[3.0] ubuntu-image classic always passes `--vcs=auto` to germinate even when told not to.

Bug #2021411 reported by Alex Lowe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Image
Fix Committed
Low
Paul Mars

Bug Description

When creating a classic image, any value of `vcs` under the seed (including not existing) causes `ubuntu-image` to call germinate with the `--vcs=auto` flag.

Workaround: comment out the vcs lines in `internal/statemachine/helper.go` and build ubuntu-image yourself

Revision history for this message
Alex Lowe (lengau) wrote :
Changed in ubuntu-image:
status: New → Confirmed
Changed in ubuntu-image:
importance: Undecided → Low
Paul Mars (upils)
Changed in ubuntu-image:
status: Confirmed → In Progress
assignee: nobody → Paul Mars (upils)
Revision history for this message
Paul Mars (upils) wrote (last edit ):

The function generating the germinate command is working as expected. I added a test case because the condition to add the `--vcs=auto` arg was not tested yet.

I am now suspecting the parsing of the Image Definition file to be causing the issue by filling default values when it should not, thus not respecting the given value. The default value for the vcs field is "true", so the --vcs=auto is added by default. If this is the case, 2 other fields maybe affected but went under the radar so far.

Revision history for this message
Paul Mars (upils) wrote :

The SetDefaults function is indeed at fault. To determine if we need to set a default value, we check if the field is set to its "zero value". In the case of a boolean, it means "false". Since Go do not have a concept of uninitialized field, there is no way to differentiate between a field not filled in the image definition and a field set to "false".

I see 2 possible ways to fix this:

- invert the current logic for the fields using boolean and having a default set to true. The 'vcs' field would be replaced by a 'NoVcs' one, with a default set to false (we can even omit it in the tag). This is a bit counter-intuitive and will represent a breaking change in the image definition schema. But it would be a simple change. Currently 'vcs' is the only boolean with a default set to true (except PPA.KeepEnabled that seems to be unused). So the change would not be too impactful.

- replace booleans by pointers to boolean. This way we can check if the pointer is nil or not and thus determine if the value was explicitly set. This will allow us to use whatever default we want for current and future booleans in the image definition schema. But it would probably be weird to deal with these pointers in the code.

Paul Mars (upils)
tags: added: foundations-todo
Paul Mars (upils)
Changed in ubuntu-image:
status: In Progress → Fix Committed
Revision history for this message
Paul Mars (upils) wrote :

Hey Alex,

FYI we have decided to keep the current logic of the 'vcs' field and replace booleans in the configuration by pointers to boolean. From a user perspective this will not require any change.

The given value for 'vcs' is now correctly used.

This is merged in the main branch so you can test if you would like.

Paul Mars (upils)
tags: removed: foundations-todo
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.