goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.57k stars 472 forks source link

mount option is not working as expected #648

Closed vinodhkumart closed 3 years ago

vinodhkumart commented 3 years ago

/dev/mapper/testvg-home /home xfs defaults,nosuid 0 0 is my fstab entry. I wrote my goss test as below.

mount: /home: exists: true opts:

When i run the test it says the below error. Looks like it takes the hardcoded opts of rw, relatime by default. How can i exclude this ? Test:

Failures/Skipped:

Mount: /home: opts: Expected <[]string | len:3, cap:3>: ["rw", "nosuid", "relatime"] to contain element matching

: defaults Total Duration: 0.001s Count: 4, Failed: 1, Skipped: 0
aelsabbahy commented 3 years ago

I think this is related to https://github.com/aelsabbahy/goss/issues/443 which is scheduled to be released with v0.4.0

Can you look over the other PR and verify if it is the same issue?

vinodhkumart commented 3 years ago

Yes, The same issue for me also. Thanks for the reply

wilrodriguez commented 3 years ago

@aelsabbahy I don't think this is anything wrong with goss, so it's not going to be fixed by that release.

I think it has more to do with the fact that defaults is an alias to the system defaults and not a representation of what the actual mount options are for a mounted filesystem. It is only relevant to the mount command and fstab and is equivalent to rw, suid, dev, exec, auto, nouser, and async (note that the exact list may change based on your platform). It would make sense to test for defaults if you were testing an fstab entry's mount options, as that's the only place where the defaults alias exists, but goss currently can't do that, it only tests live mounts. Instead, you'll want to only test the options you care about, such as nosuid.

aelsabbahy commented 3 years ago

@wilrodriguez Good point regarding aliases.

I would be curious on what /proc/self/mountinfo looks like for you @vinodhkumart

vinodhkumart commented 3 years ago

Thanks for the info @wilrodriguez

@aelsabbahy Sample output for home directory under the /proc/self/mountinfo is as follows.

46 39 253:2 / /home rw,nosuid,relatime shared:31 - xfs /dev/mapper/testvg-homelv rw,attr2,inode64,noquota

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.