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

[wicketd] allow starting multiple updates with one API call #4039

Conversation

sunshowers
Copy link
Contributor

@sunshowers sunshowers commented Sep 6, 2023

Extend post_start_update to allow starting updates on several sleds at
once. 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 care
of all possible situations:

  1. Add a new SpawnUpdateDriver trait, which has two methods: one
    to perform a one-time setup, and one to perform a spawn operation for
    each SP.
  2. Add three implementations of SpawnUpdateDriver:
    RealUpdateDriver which is the actual implementation,
    FakeUpdateDriver which is used for tests, and NeverUpdateDriver
    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 something
could 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.

Created using spr 1.3.4
Created using spr 1.3.4
Created using spr 1.3.4
Created using spr 1.3.4
Copy link
Contributor

@jgallagher jgallagher left a comment

Choose a reason for hiding this comment

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

LGTM! 👍


// Can we update the target SP? We refuse to update if:
// Can we update the target SPs? We refuse to update if:
Copy link
Contributor

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:

Suggested change
// 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:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks!

return Err(errors);
}

let plan = plan.expect("we'd have returned an error if plan was None");
Copy link
Contributor

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?

Copy link
Contributor Author

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
@sunshowers sunshowers enabled auto-merge (squash) September 28, 2023 23:42
@sunshowers sunshowers merged commit b03dd6b into main Sep 29, 2023
23 checks passed
@sunshowers sunshowers deleted the sunshowers/spr/wicketd-allow-starting-multiple-updates-with-one-api-call branch September 29, 2023 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants