-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR-5404 - The 'fstab' of 'customization' destroy original fstab content #143
Conversation
Codecov Report
@@ Coverage Diff @@
## main #143 +/- ##
==========================================
- Coverage 90.68% 90.52% -0.17%
==========================================
Files 13 13
Lines 2545 2607 +62
==========================================
+ Hits 2308 2360 +52
- Misses 210 215 +5
- Partials 27 32 +5
|
5e20d28
to
b6e4387
Compare
I just found https://bugs.launchpad.net/ubuntu-image/+bug/1955019 so I will rework this to also solve this bug. |
865319c
to
31e7c39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't take a look at the code in detail just yet, but I'm already thinking about the concept of fstab customization itself.
I think we should only support the case of overwriting the image fstab via customizations. I'm trying to think of a case where we'd need to 'modify' an fstab, and it feels very hm, hacky. It's not 100% possible of course, but we try for the image definition file to be as deterministic as possible with the options it provides (minus the manual
customizations). By allowing appending fstab entries, we willingly remove some of the determinism here. This can lead to duplicate entries in fstab or other weird behavior you might not see instantly.
Did we have a request from someone to actually support appending entries to fstab instead of just writing it from scratch? The fstab customization was always supposed to be a bit of a 'convenience' function. In my mind things like this should be done by customization packages, but this way it's just faster to iterate on it.
Were there some cases in livecd-rootfs that require this? I'd like to understand a bit better if we really need this, since otherwise I'd just stick with overwriting in all cases.
Based on the bug wording I thought that at least the OEM enablement team considered the fstab customization was supposed to append to the existing fstab, but this is not obvious now that I read it again. The idea was to make this feature flexible and make sure the behavior was clear. I have looked at the livecd-rootfs code (especially hooks) and also found 2 bugs related to fstab management:
I understand that the fstab is:
I also see cloud-init enables users setting custom fstab entries. I fear that if we only allow overriding completely the existing fstab (current behavior prior to this PR) we won't be able to satisfy the need of some team when they try to use ubuntu-image. Based on the spec mentioning the fstab customization in image definition, we never properly defined what we wanted to do with this. Based on our various image definition in fstab:
-
label: "writable"
mountpoint: "/"
filesystem-type: "ext4"
dump: false
fsck-order: 1
-
label: "system-boot"
mountpoint: "/boot/firmware"
filesystem-type: "vfat"
mount-options: "defaults"
dump: false
fsck-order: 1 I am not 100% sure we should add the "FstabTruncate" feature but I think we should decide what is the responsibility of ubuntu-image regarding the resulting fstab. I see several possibilities:
Unfortunately even the last solution won't cover every customization needs that is currently covered by hooks, customization packages or cloud-init configuration because:
So since we will never be able to fully manage the fstab in one place in oneshot, I suggest to:
|
I think your suggestion is sane. I think ubuntu-image modifying the fstab to allow boot (aka. the writable bits) + allowing setting (and overwriting) the fstab should be the immediate way forward. If we get additional requests from users about more fine grained requirements, we can revisit this when working on imagecraft. |
Tests were inaccurate. The default value was always set for pointers to bool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Some small inline questions, but nothing blocking.
} | ||
|
||
// fixFstab makes sure the fstab contains a valid entry for the root mount point | ||
func (stateMachine *StateMachine) fixFstab() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on having this be a separate state, thanks!
@@ -0,0 +1,65 @@ | |||
package statemachine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% into go, but is this file name convention correct? I always thought _test.go
files were for the actual tests, not test helpers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files with _test
suffix are excluded from regular package builds but will be included when the "go test" command is run. Otherwise you can put whatever functions you want in these files. Here I wanted to signal that what is in this file is used in the various tests across the package, and the tests only. I wanted to avoid the confusion with helper_test.go
which is (by convention) a file that should contains functions to test what is in helper.go
(and not contains test helpers).
If ubuntu-image had been destined to evolve more, I would have moved this to a dedicated "test" pkg at some point I think.
Fixes https://bugs.launchpad.net/ubuntu-image/+bug/2031889