Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARC Solaris] psutil.disk_partitions() fail with zones that have nfs mounts #1674

Closed
n27051538 opened this issue Jan 28, 2020 · 3 comments
Closed

Comments

@n27051538
Copy link

n27051538 commented Jan 28, 2020

Platform SPARC

  • { OS version } Solaris 11.4.4.4.0
  • { psutil version } 5.6.7

Bug description
When running in global zone, psutil.disk_partitions() fail with local solaris zones that have internal NFS mounts.
Have no way to ignore them like df util.

python code to reproduce the problem

root@globalzone:~# python2.7
Python 2.7.14 (default, Aug  9 2018, 16:46:26) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.disk_partitions()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/psutil/__init__.py", line 2132, in disk_partitions
    return _psplatform.disk_partitions(all)
  File "/usr/lib/python2.7/site-packages/psutil/_pssunos.py", line 232, in disk_partitions
    if not disk_usage(mountpoint).total:
  File "/usr/lib/python2.7/site-packages/psutil/_psposix.py", line 131, in disk_usage
    st = os.statvfs(path)
OSError: [Errno 1] Not owner: '/zones/mylocalzone/root/mnt'
>>> 

investigating problem directory looking at problem dir and via logging in localzone

root@globalzone:~# ls /zones/mylocalzone/root/mnt
/zones/mylocalzone/root/mnt: Not owner

root@globalzone:~# df | grep /zones/mylocalzone/root/mnt

root@globalzone:~# grep /zones/mylocalzone/root/mnt /etc/mnttab 
nfs-server:/share   /zones/mylocalzone/root/mnt       nfs     rw,nodevices,xattr,zone=mylocalzone,sharezone=7,dev=ffbc0001        1554476045

root@globalzone:~# zlogin mylocalzone                          
[Connected to zone 'mylocalzone' pts/7]
Last login: Tue Jan 28 02:33:44 2020 on pts/7
root@mylocalzone:~# ls /mnt
file1  file2  file3 
root@mylocalzone:~# logout
[Connection to zone 'mylocalzone' pts/7 closed]

Test results

root@globalzone:~# python -c psutil.tests
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'psutil' is not defined
@n27051538 n27051538 added the bug label Jan 28, 2020
@n27051538
Copy link
Author

n27051538 commented Jan 28, 2020

I have workarround by coping disk_partitions() in my program and rewriting it with try-except OSError arround disk_usage() :

from psutil import _psposix
from psutil import _psutil_sunos as cext
from psutil import _common
disk_usage = _psposix.disk_usage

def my_disk_partitions(all=False):
    """Return system disk partitions."""
    retlist = []
    partitions = cext.disk_partitions()
    for partition in partitions:
        device, mountpoint, fstype, opts = partition
        if device == 'none':
            device = ''
        if not all:
            try:
                if not disk_usage(mountpoint).total:
                    continue
            except OSError:
                continue

        ntuple = _common.sdiskpart(device, mountpoint, fstype, opts)
        retlist.append(ntuple)
    return retlist

my_disk_partitions() works without errors:

my_disk_partitions() 
[sdiskpart(device='... (very long output)...

@giampaolo
Copy link
Owner

giampaolo commented Feb 3, 2020

[Errno 1] Not owner is probably the same as EPERM. What happens if you use root user?

@n27051538
Copy link
Author

All written above was done as root (see header of command promt). Root also have no permission to view this folders, as I wrote.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants