salt.file.directory state exception output confuses when stat returns Stale file handle
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description of Issue/Question
salt.file.directory state exception output confuses when stat returns Stale file handle
It should return Stale file handle instead of making changes and reporting "File exists"
Setup
As an example, I'm running nfs client state against deployed instance and mountpoint in stale state
https://github.com/salt-formulas/salt-formula-nfs/blob/42b4c1e888a8ad7cef96a590e305f9ca30fec44f/nfs/client.sls#L10-L15
I'm getting exception that file exists and being confused as the root cause is skipped check for stale state
Steps to Reproduce Issue
- Deploy nfs server and shares.
- Deploy nfs client that uses that shares
- Reboot nfs server to push nfs mountpoint into stale state
- Run nfs state against node
Reclass:
classes:
- service.nfs.client
parameters:
nfs:
client:
enabled: true
mount:
glance:
path: /var/lib/glance/images
fstype: nfs4
device: 10.10.10.10:/nfs/glance/images
root@cfg01:~# salt 'ctl01*' state.sls nfs
ctl01:
Name: nfs-common - Function: pkg.installed - Result: Clean Started: - 14:18:54.735426 Duration: 1006.491 ms
Name: rpcbind - Function: pkg.installed - Result: Clean Started: - 14:18:55.742318 Duration: 7.123 ms
ID: _var_lib_glance_images_directory
Function: file.directory
Name: /var/lib/glance/images
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1735, in call
**cdata['kwargs'])
File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1653, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/states/file.py", line 2132, in directory
name, user=user, group=group, mode=dir_mode
File "/usr/lib/python2.7/dist-packages/salt/modules/file.py", line 4788, in mkdir
makedirs_perms(directory, user, group, mode)
File "/usr/lib/python2.7/dist-packages/salt/modules/file.py", line 4885, in makedirs_perms
os.mkdir(name)
OSError: [Errno 17] File exists: '/var/lib/glance/images'
Started: 14:18:55.755375
Duration: 15.383 ms
Changes:
ID: _var_lib_glance_images_nfs_mount
Function: mount.mounted
Name: /var/lib/glance/images
Result: False
Comment: One or more requisite failed: nfs.client._var_lib_glance_images_directory
Changes:
Summary for ctl01
------------
Succeeded: 2
Failed: 2
------------
Total states run: 4
Total run time: 1.029 s
ERROR: Minions returned with non-zero exit code
Confused here.
Checked like this
root@cfg01:~# salt 'ctl01*' cmd.run 'ls -lash /var/lib/glance/images'
ctl01:
ls: cannot access '/var/lib/glance/images': Stale file handle
ERROR: Minions returned with non-zero exit code
Expected to get stale file handle exception from file.py
Versions Report
Master:
root@cfg01:~# salt --versions-report
Salt Version:
Salt: 2016.3.6
Dependency Versions:
cffi: Not Installed
cherrypy: 3.5.0
dateutil: 2.4.2
gitdb: 0.6.4
gitpython: 1.0.1
ioflo: Not Installed
Jinja2: 2.8
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.21.1
Mako: 1.0.3
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.12 (default, Nov 19 2016, 06:48:10)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.2.0
RAET: Not Installed
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: Ubuntu 16.04 xenial
machine: x86_64
release: 4.8.0-41-generic
system: Linux
version: Ubuntu 16.04 xenial
Slave:
root@ctl01:/home/ubuntu# salt-call --versions-report
Salt Version:
Salt: 2016.3.6
Dependency Versions:
cffi: 1.5.2
cherrypy: Not Installed
dateutil: 2.4.2
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.8
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.21.1
Mako: 1.0.3
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: 1.3.7
pycparser: 2.14
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.12 (default, Nov 19 2016, 06:48:10)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.2.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: Ubuntu 16.04 xenial
machine: x86_64
release: 4.8.0-52-generic
system: Linux
version: Ubuntu 16.04 xenial
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading salt/states/file.py around the directory state and salt/modules/file.py around mkdir and makedirs_perms, using the reported NFS stale-mount reproduction as context. Verify that a stale file handle is reported distinctly instead of being surfaced as "File exists," and check the state output for the expected failure behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100