-
Notifications
You must be signed in to change notification settings - Fork 83
nexus: add failure reasons to Failed VMMs using a VmmState domain type
#10425
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a7c9ded
start adding vmm failure reasons from nexus only
hawkw bb3bf07
start breaking a whole bunch of stuff
hawkw c0a719d
start fixing some of the stuff i broke
hawkw 117999e
put back from_vmm_state
hawkw 458277b
more unbreakening stuff
hawkw fefa831
tests for consistency between nexus types and db types
hawkw 48ffdb3
migration
hawkw c349099
more thing
hawkw 2368b70
you have to SET LOCAL disallow_full_table_scans = off
hawkw 58e21fb
Merge branch 'main' into eliza/failure-reason-2
hawkw b5322ab
rename `NoSuchVmm` to `NoSuchInstance`
hawkw 8028475
ARGH I FORGOT TO SAVE
hawkw dc07899
I FORGOT TO SAVE THIS ONE TOO
hawkw d5f0651
remove <>
hawkw 88d52ec
get rid of `.next().next()`
hawkw 63ede60
Merge branch 'main' into eliza/failure-reason-2
hawkw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| //! Describes why a VMM record is in the `Failed` state. | ||
|
|
||
| use super::impl_enum_type; | ||
| use nexus_types::instance as types; | ||
| use serde::{Deserialize, Serialize}; | ||
| use std::fmt; | ||
|
|
||
| impl_enum_type!( | ||
| VmmFailureReasonEnum: | ||
|
|
||
| #[derive( | ||
| Copy, | ||
| Clone, | ||
| Debug, | ||
| PartialEq, | ||
| AsExpression, | ||
| FromSqlRow, | ||
| Serialize, | ||
| Deserialize, | ||
| )] | ||
| pub enum VmmFailureReason; | ||
|
|
||
| // The reason for this VMM's failure is unknown, because the VMM failed | ||
| // prior to the recording of failure reasons. | ||
| Prehistoric => b"prehistoric" | ||
| // The sled-agent reported that this VMM failed. | ||
| FromSledAgent => b"from_sled_agent" | ||
| // A request to the sled-agent received a response indicating that this | ||
| // VMM is no longer present on the sled. | ||
| NoSuchInstance => b"no_such_instance" | ||
| // The sled on which this VMM was running has been expunged. | ||
| SledExpunged => b"sled_expunged" | ||
| // The sled on which this VMM was running has powered off. | ||
| SledOff => b"sled_off" | ||
| ); | ||
|
|
||
| impl From<types::VmmFailureReason> for VmmFailureReason { | ||
| fn from(reason: types::VmmFailureReason) -> Self { | ||
| match reason { | ||
| types::VmmFailureReason::Prehistoric => Self::Prehistoric, | ||
| types::VmmFailureReason::FromSledAgent => Self::FromSledAgent, | ||
| types::VmmFailureReason::NoSuchInstance => Self::NoSuchInstance, | ||
| types::VmmFailureReason::SledExpunged => Self::SledExpunged, | ||
| types::VmmFailureReason::SledOff => Self::SledOff, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<VmmFailureReason> for types::VmmFailureReason { | ||
| fn from(reason: VmmFailureReason) -> Self { | ||
| match reason { | ||
| VmmFailureReason::Prehistoric => Self::Prehistoric, | ||
| VmmFailureReason::FromSledAgent => Self::FromSledAgent, | ||
| VmmFailureReason::NoSuchInstance => Self::NoSuchInstance, | ||
| VmmFailureReason::SledExpunged => Self::SledExpunged, | ||
| VmmFailureReason::SledOff => Self::SledOff, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl VmmFailureReason { | ||
| pub fn from_vmm_state(state: types::VmmState) -> Option<Self> { | ||
| match state { | ||
| types::VmmState::Failed(reason) => Some(reason.into()), | ||
| _ => None, | ||
| } | ||
| } | ||
|
|
||
| pub fn description(&self) -> &'static str { | ||
| types::VmmFailureReason::from(*self).description() | ||
| } | ||
| } | ||
|
|
||
| impl fmt::Display for VmmFailureReason { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| types::VmmFailureReason::from(*self).fmt(f) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Is this
descriptiongoing to be different from theto_string()impl above (on line 8021)?Uh oh!
There was an error while loading. Please reload this page.
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.
description()provides a human-readable sentence describing what this reason means, while theto_string()impl returns the same string used as the database enum value. I wanted to include both here, so that you can see both the actual value in the DB and a more helpful explanation of what that means.