-
Notifications
You must be signed in to change notification settings - Fork 62
Add cosmo ignition support #9076
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
Conversation
f0808c1 to
41cf877
Compare
karencfv
left a comment
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.
Looks good! Just a few nits from my part. I'm not 100% sure on the API versioning format though since this is all new. Could be good to get a review from @iliana here :)
gateway-types/src/ignition/v2.rs
Outdated
| pub details: SpIgnition, | ||
| } | ||
|
|
||
| /// Ignition command. |
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.
Maybe a little more information for this one? 😄
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.
Hah you are finding all the places that were not as well documented
gateway-types/src/ignition/v2.rs
Outdated
|
|
||
| /// State of an ignition target. | ||
| /// | ||
| /// TODO: Ignition returns much more information than we're reporting here: do |
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.
What could this additional information be used for?
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.
Mostly debugging purposes I think? This is also a pretty old comment at this point.
| ctrl_detect_0: bool, | ||
| ctrl_detect_1: bool, | ||
| flt_a3: bool, | ||
| flt_a2: bool, | ||
| flt_rot: bool, | ||
| flt_sp: bool, |
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.
Not sure if this makes sense or not, please ignore this comment if it doesn't. It could be nice to have the fields be more descriptive. For those of us without a background in firmware eng they aren't super obvious. How about something like faults_power_a3, controller_detect_0 etc?
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.
Changing field names is pretty intrusive, I'll see about adding some more comments
| let handler = async { | ||
| let out = mgmt_switch | ||
| .bulk_ignition_state() | ||
| .await? | ||
| .map(|(id, state)| ignition::v2::SpIgnitionInfo { | ||
| id: id.into(), | ||
| details: state.into(), | ||
| }) | ||
| .collect(); | ||
|
|
||
| Ok(HttpResponseOk(out)) | ||
| }; |
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.
I'm assuming that we'll never have enough items to warrant pagination here?
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.
Interesting question! At least in MGS it does look to possibly allow it https://github.com/oxidecomputer/management-gateway-service/blob/91c9d622027c39f5acdd17ae3dab046330bf6717/gateway-messages/src/sp_impl.rs#L765-L776 but I'm guessing the amount of data returned right now is small enough we just haven't bothered
41cf877 to
8d141c2
Compare
karencfv
left a comment
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 addressing my comments! Looks like it's just missing a cargo xtask openapi generate.
If possible, it'd be good to get a review from someone more acquainted with the new API versioning system
gateway-api/src/lib.rs
Outdated
| }] | ||
| async fn ignition_command_v2( | ||
| rqctx: RequestContext<Self::Context>, | ||
| path: Path<ignition::v2::PathSpIgnitionCommand>, |
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.
Why do we need a v2::PathSpIgnitionCommand? I tried comparing v1 and v2, but I couldn't tell what the difference was.
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.
Double checked this, PathSpIgnitionCommand uses IgnitionCommand which is part of the versioned ignition types. Versioning PathSpIgnitionCommand seemed like the least ugly path forward
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.
John explained this to me a little bit more, I'm going to make this not be versioned
gateway-api/src/lib.rs
Outdated
| #[endpoint { | ||
| method = GET, | ||
| path = "/ignition", | ||
| operation_id = "ignition_list", | ||
| versions = VERSION_COSMO.. | ||
| }] | ||
| async fn ignition_list_v2( | ||
| rqctx: RequestContext<Self::Context>, | ||
| ) -> Result<HttpResponseOk<Vec<ignition::v2::SpIgnitionInfo>>, HttpError>; |
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.
This is a pretty different stylistic choice than @iliana made when revving an API for sled agent on #8983. I think I prefer that style, but maybe it's worth discussing? In that change, the new endpoint and its associated types don't have any versioning in the name or types, which makes it clear (IMO) that they're "the current version". So this would be
| #[endpoint { | |
| method = GET, | |
| path = "/ignition", | |
| operation_id = "ignition_list", | |
| versions = VERSION_COSMO.. | |
| }] | |
| async fn ignition_list_v2( | |
| rqctx: RequestContext<Self::Context>, | |
| ) -> Result<HttpResponseOk<Vec<ignition::v2::SpIgnitionInfo>>, HttpError>; | |
| #[endpoint { | |
| method = GET, | |
| path = "/ignition", | |
| versions = VERSION_COSMO.. | |
| }] | |
| async fn ignition_list( | |
| rqctx: RequestContext<Self::Context>, | |
| ) -> Result<HttpResponseOk<Vec<SpIgnitionInfo>>, HttpError>; |
and only the old version would have v1 in its name and return type.
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.
I'm fine making the style change, I was initially matching http://github.com/oxidecomputer/omicron/pull/8047 which was my initial reference for doing API versioning
518df6f to
c3b734e
Compare
gateway/src/http_entrypoints.rs
Outdated
| err, | ||
| })?; | ||
|
|
||
| let info = ignition::v1::SpIgnitionInfo { |
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.
I think this impl (and the ignition_list_v1) are fine as-is, but I'm wondering if they could be written in terms of the v2 API? Something like
async fn ignition_get_v1(
rqctx: RequestContext<Self::Context>,
path: Path<PathSp>,
) -> Result<HttpResponseOk<ignition::v1::SpIgnitionInfo>, HttpError> {
let HttpResponseOk(v2_info) = Self::ignition_get(rqctx, path)?;
Ok(HttpResponseOk(ignition::v1::SpIgnitionInfo::from(v2_info)))
}to avoid having to duplicate the guts of talking to the ignition controller, mapping errors, etc.
| # | ||
| gateway-ereport-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "77e316c812aa057b9714d0d99c4a7bdd36d45be2", default-features = false, features = ["debug-impls"] } | ||
| gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "77e316c812aa057b9714d0d99c4a7bdd36d45be2", default-features = false, features = ["std"] } | ||
| gateway-sp-comms = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "77e316c812aa057b9714d0d99c4a7bdd36d45be2" } |
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.
We should also bump this hash in package-manifest.toml where pull in package.omicron-faux-mgs. (Always shipping an up-to-date faux-mgs is not critical, but it's nice to have.)
f84af39 to
68e9f03
Compare
No description provided.