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

o/snapstate: respect validation sets when refreshing and installing components with snaps #14783

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

andrewphelpsj
Copy link
Member

This change makes it so that we respect validation sets when installing/refreshing components alongside snaps.

Note that the store doesn't yet fully support introspecting the validation sets that are sent during a refresh, so they cannot yet change which component revisions are actually returned with the actions. We double check the actions that are returned from the store to ensure that we always follow the correct constraints.

Based on #14769 for now.

@github-actions github-actions bot added the Needs Documentation -auto- Label automatically added which indicates the change needs documentation label Dec 2, 2024
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 75.42373% with 29 lines in your changes missing coverage. Please review.

Project coverage is 78.20%. Comparing base (96ea7b0) to head (bc97387).
Report is 136 commits behind head on master.

Files with missing lines Patch % Lines
overlord/snapstate/target.go 77.52% 16 Missing and 4 partials ⚠️
overlord/snapstate/snapmgr.go 50.00% 4 Missing and 2 partials ⚠️
overlord/snapstate/storehelpers.go 82.35% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #14783      +/-   ##
==========================================
- Coverage   78.95%   78.20%   -0.75%     
==========================================
  Files        1084     1148      +64     
  Lines      146638   151351    +4713     
==========================================
+ Hits       115773   118359    +2586     
- Misses      23667    25659    +1992     
- Partials     7198     7333     +135     
Flag Coverage Δ
unittests 78.20% <75.42%> (-0.75%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@andrewphelpsj andrewphelpsj force-pushed the component-vsets-on-refresh-install branch from 905260a to bc97387 Compare December 3, 2024 17:22
@github-actions github-actions bot removed the Needs Documentation -auto- Label automatically added which indicates the change needs documentation label Dec 3, 2024
Copy link
Contributor

@miguelpires miguelpires left a comment

Choose a reason for hiding this comment

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

looks good but missing a test I think

Comment on lines 361 to 366
return fmt.Errorf(
"cannot %s snap %q due to enforcing rules of validation set %s",
verb,
instanceName,
constraints.Sets.CommaSeparated(),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry to be nitpicking on style but to me this more verbose and actually less readable than just splitting it in two lines

Suggested change
return fmt.Errorf(
"cannot %s snap %q due to enforcing rules of validation set %s",
verb,
instanceName,
constraints.Sets.CommaSeparated(),
)
return fmt.Errorf("cannot %s snap %q due to enforcing rules of validation set %s",
verb, instanceName, constraints.Sets.CommaSeparated())

IMO it makes it easier to match the format specifiers to the variables

constraints snapasserts.SnapPresenceConstraints,
action string,
) error {
if constraints.Presence == asserts.PresenceInvalid {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we're missing a test for this case

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, thanks. There was an identical check right before calling this function, preventing the test that should have hit it from going in there.

Comment on lines 347 to 348
// should something like this maybe be a method on snapasserts.ValidationSets?
// the error strings are the main thing that don't really fit well in there
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems fine as a standalone function, a method doesn't feel particularly more natural than this

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