-
Notifications
You must be signed in to change notification settings - Fork 40
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
[wicketd] allow starting multiple updates with one API call #4039
[wicketd] allow starting multiple updates with one API call #4039
Conversation
Created using spr 1.3.4
Created using spr 1.3.4
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.
LGTM! 👍
wicketd/src/http_entrypoints.rs
Outdated
|
||
// Can we update the target SP? We refuse to update if: | ||
// Can we update the target SPs? We refuse to update if: |
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.
Tiny nit since the list refers to single SPs:
// Can we update the target SPs? We refuse to update if: | |
// Can we update the target SPs? We refuse to update if for any target SP: |
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.
Done, thanks!
wicketd/src/update_tracker.rs
Outdated
return Err(errors); | ||
} | ||
|
||
let plan = plan.expect("we'd have returned an error if plan was None"); |
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.
Tiny nit - could we move the let plan = ...; if plan.is_none()
check from farther above to just before the if !errors.is_empty()
check, just so it's easier to visually jump from this expect()
to the place where we can see it's correct?
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.
Also done, and added a comment to be clear about it.
Created using spr 1.3.4
Extend
post_start_update
to allow starting updates on several sleds atonce. This is not currently used (the TUI always updates one sled at a
time), but will be used for command-line driven mupdates.
If we're issuing updates on several sleds at once, we can encounter
different kinds of errors for each sled. So instead of returning
immediately, we collect errors into a vector and then return them all at
once.
This also required some refactoring in
update_tracker.rs
. To take careof all possible situations:
SpawnUpdateDriver
trait, which has two methods: oneto perform a one-time setup, and one to perform a spawn operation for
each SP.
SpawnUpdateDriver
:RealUpdateDriver
which is the actual implementation,FakeUpdateDriver
which is used for tests, andNeverUpdateDriver
which is an uninhabited type (empty enum, can never be constructed)
and is used to perform pre-update checks but not the update itself.
Happy to hear suggestions about how to make this better.
One path I went down but rejected is using a typestate to indicate that
update checks had passed -- then the caller could decide whether to
perform the update or not. The problem is that for the typestate to be
valid it would have to hold on to the
MutexGuard
(otherwise somethingcould come in between and replace the task that we thought was
finished), and that seems a bit fraught as you could accidentally
attempt to lock the update data again. A callback-like approach, which
was the previous implementation and which has been retained in this PR,
does not have that pitfall.
I tested this by spinning up sp-sim, mgs, and wicketd, and it worked
as expected. Errors (e.g. no inventory present) were caught as
expected.