-
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
refine error messages about not having a propolis address #7263
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1610,11 +1610,19 @@ impl super::Nexus { | |
if let Some(max_bytes) = params.max_bytes { | ||
request = request.max_bytes(max_bytes); | ||
} | ||
if let Some(from_start) = params.from_start { | ||
request = request.from_start(from_start); | ||
} | ||
if let Some(most_recent) = params.most_recent { | ||
request = request.most_recent(most_recent); | ||
match (params.from_start, params.most_recent) { | ||
(Some(from_start), None) => { | ||
request = request.from_start(from_start); | ||
} | ||
(None, Some(most_recent)) => { | ||
request = request.most_recent(most_recent); | ||
} | ||
_ => { | ||
return Err(Error::invalid_request( | ||
"Exactly one of 'from_start' \ | ||
or 'most_recent' must be specified.", | ||
)); | ||
} | ||
} | ||
let data = request | ||
.send() | ||
|
@@ -1714,29 +1722,30 @@ impl super::Nexus { | |
match vmm.runtime.state { | ||
DbVmmState::Running | ||
| DbVmmState::Rebooting | ||
| DbVmmState::Migrating => { | ||
Ok((vmm.clone(), SocketAddr::new(vmm.propolis_ip.ip(), vmm.propolis_port.into()))) | ||
} | ||
| DbVmmState::Migrating => Ok(( | ||
vmm.clone(), | ||
SocketAddr::new( | ||
vmm.propolis_ip.ip(), | ||
vmm.propolis_port.into(), | ||
), | ||
)), | ||
|
||
DbVmmState::Starting | ||
| DbVmmState::Stopping | ||
| DbVmmState::Stopped | ||
| DbVmmState::Failed | ||
| DbVmmState::Creating => { | ||
| DbVmmState::Creating | ||
| DbVmmState::Destroyed | ||
| DbVmmState::SagaUnwound => { | ||
Err(Error::invalid_request(format!( | ||
"cannot connect to serial console of instance in state \"{}\"", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i tried to make this a stronger error type than so after spinning a little too long on error plumbing here, i decided to take the different approach of picking the lowest common denominator message that makes sense for any caller of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I think just making it generic is fine. 's fair. a slightly different wording is something like "this operation cannot be performed on instances in state ...", which is also generic but suggests that the specific thing you tried to do can't be done in that state. I worry a little that "administer an instance" is broad enough that it does include operations you can perform in these states --- i.e., is deleting an instance "administering" it? |
||
"cannot administer instance in state \"{}\"", | ||
state.effective_state(), | ||
))) | ||
} | ||
|
||
DbVmmState::Destroyed | DbVmmState::SagaUnwound => Err(Error::invalid_request( | ||
"cannot connect to serial console of instance in state \"Stopped\"", | ||
)), | ||
} | ||
} else { | ||
Err(Error::invalid_request(format!( | ||
"instance is {} and has no active serial console \ | ||
server", | ||
"instance is {} and cannot be administered", | ||
state.effective_state(), | ||
))) | ||
} | ||
|
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.
don't super love this, and maybe @hawkw's new dropshot error type stuff can help? this reproduces a check that's done in both Propolis and propolis-sim. when they see invalid parameters, they respond with a 400 whose message is the same as here. my thinking is, the connection to Propolis could error for other reasons, and for any other reason it would be correctly categorized as a 500. and i didn't want to just forward any 400 error from Propolis out to users here because Propolis errors aren't necessarily intended for direct end-user consumption...
if parameter validation gets more strict on the Propolis side, though, things checked there and not here will be 500s..
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.
Yeah, hm. I think once #7196 we could have Propolis return a structured error here. But, since we are constructing the request in Nexus, I think it's reasonable-ish to say that any invalid request sent to Propolis is arguably an "internal server error" and we should be validating it here beforehand. On the other hand, duplicating the validation also feels bad. I dunno...