Forced remount because options changed when no options changed (2014.7 regression)
Running a highstate on minions with some NFS mounts results in the mount being remounted every time. This did not occur under 2014.1
----------
[INFO ] Completed state [/nfsmnt] at time 17:21:20.145018
[INFO ] Running state [/nfsmnt] at time 17:21:20.146726
[INFO ] Executing state mount.mounted for /nfsmnt
[INFO ] Executing command 'mount -l' in directory '/root'
[INFO ] Executing command 'mount -l' in directory '/root'
[INFO ] Executing command 'mount -o rw,tcp,bg,hard,intr,remount -t nfshost:/nfsmnt /nfsmnt ' in directory '/root'
[INFO ] {'umount': 'Forced remount because options changed'}
[INFO ] Completed state [/nfsmnt] at time 17:21:20.267764
...
ID: /nfsmnt
Function: mount.mounted
Result: True
Comment:
Started: 10:04:16.078806
Duration: 68.802 ms
Changes:
----------
umount:
Forced remount because options changed
Running mount -l shows the following:
...
nfshost:/nfsmnt on /nfsmnt type nfs (rw,remount,tcp,bg,hard,intr,addr=x.x.x.x)
I can only assume it's breaking due to the addr option (which is automatically filled by the OS by the looks of it, it was never manually specified as a mount option) or the ordering.
The mount.mounted state looks as follows:
/nfsmnt:
mount.mounted:
- device: nfshost:/nfsmnt
- fstype: nfs
- opts: rw,tcp,bg,hard,intr
# salt-call --versions-report
Salt: 2014.7.0
Python: 2.6.8 (unknown, Nov 7 2012, 14:47:45)
Jinja2: 2.5.5
M2Crypto: 0.21.1
msgpack-python: 0.1.12
msgpack-pure: Not Installed
pycrypto: 2.3
libnacl: Not Installed
PyYAML: 3.08
ioflo: Not Installed
PyZMQ: 14.3.1
RAET: Not Installed
ZMQ: 4.0.4
Mako: Not Installed
@nvx Thank you for this very helpful bug report! We'll check this out.
This might be related to #18474
@garethgreenaway I don't think so: applying the patch manually didn't fix the issue for me. Besides I believe the option checking should not fail in the first place: as @nvx said: no option changed. This issue arose for me when upgrading salt-2014.1.10-4.el5.noarch -> salt-2014.7.0-3.el5.noarch if that helps.
As a guess I would agree with @nvx it's remounting it because the addr option appears in the list of mounted file systems but not in the mount options specified in the state. There are a few that we flag as "hidden" options, we may have to do the same for the addr option.
Not sure if "me too"s are useful, but I'm experiencing this as well, and also with an NFS mount. My SLS entry looks like this:
/egtnas:
file.directory:
- makedirs: True
mount.mounted:
- device: 10.0.7.48:/
- fstype: nfs
- mkmnt: True
- opts: rw,proto=tcp,port=2049
and mount -l includes this line:
10.0.7.48:/ on /egtnas type nfs (rw,proto=tcp,port=2049)
but when I run salt-call -l debug state.highstate then I see this in the log output:
[INFO ] Executing state mount.mounted for /egtnas
[INFO ] Executing command 'mount -l' in directory '/root'
[DEBUG ] stdout: /dev/xvda1 on / type ext4 (rw) [cloudimg-rootfs]
<... snip ...>
10.0.7.48:/ on /egtnas type nfs (rw,proto=tcp,port=2049)
[INFO ] Executing command 'mount -l' in directory '/root'
[DEBUG ] stdout: /dev/xvda1 on / type ext4 (rw) [cloudimg-rootfs]
<... snip ...>
10.0.7.48:/ on /egtnas type nfs (rw,proto=tcp,port=2049)
[INFO ] Executing command 'mount -o rw,proto=tcp,port=2049,remount -t nfs 10.0.7.48:/ /egtnas ' in directory '/root'
[INFO ] {'umount': 'Forced remount because options changed'}
[INFO ] Completed state [/egtnas] at time 11:10:16.359984
and then the output includes this:
ID: /egtnas
Function: mount.mounted
Result: True
Comment:
Started: 11:10:16.335117
Duration: 24.867 ms
Changes:
----------
umount:
Forced remount because options changed
I'm running version 2014.7.0+ds-2trusty1 from the PPA:
Salt: 2014.7.0
Python: 2.7.6 (default, Mar 22 2014, 22:59:56)
Jinja2: 2.7.2
M2Crypto: 0.21.1
msgpack-python: 0.3.0
msgpack-pure: Not Installed
pycrypto: 2.6.1
libnacl: Not Installed
PyYAML: 3.10
ioflo: Not Installed
PyZMQ: 14.0.1
RAET: Not Installed
ZMQ: 4.0.4
Mako: 0.9.1
Planning to take a look at this today, hoping that some of the fixes I put in that got merged this morning addressed this. Thanks for the reports.
The fix provided by @garethgreenaway in #18978 changed, but didn't fix the situation for me.
Using now salt/states/mount.py from 2014.7 as of ec9061983e822fa95597e155e811c18d4bf278e4 and get now this result from my NFS mount states:
----------
ID: library-storage-mount
Function: mount.mounted
Name: /media/remotefs/library
Result: None
Comment: Remount would be forced because options (bg) changed
Started: 23:35:40.916259
Duration: 73.019 ms
Changes:
@eliasp Can you include your state?
@garethgreenaway Sure, sorry…
{{ share }}-storage-mount:
mount.mounted:
- name: {{ pillar['storage']['mountroot'] }}/{{ share }}
- device: {{ host }}:/{{ share }}
- fstype: nfs
- mkmnt: True
- opts:
- defaults
- bg
- soft
- intr
- timeo=5
- retrans=5
- actimeo=10
- retry=5
- require:
- pkg: nfs-common
The current mount already includes the bg option state.highstate test=True wants to change:
$ mount | ack-grep -i library
134.2.xx.xx:/library on /media/remotefs/library type nfs (rw,bg,soft,intr,timeo=5,retrans=5,actimeo=10,retry=5)
The corresponding entry in /proc/self/mountinfo doesn't contain the bg option:
53 22 0:37 / /media/remotefs/library rw,relatime - nfs 134.2.xx.xx:/library rw,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=10,acregmax=10,acdirmin=10,acdirmax=10,soft,proto=tcp,timeo=5,retrans=5,sec=sys,mountaddr=134.2.xx.xx,mountvers=3,mountport=33308,mountproto=udp,local_lock=none,addr=134.2.xx.xx
Besides that, I stumbled upon a traceback while working on this. In case the device/resource is currently busy, the mount state will backtrace instead of handling this more graceful. I'll file a separate issue for this.
Another related case I found here with a CIFS mount: State:
elite-mount:
mount.mounted:
- name: {{ pillar['linux']['remotefspath'] }}/{{ name }}_share
- device: //{{ data.address }}/{{ data.share }}
- fstype: cifs
- mkmnt: True
- opts:
- username={{ data.user }}
- password={{ data.password }}
- _netdev
- soft
state.highstate test=True:
ID: elite-mount
Function: mount.mounted
Name: /media/remotefs/elite_share
Result: None
Comment: Remount would be forced because options (password=plain-text-password-redacted) changed
Started: 01:49:46.970902
Duration: 86.95 ms
Changes:
Entry in /proc/self/mountinfo:
45 22 0:35 / /media/remotefs/elite_share rw,relatime - cifs //192.168.1.2/data_mirror rw,vers=1.0,cache=strict,username=backupuser,domain=8B9865J,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.1.2,file_mode=0755,dir_mode=0755,nounix,serverino,rsize=61440,wsize=65536,actimeo=1
So there are two issues here:
- It trips over the (non-)existing
passwordparam - It shows the value of
passwordas plaintext (redacted above asplain-text-password-redacted)
… and another option which causes mount.mounted to stumble:
Forced remount because options (soft) changed
This is caused by the CIFS state described in my previous comment.
Is soft a valid flag for cifs?
Yes, soft is a valid flag which is used by default, so my usage of it in the state is actually redundant but not wrong.
On December 31, 2014 3:18:06 AM CET, garethgreenaway [email protected] wrote:
Is soft a valid flag for cifs?
Reply to this email directly or view it on GitHub: https://github.com/saltstack/salt/issues/18630#issuecomment-68418655
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Created #19369 to address some additional issues I ran into in my setup. With #19369 applied everything works for me so far.
Thanks for following up everyone! @nvx with the two pull requests applied, is this issue fixed for you as well?
I can confirm that #19369 will help with this problem... I have the same problem with nfs mounts that have a "bg" option set. The problem is that these options are not reflected in the proc filesystem.
In which release could I see the fix?
In which release could I see the fix?
This will be in 2014.7.1 and 2015.2.0.
If you want to test it now, place salt/states/mount.py from 2014.7 your states repository/directory in a new subdirectory named _states.
Then run salt your-minion saltutil.sync_all to distribute it to your minion(s) where you'd want to test it.
See also Dynamic Module Distribution for more details on how to do this.
Don't forget to remove _states/mount.py once you updated your minions to the next release.
Hmm I updated states/mount.py from the 2014.7 branch and I now get this error:
----------
ID: /nfsmnt
Function: mount.mounted
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1533, in call
**cdata['kwargs'])
File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python2.6/site-packages/salt/utils/context.py", line 41, in func_globals_inject
yield
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1533, in call
**cdata['kwargs'])
File "/var/cache/salt/minion/extmods/states/mount.py", line 191, in mounted
if opt not in active[real_name]['opts'] and opt not in active[real_name]['superopts'] and opt not in mount_invisible_options:
KeyError: 'superopts'
Started: 14:43:01.999878
Duration: 40.286 ms
Changes:
I tried updating modules/mount.py as well but it didn't help.
/nfsmnt:
mount.mounted:
- device: nfshost:/nfsmnt
- fstype: nfs
- opts: rw,tcp,bg,hard,intr
This could be an issue in 2014.7 unrelated to the fixing of this issue though. Is there a known-good revision that has this issue fixed that I can test to confirm fix?
@nvx what OS? distribution? Kernel version?
Same as described in the initial post.
RHEL5 x64
Linux boxen 2.6.18-400.1.1.el5 #1 SMP Sun Dec 14 06:01:17 EST 2014 x86_64 x86_64 x86_64 GNU/Linux
Salt: 2014.7.0
Python: 2.6.8 (unknown, Nov 7 2012, 14:47:45)
Jinja2: 2.5.5
M2Crypto: 0.21.1
msgpack-python: 0.1.12
msgpack-pure: Not Installed
pycrypto: 2.3
libnacl: Not Installed
PyYAML: 3.08
ioflo: Not Installed
PyZMQ: 14.3.1
RAET: Not Installed
ZMQ: 4.0.4
Mako: Not Installed