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: raise conflict when requesting system action while seeding #8689

Merged
merged 14 commits into from May 21, 2020

Conversation

bboozzoo
Copy link
Collaborator

Return a conflict error when trying to request system action on a system that is still seeding (or seeding hasn't started yet).

Stacked on top of #8627.

…quested

When we get a request for a system action, verify that the device is seeded or
at least that the seeding change has finished.

We cannot execute the action sooner, because the list of allowed actions for the
current system depends on the mode and the system state. Eg. a fully seeded
system supports 'run'/'recover'/'install' actions for itself, or install for other
system seeds. However, when the seeding fails, one can only execute an 'install'
action for the system.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
…onflicts

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
@bboozzoo bboozzoo added the UC20 label May 18, 2020
@pedronis pedronis self-requested a review May 18, 2020 13:24
}

// not yet fully seeded, hold off requests for the system that is being
// seeded, but allow requests for other systems
Copy link
Collaborator

Choose a reason for hiding this comment

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

this feels a bit complicated, can't we base this on the current system (when defined) and as the system being installed for install

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe I misunderstood something, but the current system is only recorded when seeding is done. Once it's past that point, there's no conflict anymore, regardless of the current system. When it's not started yet, we don't know whether there is a conflict because we don't know which system is being installed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Simplified as per discussion.

Instead of inspecting the seeding change and extracting the seed system
information, look at modeenv and the recovery system stored there.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
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, couple of comments

// not yet fully seeded, hold off requests for the system that is being
// seeded, but allow requests for other systems
if modeEnv.RecoverySystem == systemLabel {
return &snapstate.ChangeConflictError{Message: "cannot request system action, system is seeding"}
Copy link
Collaborator

Choose a reason for hiding this comment

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

we probably want to set ChangeKind: "seed" as other similar cases

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added

return err
}
if modeEnv == nil {
// non UC20 systems do not support actions, no conflict can
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't get here in tests, do we have tests about what RequestSystemAction should do on 16/18 ?

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 added additional checks for non-UC20 and a couple of unit tests.

…here is no mode

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
if systemLabel == "" {
return fmt.Errorf("internal error: system label is unset")
}
if m.systemMode == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

mmh, we don't do this anywhere else, usually we use the grade unset of the model to know if we are on uc16/18. we need to think a bit.

Copy link
Contributor

@stolowski stolowski left a comment

Choose a reason for hiding this comment

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

LGTM, one wondering about error message, perhaps @degville can comment.

if modeEnv.RecoverySystem == systemLabel {
return &snapstate.ChangeConflictError{
ChangeKind: "seed",
Message: "cannot request system action, system is seeding",
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps 'cannot ..., system is being seeded'?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a close one, but I think it's probably fine as is; seeding is more active (which is good) and I think it's a widely enough accepted term.

@pedronis pedronis merged commit 4735986 into snapcore:master May 21, 2020
return nil
}

// inspect the current system which is stored in modeenv, were are
Copy link
Member

Choose a reason for hiding this comment

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

note, typo this should be

	// inspect the current system which is stored in modeenv, note we are

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for spotting this, I've opened #8712

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants