Skip to content
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

Publish instance vCPU usage statistics to oximeter #4855

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 85 additions & 85 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,15 @@ prettyplease = "0.2.16"
proc-macro2 = "1.0"
progenitor = { git = "https://github.com/oxidecomputer/progenitor", branch = "main" }
progenitor-client = { git = "https://github.com/oxidecomputer/progenitor", branch = "main" }
bhyve_api = { git = "https://github.com/oxidecomputer/propolis", rev = "1e25649e8c2ac274bd04adfe0513dd14a482058c" }
propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "1e25649e8c2ac274bd04adfe0513dd14a482058c" }
propolis-mock-server = { git = "https://github.com/oxidecomputer/propolis", rev = "1e25649e8c2ac274bd04adfe0513dd14a482058c" }

# TODO(ben): Put back to main before merge.
#bhyve_api = { git = "https://github.com/oxidecomputer/propolis", rev = "1e25649e8c2ac274bd04adfe0513dd14a482058c" }
#propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "1e25649e8c2ac274bd04adfe0513dd14a482058c" }
#propolis-mock-server = { git = "https://github.com/oxidecomputer/propolis", rev = "1e25649e8c2ac274bd04adfe0513dd14a482058c" }
bhyve_api = { git = "https://github.com/oxidecomputer/propolis", branch = "vcpu-usage-stats" }
propolis-client = { git = "https://github.com/oxidecomputer/propolis", branch = "vcpu-usage-stats" }
propolis-mock-server = { git = "https://github.com/oxidecomputer/propolis", branch = "vcpu-usage-stats" }

proptest = "1.4.0"
quote = "1.0"
rand = "0.8.5"
Expand Down
6 changes: 4 additions & 2 deletions clients/dns-service-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ pub fn is_retryable(error: &DnsConfigError<crate::types::Error>) -> bool {
let response_value = match error {
DnsConfigError::CommunicationError(_) => return true,
DnsConfigError::InvalidRequest(_)
| DnsConfigError::InvalidResponsePayload(_)
| DnsConfigError::UnexpectedResponse(_) => return false,
| DnsConfigError::InvalidResponsePayload(_, _)
| DnsConfigError::UnexpectedResponse(_)
| DnsConfigError::InvalidUpgrade(_)
| DnsConfigError::ResponseBodyError(_) => return false,
DnsConfigError::ErrorResponse(response_value) => response_value,
};

Expand Down
7 changes: 7 additions & 0 deletions common/src/api/external/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ impl<T: ClientError> From<progenitor::progenitor_client::Error<T>> for Error {
// our version constraints (i.e. that the call was to a newer
// service with an incompatible response).
progenitor::progenitor_client::Error::InvalidResponsePayload(
_bytes,
ee,
) => Error::internal_error(&format!(
"InvalidResponsePayload: {}",
Expand All @@ -539,6 +540,12 @@ impl<T: ClientError> From<progenitor::progenitor_client::Error<T>> for Error {
r.status(),
))
}
progenitor::progenitor_client::Error::InvalidUpgrade(e) => {
Error::internal_error(&format!("InvalidUpgrade: {e}",))
}
progenitor::progenitor_client::Error::ResponseBodyError(_) => {
Error::internal_error(&format!("ResponseBodyError: {e}",))
}
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions nexus/src/app/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,21 @@ impl super::Nexus {
.map(|ssh_key| ssh_key.public_key)
.collect::<Vec<String>>();

// Construct instance metadata used to track its statistics.
//
// This current means fetching the current silo ID, since we have all
// the other metadata already.
let silo_id = self
.current_silo_lookup(opctx)?
.lookup_for(authz::Action::Read)
.await?
.0
.id();
let metadata = sled_agent_client::types::InstanceMetadata {
silo_id,
project_id: db_instance.project_id,
};

// Ask the sled agent to begin the state change. Then update the
// database to reflect the new intermediate state. If this update is
// not the newest one, that's fine. That might just mean the sled agent
Expand Down Expand Up @@ -1178,6 +1193,7 @@ impl super::Nexus {
PROPOLIS_PORT,
)
.to_string(),
metadata,
},
)
.await
Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/sagas/switch_port_settings_apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ async fn spa_undo_ensure_switch_port_settings(
let log = sagactx.user_data().log();

let port_id: PortId = PortId::from_str(&params.switch_port_name)
.map_err(|e| external::Error::internal_error(e))?;
.map_err(|e| external::Error::internal_error(e.to_string().as_str()))?;

let orig_port_settings_id = sagactx
.lookup::<Option<Uuid>>("original_switch_port_settings_id")
Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/sagas/switch_port_settings_clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async fn spa_undo_clear_switch_port_settings(
let log = sagactx.user_data().log();

let port_id: PortId = PortId::from_str(&params.port_name)
.map_err(|e| external::Error::internal_error(e))?;
.map_err(|e| external::Error::internal_error(e.to_string().as_str()))?;

let orig_port_settings_id = sagactx
.lookup::<Option<Uuid>>("original_switch_port_settings_id")
Expand Down
27 changes: 27 additions & 0 deletions openapi/sled-agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -4515,6 +4515,14 @@
}
]
},
"metadata": {
"description": "Metadata used to track instance statistics.",
"allOf": [
{
"$ref": "#/components/schemas/InstanceMetadata"
}
]
},
"propolis_addr": {
"description": "The address at which this VMM should serve a Propolis server API.",
"type": "string"
Expand All @@ -4536,6 +4544,7 @@
"required": [
"hardware",
"instance_runtime",
"metadata",
"propolis_addr",
"propolis_id",
"vmm_runtime"
Expand Down Expand Up @@ -4624,6 +4633,24 @@
"snapshot_id"
]
},
"InstanceMetadata": {
"description": "Metadata used to track statistics about an instance.",
"type": "object",
"properties": {
"project_id": {
"type": "string",
"format": "uuid"
},
"silo_id": {
"type": "string",
"format": "uuid"
}
},
"required": [
"project_id",
"silo_id"
]
},
"InstanceMigrationSourceParams": {
"description": "Instance runtime state to update for a migration.",
"type": "object",
Expand Down
5 changes: 3 additions & 2 deletions oximeter/instruments/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ uuid.workspace = true
omicron-workspace-hack.workspace = true

[features]
default = ["http-instruments", "kstat"]
default = ["http-instruments", "datalink", "virtual-machine"]
http-instruments = ["http"]
kstat = ["kstat-rs"]
datalink = ["dep:kstat-rs"]
virtual-machine = ["dep:kstat-rs"]

[dev-dependencies]
rand.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions oximeter/instruments/src/kstat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ use std::cmp::Ordering;
use std::collections::BTreeMap;
use std::time::Duration;

#[cfg(feature = "datalink")]
pub mod link;
mod sampler;
#[cfg(feature = "virtual-machine")]
pub mod virtual_machine;

pub use sampler::CollectionDetails;
pub use sampler::ExpirationBehavior;
Expand Down
Loading
Loading