-
Notifications
You must be signed in to change notification settings - Fork 54
Sled agent views/params shuffling #386
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
Changes from all commits
4b4e932
858281e
0914192
818041b
665a9eb
02e0afe
ff05c28
daa3aa7
9785211
87e3e77
469d6c6
4137a61
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
//! Internally facing APIs. | ||
|
||
pub mod bootstrap_agent; | ||
pub mod nexus; | ||
pub mod sled_agent; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ pub mod agent; | |
mod client; | ||
pub mod config; | ||
mod http_entrypoints; | ||
mod params; | ||
pub mod server; | ||
mod views; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//! Request body types for the bootstrap agent | ||
|
||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Identity signed by local RoT and Oxide certificate chain. | ||
#[derive(Serialize, Deserialize, JsonSchema)] | ||
pub struct ShareRequest { | ||
// TODO-completeness: format TBD; currently opaque. | ||
pub identity: Vec<u8>, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,8 @@ | ||
//! APIs exposed by the bootstrap agent | ||
//! Response types for the bootstrap agent | ||
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. Why pull apart inputs and outputs? 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. Related: I asked this on chat, but I'll ask it more publicly - Are "views" supposed to be 1:1 with response types, or with DB representations? I'm especially curious about responses that do not represent data stored in a DB - does that still make sense to store in "view.rs"? If so, would it be more accurate to call these "requests.rs" and "responses.rs"? And in that case, I think Adam's question still applies - why split 'em? 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. You're right to point out the disparity — I'll update #374 to say they're response bodies, most of which are lenses onto DB models. I'm really just following a convention set by the big fullstack frameworks in various languages — Rails, Django, Phoenix, Laravel — which all call response bodies "views", though usually those are HTML responses. In Rails they call the JSON serializers "serializers". I guess they call them serializers in Django too. They distinguish views and serializers from controllers (route handlers) and models. They're not as consistent about what they call request bodies, probably because in the dynamic languages the request bodies don't have to be defined anywhere outside of the request handler.
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'm going to merge as-is because we can rearrange easily later. The hard part, as you'll see, is moving things out of common. Moving things around within sled-agent or within nexus is easy. |
||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Identity signed by local RoT and Oxide certificate chain. | ||
#[derive(Serialize, Deserialize, JsonSchema)] | ||
pub struct ShareRequest { | ||
// TODO-completeness: format TBD; currently opaque. | ||
pub identity: Vec<u8>, | ||
} | ||
|
||
/// Sent between bootstrap agents to establish trust quorum. | ||
#[derive(Serialize, Deserialize, JsonSchema)] | ||
pub struct ShareResponse { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use omicron_common::api::internal::nexus::DiskRuntimeState; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
use uuid::Uuid; | ||
|
||
///Used to request a Disk state change | ||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, JsonSchema)] | ||
#[serde(rename_all = "lowercase", tag = "state", content = "instance")] | ||
pub enum DiskStateRequested { | ||
Detached, | ||
Attached(Uuid), | ||
Destroyed, | ||
Faulted, | ||
} | ||
|
||
impl DiskStateRequested { | ||
/// Returns whether the requested state is attached to an Instance or not. | ||
pub fn is_attached(&self) -> bool { | ||
match self { | ||
DiskStateRequested::Detached => false, | ||
DiskStateRequested::Destroyed => false, | ||
DiskStateRequested::Faulted => false, | ||
|
||
DiskStateRequested::Attached(_) => true, | ||
} | ||
} | ||
} | ||
|
||
/// Sent from to a sled agent to establish the runtime state of a Disk | ||
#[derive(Serialize, Deserialize, JsonSchema)] | ||
pub struct DiskEnsureBody { | ||
/// Last runtime state of the Disk known to Nexus (used if the agent has | ||
/// never seen this Disk before). | ||
pub initial_runtime: DiskRuntimeState, | ||
/// requested runtime state of the Disk | ||
pub target: DiskStateRequested, | ||
} |
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.
@ahl because nexus refers to the generated type all the time, there is no more conversion
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.
awesome