Forced remount because options changed when no options changed for tmpfs filesystems (2014.7)
salt-minion 2014.7.0 (Helium)
I have the following state
tmpfs_filesystem:
mount.mounted:
- name: /tmp
- device: tmpfs
- fstype: tmpfs
- mkmnt: True
- persist: True
- opts:
- size=4096m
My corresponding fstab looks like this:
*tmpfs /tmp tmpfs size=4096m 0 0*
mount -l shows also
*tmpfs on /tmp type tmpfs (rw,size=4096m)*
But /cat/proc/mounts shows
*tmpfs /tmp tmpfs rw,relatime,size=4194304k 0 0*
which is the base for deciding if a mount option changed... The problem is now that the numbers in megabytes are not adapted/recalculated to the kb values to be matched.
I have two ideas how to solve this:
- Recalculate the numbers and do the matching based on that... 4096m gets to 4194304k
or
- Merge the options of a specific device of the output of mount -l into the option list received by the proc filesystem and use the resulting list as base for the comparison... In that case you would have two size entries; one with megabytes and one with kilobytes...
Any comments/suggestions?
Btw. as a workaround, one can simply always use kilobytes in the state to specify size values like that:
tmpfs_filesystem:
mount.mounted:
- name: /tmp
- device: tmpfs
- fstype: tmpfs
- mkmnt: True
- persist: True
- opts:
- size=4194304k
Thanks for the report @RobertFach. I know that @garethgreenaway has been fixing quite a few mount issues lately and this might be fixed already, though I haven't tried it myself yet. Are you in a position to try testing this on the current 2014.7 branch HEAD?
I will check if that special issue has been already fixed in the 2014.7 branch head... (most probably tomorrow) Cheers,
I have verified that the problem is not fixed on the 2014.7 branch (salt-minion 2014.7.0-1213-gfd174db (Helium) ).
As I mentioned, the problem is related to the unit of the size argument.
@RobertFach Thanks for testing that! We'll take a look and get this fixed up. Or, if you have a fix, we'd gladly accept a pull request!
@rallytime I'll have a look at it!
Doesn't look like something that has been addressed yet. My thought is that we should convert to value to KB to compare it with the value that's found under /proc.
I agree, this seems to be the cleanest solution.
Btw. in order to fix this issue, I would like to use a library to convert possible sizes to kilobytes, e.g., pypi bitmath library. What is the recommended way in Salt to get usage of a lib? What do I have to do to get it included? As an alternative, one could also implement the conversion on its own - however, I prefer to reuse already existing code.
What do you think? @rallytime , @garethgreenaway
I have created a Pull Request with a proposed fix:
https://github.com/saltstack/salt/pull/19645
@RobertFach It looks like you went the way of implementing the conversion on your own. That was the right way. We work very hard to avoid adding additional hard deps to salt. Modules which dep on a third party library use the __virtual__ function to only load if the dependencies are installed. So if you had to use a third party library, you'd have to also make that module not load unless that library was installed, which hurts usability on the module.
Hopefully that makes sense. Thanks for your pull request!
@basepi Thx for this info... I think it makes sense, as it keeps the number of dependencies and hence issues low. Especially in my case it was very simple to make the calculations on my own... One point that I couldn't check is if the proc fs always reports sizes in kilobytes on all operating systems. If not, then the fix would not work on all systems. In that context, I have seen that you spawn some test environments (Ubuntu, RHEL) in an Openstack Cluster, what kind of tests am I able to run there? Just thinking loud... I should check the documentation...
Cheers...
We run all the unit tests and integration tests on a number of different distributions at regular intervals at jenkins.saltstack.com. You can check out the existing tests in the tests/ directory.
Anyway, looks like your fix was merged, so I'm going to go ahead and close this!