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/devicestate: allow remodeling back to an old snap revision that includes components #15060

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

Conversation

andrewphelpsj
Copy link
Member

@andrewphelpsj andrewphelpsj commented Feb 11, 2025

This will enable us to remodel back to a snap revision that was already installed in the past (somewhere in the sequence), assuming that the snap has all of the components that are needed already installed as well.

@andrewphelpsj andrewphelpsj modified the milestones: 2.68, 2.68.1 Feb 11, 2025
@andrewphelpsj andrewphelpsj added the Run nested The PR also runs tests inluded in nested suite label Feb 11, 2025
Copy link

github-actions bot commented Feb 11, 2025

Thu Mar 13 19:17:47 UTC 2025
The following results are from: https://github.com/canonical/snapd/actions/runs/13840156322

Failures:

Preparing:

  • google-nested:ubuntu-22.04-64:tests/nested/manual/core20-boot-config-update:gadgetfull
  • google-nested:ubuntu-24.04-64:tests/nested/manual/hybrid-remodel

Executing:

  • google-nested:ubuntu-20.04-64:tests/nested/manual/remodel-offline:installed_snaps
  • google-nested:ubuntu-20.04-64:tests/nested/manual/remodel-offline:local_assertions
  • google-nested:ubuntu-22.04-64:tests/nested/manual/update-snapd-seed-and-factory-reset:tpm
  • google-nested:ubuntu-24.04-64:tests/nested/manual/muinstaller-real:seeded
  • google-nested:ubuntu-24.04-64:tests/nested/manual/muinstaller-real:encrypted
  • google-nested:ubuntu-24.04-64:tests/nested/manual/muinstaller-real:plain
  • google-nested:ubuntu-24.04-64:tests/nested/manual/passphrase-support-on-hybrid:argon2id
  • google-nested:ubuntu-24.04-64:tests/nested/manual/muinstaller-core:install_optional_all
  • google-nested:ubuntu-24.04-64:tests/nested/manual/core20-factory-reset-install-device-hook
  • google-nested:ubuntu-24.04-64:tests/nested/manual/muinstaller-core:passphrase_auth
  • google-core:ubuntu-core-18-64:tests/core/gadget-update-pc
  • google-core:ubuntu-core-20-64:tests/main/default-tracks
  • google:ubuntu-20.04-64:tests/main/lxd:snapd_cgroup_just_outside
  • google:ubuntu-20.04-64:tests/main/lxd:snapd_cgroup_just_inside
  • google:ubuntu-20.04-64:tests/main/lxd:snapd_cgroup_neither

Restoring:

  • google-nested:ubuntu-22.04-64:tests/nested/manual/muinstaller-real:plain
  • google-nested:ubuntu-22.04-64:tests/nested/manual/
  • google-nested:ubuntu-22.04-64
  • google-nested:ubuntu-24.04-64:tests/nested/manual/minimal-smoke:secboot_enabled
  • google-nested:ubuntu-24.04-64:tests/nested/manual/muinstaller-core:install_optional_all
  • google-nested:ubuntu-24.04-64:tests/nested/manual/
  • google-nested:ubuntu-24.04-64
  • google-nested:ubuntu-24.04-64:tests/nested/manual/
  • google-nested:ubuntu-24.04-64
  • google-nested:ubuntu-24.04-64:tests/nested/manual/core20-factory-reset-install-device-hook
  • google-nested:ubuntu-24.04-64:tests/nested/manual/
  • google-nested:ubuntu-24.04-64
  • google-nested:ubuntu-24.04-64:tests/nested/manual/muinstaller-core:passphrase_auth
  • google-nested:ubuntu-24.04-64:tests/nested/manual/
  • google-nested:ubuntu-24.04-64
  • google-core:ubuntu-core-18-64:tests/core/gadget-update-pc
  • google-core:ubuntu-core-18-64:tests/core/
  • google-core:ubuntu-core-18-64

@ernestl ernestl modified the milestones: 2.68.1, 2.68.2 Feb 24, 2025
@ernestl
Copy link
Collaborator

ernestl commented Feb 25, 2025

As discussed with @andrewphelpsj, it's unlikely this content will make 2.68.2. Keeping tag for the moment, will reevaluate when everything else is ready.

Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 64.28571% with 15 lines in your changes missing coverage. Please review.

Project coverage is 78.13%. Comparing base (3141522) to head (f7d9051).
Report is 55 commits behind head on master.

Files with missing lines Patch % Lines
snap/snaptest/snaptest.go 0.00% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #15060      +/-   ##
==========================================
+ Coverage   78.06%   78.13%   +0.06%     
==========================================
  Files        1183     1183              
  Lines      158250   158660     +410     
==========================================
+ Hits       123541   123963     +422     
+ Misses      27029    26990      -39     
- Partials     7680     7707      +27     
Flag Coverage Δ
unittests 78.13% <64.28%> (+0.06%) ⬆️

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.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ernestl
Copy link
Collaborator

ernestl commented Feb 26, 2025

This PR is not going to make 2.68.2, moving to 2.69. @andrewphelpsj @pedronis

@ernestl ernestl modified the milestones: 2.68.2, 2.69 Feb 26, 2025
@andrewphelpsj andrewphelpsj force-pushed the remodel-fix-back-to-old-revision branch from a134697 to c58aa33 Compare March 4, 2025 14:10
…ith components involved

This change also makes it so we no longer depend on snapstate.Update not
reaching out to the store if the snap revision is already installed.
@andrewphelpsj andrewphelpsj force-pushed the remodel-fix-back-to-old-revision branch from c58aa33 to 24ca0f1 Compare March 6, 2025 20:35
@andrewphelpsj andrewphelpsj marked this pull request as ready for review March 6, 2025 20:36
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

questions

Comment on lines +10359 to +10364
if wrongRevisionInstalled {
c.Assert(err, ErrorMatches, `cannot fall back to component "pc-kernel\+kmod" with revision 11, required revision is 12`)
} else {
c.Assert(err, ErrorMatches, `cannot find required component in set of already installed components: pc-kernel\+kmod`)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

the helper could actually return the error and the Assert moved into the tests, no need for the boolean flag

Copy link
Member Author

Choose a reason for hiding this comment

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

wrongRevisionInstalled is used earlier in the function as part of the setup as well. I made an attempt at moving the setup into the calling functions, as well as returing the error. My attempt didn't look that great. But I'm happy to try again if you think it'd be better that way.

}

return snapstateStoreUpdateGoal(snapstate.StoreUpdate{
return snapstatePathUpdateGoal(snapstate.PathSnap{
Copy link
Collaborator

Choose a reason for hiding this comment

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

will this actually move the old sequence point in front or will there be two sequence points?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will move the sequence point to the end of the sequence. You can see that in TestUpdateWithComponentsBackToPrevRevision: https://github.com/canonical/snapd/blob/master/overlord/snapstate/snapstate_update_test.go?plain=1#L15370-L15374.

Copy link
Collaborator

@pedronis pedronis Mar 13, 2025

Choose a reason for hiding this comment

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

where do I see that that test is using a PathUpdateGoal?

updated["pc-kernel"],
}, []interface{}{
updated["pc-kernel+kmod"],
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

should the test also look at the state of the corresponding SnapState.Sequence after the remodel?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a good idea, and will clear up your other question. These specific tests aren't set up to actually drive the change to completion right now; I'll work on that.

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like that style of test would fit better in managers_test.go, since this change goes across many managers.

@andrewphelpsj andrewphelpsj requested a review from pedronis March 12, 2025 16:37
Comment on lines +18042 to +18043
c.Assert(snapst.Sequence.Revisions[0], DeepEquals, originalSideState)
c.Assert(snapst.Sequence.Revisions[1], DeepEquals, expectedSideState)
Copy link
Collaborator

Choose a reason for hiding this comment

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

so these are swapped now vs when they were read out in the fixture setup?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that is correct.

@andrewphelpsj andrewphelpsj requested a review from pedronis March 14, 2025 18:16
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

thanks

Copy link
Member

@alfonsosanchezbeato alfonsosanchezbeato left a comment

Choose a reason for hiding this comment

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

LGTM, thanks - please remember to fix the leftover before merging, see cooment

Comment on lines +119 to +124
// err = os.MkdirAll(filepath.Dir(cpi.MountFile()), 0755)
// c.Assert(err, check.IsNil)
//
// contents := fmt.Sprintf("%s-%s", csi.Component.String(), csi.Revision)
// err = os.WriteFile(cpi.MountFile(), []byte(contents), 0644)
// c.Assert(err, check.IsNil)

Choose a reason for hiding this comment

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

You probably forgot to remove this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Run nested The PR also runs tests inluded in nested suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants