-
Notifications
You must be signed in to change notification settings - Fork 574
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/registrystate: add registry hook handlers #14483
base: master
Are you sure you want to change the base?
Conversation
Adds a change-view hook handler that checks whether the snap has rejected the changes and outputs that nicely.
Signed-off-by: Miguel Pires <[email protected]>
Signed-off-by: Miguel Pires <[email protected]>
c7b6c45
to
4086599
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Some comments, but looks good
Signed-off-by: Miguel Pires <[email protected]>
Signed-off-by: Miguel Pires <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes!
Signed-off-by: Miguel Pires <[email protected]>
Signed-off-by: Miguel Pires <[email protected]>
Signed-off-by: Miguel Pires <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, did a pass, some questions and comments
func (h *snapHookHandler) Before() error { | ||
return nil | ||
} | ||
type SnapHookHandler struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to export this now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The -view-changed hooks can use it. I could duplicate it but it this seemed reasonable
Signed-off-by: Miguel Pires <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you
err = s.o.Settle(5 * time.Second) | ||
c.Assert(err, IsNil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this bit do something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just runs the manager's Ensure which is a no-op
// prevent the next registry tasks from running before the rollbacks. Once the | ||
// last rollback task errors, these will be put on Hold by the usual mechanism | ||
for _, halt := range t.HaltTasks() { | ||
halt.WaitFor(last) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the run hooks will also end up with HoldStatus ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the last rollback task surfaces the error, the tasks after it will be held I believe
Adds registry hook handlers. The change-view- hook handler checks the transaction to see if the snap has rejected the changes (this will be done with a
snapctl fail <reason>
command) and outputs that information nicely if so. The save-view- hook handler attempts to roll back previous save-view hooks that have already run if the hook failed. It saves the error, schedules rollback tasks and then outputs the error once those are done. The -view-changed doesn't have any code to it.