Skip to content
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-5402 - ubuntu-image classic always passes --vcs=auto to germinate even when told not to #146

Merged
merged 4 commits into from
Oct 4, 2023

Conversation

upils
Copy link
Collaborator

@upils upils commented Sep 27, 2023

@upils upils marked this pull request as draft September 27, 2023 12:37
@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

Merging #146 (aa24b6f) into main (5b10b91) will increase coverage by 2.40%.
Report is 9 commits behind head on main.
The diff coverage is 100.00%.

❗ Current head aa24b6f differs from pull request most recent head 6f8e4be. Consider uploading reports for the commit 6f8e4be to get more accurate results

@@            Coverage Diff             @@
##             main     #146      +/-   ##
==========================================
+ Coverage   87.32%   89.72%   +2.40%     
==========================================
  Files          11       11              
  Lines        2437     2589     +152     
==========================================
+ Hits         2128     2323     +195     
+ Misses        289      244      -45     
- Partials       20       22       +2     
Files Coverage Δ
internal/helper/helper.go 23.10% <100.00%> (+18.59%) ⬆️
internal/imagedefinition/image_definition.go 100.00% <ø> (ø)
internal/statemachine/helper.go 98.67% <100.00%> (ø)

... and 3 files with indirect coverage changes

@upils upils requested a review from sil2100 September 29, 2023 07:09
@upils upils marked this pull request as ready for review September 29, 2023 07:10
Copy link
Contributor

@sil2100 sil2100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, I know you already did work for this fix here, but I will have to indeed object to the renaming of vcs to no-vcs. One thing is what you mentioned in the LP bug already: backwards compatibility. I wouldn't want us to fix something by changing the schema per-se. Second, the schema so far doesn't really have any 'negative keys', aka. this would be the first inverse field in the yaml file. And I don't think it's very intuitive in this case.

It is indeed a troublesome feature of the boolean in this case, and I think it's a shame that the schema handling does not really handle fields being unassigned in some special way (like via a separate flag somewhere). Potentially this problem can appear for any boolean value, and I don't think we should build out schema against limitations of the language/framework we're using.

I know you mentioned a pointer approach, which I guess could be doable - we could design it in such a way to use it in any other future booleans if the need appears. I was personally even thinking of using a string here, but that seems a bit worse? Anyway, could you take a look at it so that we don't have to change the schema? Thank you!

@upils upils force-pushed the vcs-option-broken branch from 2c7625c to f1be00d Compare October 3, 2023 07:55
@upils
Copy link
Collaborator Author

upils commented Oct 3, 2023

Fixed it using pointers to booleans. I also updated the definition of KeepEnabled even though it is not used. I understand this is to keep a kind of compatibility with *crafts configuration, but should we remove it?

@upils upils requested a review from sil2100 October 3, 2023 08:55
Copy link
Contributor

@sil2100 sil2100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. And I like the additional improvements to the testing story. This feels good for merging.

As for KeepEnabled - this is a bug/missing-feature if it's not used. I thought we did handle it properly. Might be that it got missed due to deadlines. Basically it means whether the enabled PPA should be kept enabled on the built system after package installation. Let me create a card for it.

case reflect.Slice:
defaultValues := strings.Split(defaultValue, ",")
field.Set(reflect.ValueOf(defaultValues))
case reflect.Bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking if maybe at this point we shouldn't just drop this part. Maybe it's better to remind us that it's not really 'safe' to use default values for pure booleans. Sure, there are cases where this would work, but it's unreliable IMO. So maybe I'd propose to remove this line and let us error out when trying to set a default. We should probably use pointers-to-booleans for every boolean with a default value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that is unreliable. I will error out when trying to set a default on a bool. I will also add a specific test case on the image definition to make sure we never add a bool with a default. Without this test we risk letting it pass and users will face an error they cannot do anything about.

A []*S4
}

func TestSetDefaults(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -97,7 +97,7 @@ type PPA struct {
PPAName string `yaml:"name" json:"PPAName" jsonschema:"pattern=^[a-zA-Z0-9_.+-]+/[a-zA-Z0-9_.+-]+$"`
Auth string `yaml:"auth" json:"Auth,omitempty" jsonschema:"pattern=^[a-zA-Z0-9_.+-]+:[a-zA-Z0-9]+$"`
Fingerprint string `yaml:"fingerprint" json:"Fingerprint,omitempty"`
KeepEnabled bool `yaml:"keep-enabled" json:"KeepEnabled" default:"true"`
KeepEnabled *bool `yaml:"keep-enabled" json:"KeepEnabled" default:"true"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for this, I'll mention more about it in my main review comment, but I missed that it's not used! I was sure we used it already!

@sil2100
Copy link
Contributor

sil2100 commented Oct 3, 2023

Ok, before merging, could you maybe remove the boolean handling though?

@upils upils requested a review from sil2100 October 3, 2023 12:55
Copy link
Contributor

@sil2100 sil2100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@sil2100
Copy link
Contributor

sil2100 commented Oct 4, 2023

hm, linting failed, but that doesn't seem to be a real issue?

@upils upils force-pushed the vcs-option-broken branch from aa24b6f to 6f8e4be Compare October 4, 2023 08:02
@upils
Copy link
Collaborator Author

upils commented Oct 4, 2023

Yeah, just a minor linting error about import order. This is fixed.

@sil2100 sil2100 merged commit 6193013 into main Oct 4, 2023
@upils upils deleted the vcs-option-broken branch November 28, 2023 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants