From 90cc17b89d72d3109ffd1f327baabe6406545aa5 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Mon, 22 May 2023 15:14:19 -0400 Subject: [PATCH] Bump to latest gateway-messages Adds `UpdateStatus::RotError` for failed RoT updates --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- gateway-cli/src/main.rs | 8 +++++++ gateway/src/http_entrypoints.rs | 2 ++ gateway/src/http_entrypoints/conversions.rs | 20 ++++++----------- openapi/gateway.json | 24 +++++++++++++++++++++ sp-sim/src/gimlet.rs | 6 +++--- sp-sim/src/sidecar.rs | 6 +++--- wicketd/src/update_tracker.rs | 4 ++++ 9 files changed, 55 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 98a89dd0bd0..ed284f03b1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2610,7 +2610,7 @@ dependencies = [ [[package]] name = "gateway-messages" version = "0.1.0" -source = "git+https://github.com/oxidecomputer/management-gateway-service?rev=1b3d1a4a074fb8ec2df67a906d41bfa636c261a8#1b3d1a4a074fb8ec2df67a906d41bfa636c261a8" +source = "git+https://github.com/oxidecomputer/management-gateway-service?rev=da51768e10dbe260cc6302bcfd2ac379e275a313#da51768e10dbe260cc6302bcfd2ac379e275a313" dependencies = [ "bitflags", "hubpack 0.1.2", @@ -2625,7 +2625,7 @@ dependencies = [ [[package]] name = "gateway-sp-comms" version = "0.1.1" -source = "git+https://github.com/oxidecomputer/management-gateway-service?rev=1b3d1a4a074fb8ec2df67a906d41bfa636c261a8#1b3d1a4a074fb8ec2df67a906d41bfa636c261a8" +source = "git+https://github.com/oxidecomputer/management-gateway-service?rev=da51768e10dbe260cc6302bcfd2ac379e275a313#da51768e10dbe260cc6302bcfd2ac379e275a313" dependencies = [ "async-trait", "backoff", diff --git a/Cargo.toml b/Cargo.toml index 9bb0f6effc6..db00403161d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -167,8 +167,8 @@ flate2 = "1.0.26" fs-err = "2.9.0" futures = "0.3.28" gateway-client = { path = "gateway-client" } -gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", default-features = false, features = ["std"], rev = "1b3d1a4a074fb8ec2df67a906d41bfa636c261a8" } -gateway-sp-comms = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "1b3d1a4a074fb8ec2df67a906d41bfa636c261a8" } +gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", default-features = false, features = ["std"], rev = "da51768e10dbe260cc6302bcfd2ac379e275a313" } +gateway-sp-comms = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "da51768e10dbe260cc6302bcfd2ac379e275a313" } gateway-test-utils = { path = "gateway-test-utils" } headers = "0.3.8" heck = "0.4" diff --git a/gateway-cli/src/main.rs b/gateway-cli/src/main.rs index d9a2cbfbb2d..7bc1110e1e6 100644 --- a/gateway-cli/src/main.rs +++ b/gateway-cli/src/main.rs @@ -665,6 +665,14 @@ async fn update( } bail!("update failed (code {code})"); } + SpUpdateStatus::RotError { id, message } => { + if id != update_id { + bail!( + "different update failed ({id:?}, rot error {message})" + ); + } + bail!("update failed (rot error {message})"); + } } tokio::time::sleep(Duration::from_secs(1)).await; } diff --git a/gateway/src/http_entrypoints.rs b/gateway/src/http_entrypoints.rs index 58d35daff09..ba972d9107d 100644 --- a/gateway/src/http_entrypoints.rs +++ b/gateway/src/http_entrypoints.rs @@ -220,6 +220,8 @@ enum SpUpdateStatus { Aborted { id: Uuid }, /// The update process failed. Failed { id: Uuid, code: u32 }, + /// The update process failed with an RoT-specific error. + RotError { id: Uuid, message: String }, } /// Progress of an SP preparing to update. diff --git a/gateway/src/http_entrypoints/conversions.rs b/gateway/src/http_entrypoints/conversions.rs index 8d5b949fc0f..6a3fe65ed82 100644 --- a/gateway/src/http_entrypoints/conversions.rs +++ b/gateway/src/http_entrypoints/conversions.rs @@ -65,6 +65,9 @@ impl From for SpUpdateStatus { UpdateStatus::Failed { id, code } => { Self::Failed { id: id.into(), code } } + UpdateStatus::RotError { id, error } => { + Self::RotError { id: id.into(), message: format!("{error:?}") } + } } } } @@ -206,20 +209,11 @@ impl From> } } -impl From for RotSlot { - fn from(slot: gateway_messages::RotSlot) -> Self { - match slot { - gateway_messages::RotSlot::A => Self::A, - gateway_messages::RotSlot::B => Self::B, - } - } -} - -impl From for RotSlot { - fn from(slot: gateway_messages::SlotId) -> Self { +impl From for RotSlot { + fn from(slot: gateway_messages::RotSlotId) -> Self { match slot { - gateway_messages::SlotId::A => Self::A, - gateway_messages::SlotId::B => Self::B, + gateway_messages::RotSlotId::A => Self::A, + gateway_messages::RotSlotId::B => Self::B, } } } diff --git a/openapi/gateway.json b/openapi/gateway.json index 95fae19702f..2ce0d5ba092 100644 --- a/openapi/gateway.json +++ b/openapi/gateway.json @@ -2808,6 +2808,30 @@ "id", "state" ] + }, + { + "description": "The update process failed with an RoT-specific error.", + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "message": { + "type": "string" + }, + "state": { + "type": "string", + "enum": [ + "rot_error" + ] + } + }, + "required": [ + "id", + "message", + "state" + ] } ] }, diff --git a/sp-sim/src/gimlet.rs b/sp-sim/src/gimlet.rs index 88fa71554d7..eab776e6207 100644 --- a/sp-sim/src/gimlet.rs +++ b/sp-sim/src/gimlet.rs @@ -18,7 +18,7 @@ use gateway_messages::sp_impl::SpHandler; use gateway_messages::sp_impl::{BoundsChecked, DeviceDescription}; use gateway_messages::ComponentAction; use gateway_messages::Header; -use gateway_messages::SlotId; +use gateway_messages::RotSlotId; use gateway_messages::SpComponent; use gateway_messages::SpError; use gateway_messages::SpPort; @@ -547,8 +547,8 @@ impl Handler { base_mac_address: [0; 6], power_state: self.power_state, rot: Ok(gateway_messages::RotStateV2 { - active: SlotId::A, - persistent_boot_preference: SlotId::A, + active: RotSlotId::A, + persistent_boot_preference: RotSlotId::A, pending_persistent_boot_preference: None, transient_boot_preference: None, slot_a_sha3_256_digest: None, diff --git a/sp-sim/src/sidecar.rs b/sp-sim/src/sidecar.rs index 6034455717f..cedf39f7c59 100644 --- a/sp-sim/src/sidecar.rs +++ b/sp-sim/src/sidecar.rs @@ -28,7 +28,7 @@ use gateway_messages::IgnitionCommand; use gateway_messages::IgnitionState; use gateway_messages::MgsError; use gateway_messages::PowerState; -use gateway_messages::SlotId; +use gateway_messages::RotSlotId; use gateway_messages::SpComponent; use gateway_messages::SpError; use gateway_messages::SpPort; @@ -344,8 +344,8 @@ impl Handler { base_mac_address: [0; 6], power_state: self.power_state, rot: Ok(gateway_messages::RotStateV2 { - active: SlotId::A, - persistent_boot_preference: SlotId::A, + active: RotSlotId::A, + persistent_boot_preference: RotSlotId::A, pending_persistent_boot_preference: None, transient_boot_preference: None, slot_a_sha3_256_digest: None, diff --git a/wicketd/src/update_tracker.rs b/wicketd/src/update_tracker.rs index 4df2cfbc706..728936044e3 100644 --- a/wicketd/src/update_tracker.rs +++ b/wicketd/src/update_tracker.rs @@ -1394,6 +1394,10 @@ impl UpdateContext { ensure!(id == update_id, "SP processing different update"); bail!("update failed (error code {code})"); } + SpUpdateStatus::RotError { message, id } => { + ensure!(id == update_id, "SP processing different update"); + bail!("update failed (rot error message {message})"); + } } tokio::time::sleep(STATUS_POLL_FREQ).await;