ApiInstanceState: Make a separate state for "rebooting".#118
Merged
Conversation
This was referenced Jun 8, 2021
david-crespo
reviewed
Jun 8, 2021
david-crespo
reviewed
Jun 8, 2021
david-crespo
approved these changes
Jun 8, 2021
Contributor
david-crespo
left a comment
There was a problem hiding this comment.
looks good, solves my problem in #117
bnaecker
approved these changes
Jun 8, 2021
Collaborator
bnaecker
left a comment
There was a problem hiding this comment.
This looks great, thanks for handling that. It's interesting -- the data-carrying enum variant is more idiomatic Rust, but this "flattened" version is simpler for both the generated client and the database itself. Maybe it's just the mismatch between the Propolis and sled-agent state machines manifested. But looks great!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the second in a series of "lessons learned" regarding the ApiInstanceState's treatment of rebooting.
Some History
Originally, the structure appeared as follows:
In #88 , it was identified that the "reboot_in_progress" value, although present for all states, only actually had relevance for the "stopping" and "stopped" states. The structure was updated to include the following enum variants, removing the need for the
reboot_in_progressbool:The Problem Currently Being Faced
As identified by #117 , this ergonomic-in-rust pattern has some complications for other languages - namely TypeScript, which generates fairly non-intuitive bindings (and, as discussed, still risks some confusion for developers even if the "right" bindings were generated). TL;DR, the use of heterogeneous Rust enum variants is probably too painful for dynamic languages to handle gracefully.
Additionally, while integrating Propolis and Omicron, an impedance mismatch was identified:
This distinction permits some wiggle-room in distinguishing the "stopping / stopped / rebooting" states:
Proposal
This PR proposes the following modification to
ApiInstanceState, based on the distinction between the three states:This change aligns Omicron more closely with the actual interface provided by Propolis, and also simplifies the handling of API states by end-users (and dynamic languages).
Notes