salt icon indicating copy to clipboard operation
salt copied to clipboard

Forced remount because options changed when no options changed for tmpfs filesystems (2014.7)

Open RobertFach opened this issue 11 years ago • 12 comments

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:

  1. Recalculate the numbers and do the matching based on that... 4096m gets to 4194304k

or

  1. 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?

RobertFach avatar Jan 07 '15 15:01 RobertFach

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

RobertFach avatar Jan 07 '15 16:01 RobertFach

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?

rallytime avatar Jan 07 '15 19:01 rallytime

I will check if that special issue has been already fixed in the 2014.7 branch head... (most probably tomorrow) Cheers,

RobertFach avatar Jan 07 '15 23:01 RobertFach

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 avatar Jan 09 '15 14:01 RobertFach

@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 avatar Jan 09 '15 15:01 rallytime

@rallytime I'll have a look at it!

RobertFach avatar Jan 09 '15 16:01 RobertFach

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.

garethgreenaway avatar Jan 09 '15 19:01 garethgreenaway

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

RobertFach avatar Jan 12 '15 11:01 RobertFach

I have created a Pull Request with a proposed fix:

https://github.com/saltstack/salt/pull/19645

RobertFach avatar Jan 12 '15 12:01 RobertFach

@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 avatar Jan 12 '15 17:01 basepi

@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...

RobertFach avatar Jan 12 '15 21:01 RobertFach

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!

basepi avatar Jan 13 '15 20:01 basepi