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, o/devicestate: remodel with components from the store #14933

Conversation

andrewphelpsj
Copy link
Member

@andrewphelpsj andrewphelpsj commented Jan 15, 2025

This change enables us to do a remodel that includes components from the store. This is a little incomplete, as I discovered that I need to handle the case where we swap to an already installed kernel (leftover from a previous remodeling) that may have some components already installed. This is a small edge case, and will not change most of the PR.

Based on #14939 for now.

Copy link

github-actions bot commented Jan 15, 2025

Fri Jan 31 23:04:53 UTC 2025
The following results are from: https://github.com/canonical/snapd/actions/runs/13075034459

Failures:

Preparing:

  • openstack:opensuse-tumbleweed-64
  • openstack:opensuse-tumbleweed-64
  • openstack:opensuse-tumbleweed-64
  • openstack:opensuse-tumbleweed-64
  • openstack:opensuse-tumbleweed-64
  • openstack:opensuse-tumbleweed-64

Executing:

  • openstack:debian-12-64:tests/upgrade/basic
  • google-nested:ubuntu-24.04-64:tests/nested/manual/remodel-min-size

Restoring:

  • openstack:debian-12-64:tests/upgrade/basic
  • openstack:opensuse-tumbleweed-64
  • openstack:opensuse-tumbleweed-64
  • openstack:opensuse-tumbleweed-64
  • openstack:opensuse-tumbleweed-64
  • openstack:opensuse-tumbleweed-64
  • openstack:opensuse-tumbleweed-64

@andrewphelpsj andrewphelpsj force-pushed the remodel-components-from-store branch 2 times, most recently from 9d70ca3 to f291bf0 Compare January 16, 2025 19:06
Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 78.99160% with 25 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@81fd929). Learn more about missing BASE report.
Report is 64 commits behind head on master.

Files with missing lines Patch % Lines
overlord/devicestate/devicestate.go 78.81% 16 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #14933   +/-   ##
=========================================
  Coverage          ?   78.22%           
=========================================
  Files             ?     1163           
  Lines             ?   154159           
  Branches          ?        0           
=========================================
  Hits              ?   120597           
  Misses            ?    26132           
  Partials          ?     7430           
Flag Coverage Δ
unittests 78.22% <78.99%> (?)

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.

snapsupTask = t
break
}
t := ts.MaybeEdge(snapstate.SnapSetupEdge)
Copy link
Member Author

Choose a reason for hiding this comment

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

@pedronis here is where the new edge is used

@andrewphelpsj andrewphelpsj force-pushed the remodel-components-from-store branch from f291bf0 to 8acd511 Compare January 23, 2025 22:02
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.

sorry, only couple of trivials first

Comment on lines 1 to 8
summary: create a recovery system with a kernel module component and reboot into it

details: |
This test creates a recovery system with a kernel module component and
validates that the newly created system can be rebooted into.
Copy link
Collaborator

Choose a reason for hiding this comment

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

summary and description sound off as they don't mention remodel?

return nil, nil, err
}

if !snapsup.ComponentExclusiveSetup {
Copy link
Collaborator

Choose a reason for hiding this comment

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

hasn't this been renamed?

@andrewphelpsj andrewphelpsj force-pushed the remodel-components-from-store branch from 8acd511 to 0dd1396 Compare January 27, 2025 16:56
@pedronis pedronis self-requested a review January 27, 2025 17:00
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.

did a pass

default:
// nothing to do but add the snap to the prereq tracker
r.tracker.Add(currentInfo)
return remodelNoAction, nil, nil
}
}

func (r *remodeler) shouldJustSwitch(rt remodelSnapTarget, needsRevisionChange bool) bool {
func (r *remodeler) shouldSwitchWithoutRefresh(rt remodelSnapTarget, needsRevisionChange bool, needsComponentChanges bool) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not entirely sure if passing needsComponentChanges is more readable than checking it outside of the helper

requiredComponents = append(requiredComponents, c)
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe the two loops to compute needsComponentChanges and update requiredCompontents should be a helper?

Copy link
Member Author

Choose a reason for hiding this comment

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

Pushed 9c30418. Name of function might need some work.

@@ -563,7 +616,18 @@ func (r *remodeler) maybeInstallOrUpdate(ctx context.Context, st *state.State, r
return remodelChannelSwitch, []*state.TaskSet{ts}, nil
}

goal, err := r.updateGoal(st, rt, constraints)
// right now, we don't properly handle switching a channel and
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we have a test for that combo though?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added one in 909780f.

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.

thank you

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.

Thanks, some minor things

tests/nested/manual/remodel-with-components/task.yaml Outdated Show resolved Hide resolved
exit
fi

snap install test-snapd-swtpm --edge

Choose a reason for hiding this comment

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

Isn't this installed by nested_start_core_vm_unit()?

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 is, but it won't work there since we've already set up the fake store at that point. I'll add a comment.

tests/nested/manual/remodel-with-components/task.yaml Outdated Show resolved Hide resolved
overlord/devicestate/devicestate.go Outdated Show resolved Hide resolved
@andrewphelpsj andrewphelpsj added the Run nested The PR also runs tests inluded in nested suite label Jan 29, 2025
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 for the changes

@andrewphelpsj andrewphelpsj force-pushed the remodel-components-from-store branch from e158aaf to fddca0c Compare January 30, 2025 13:55
@andrewphelpsj
Copy link
Member Author

Only required failure is google-nested:ubuntu-24.04-64:tests/nested/manual/remodel-min-size, which is a known issue and not related to this change.

@andrewphelpsj andrewphelpsj force-pushed the remodel-components-from-store branch from a7744b5 to 44cc1d2 Compare January 31, 2025 14:46
@alfonsosanchezbeato alfonsosanchezbeato merged commit 4be46eb into canonical:master Feb 4, 2025
64 of 67 checks passed
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.

3 participants