Skip to content

Commit 893e85d

Browse files
committed
Report power state transitions to MGS
Basically, this commit glues together the changes from #2064 and oxidecomputer/management-gateway-service#390. The `SpHandler::set_power_state` implementation for compute sleds in the `control-plane-agent` task now report the outcome of power state transitions using the new `gateway_messages::PowerStateTransition` type added in oxidecomputer/management-gateway-service#390. This fixes oxidecomputer/management-gateway-service#270, and closes oxidecomputer/management-gateway-service#271. We'll need to update MGS proper (in the Omicron repo) to pick up the new `gateway-messages` changes, as well.
1 parent e99fff9 commit 893e85d

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

task/control-plane-agent/src/mgs_compute_sled.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ use gateway_messages::{
1818
ignition, ComponentAction, ComponentActionResponse, ComponentDetails,
1919
ComponentUpdatePrepare, DiscoverResponse, DumpSegment, DumpTask, Header,
2020
IgnitionCommand, IgnitionState, Message, MessageKind, MgsError, MgsRequest,
21-
MgsResponse, PowerState, RotBootInfo, RotRequest, RotResponse,
22-
SensorRequest, SensorResponse, SpComponent, SpError, SpPort as GwSpPort,
23-
SpRequest, SpStateV2, SpUpdatePrepare, UpdateChunk, UpdateId, UpdateStatus,
24-
SERIAL_CONSOLE_IDLE_TIMEOUT,
21+
MgsResponse, PowerState, PowerStateTransition, RotBootInfo, RotRequest,
22+
RotResponse, SensorRequest, SensorResponse, SpComponent, SpError,
23+
SpPort as GwSpPort, SpRequest, SpStateV2, SpUpdatePrepare, UpdateChunk,
24+
UpdateId, UpdateStatus, SERIAL_CONSOLE_IDLE_TIMEOUT,
2525
};
2626
use heapless::{Deque, Vec};
2727
use host_sp_messages::HostStartupOptions;
@@ -707,8 +707,10 @@ impl SpHandler for MgsHandler {
707707
&mut self,
708708
sender: Sender<VLanId>,
709709
power_state: PowerState,
710-
) -> Result<(), SpError> {
710+
) -> Result<PowerStateTransition, SpError> {
711711
use drv_cpu_seq_api::PowerState as DrvPowerState;
712+
use drv_cpu_seq_api::Transition;
713+
712714
ringbuf_entry_root!(
713715
CRITICAL,
714716
CriticalEvent::SetPowerState {
@@ -727,16 +729,18 @@ impl SpHandler for MgsHandler {
727729
PowerState::A2 => DrvPowerState::A2,
728730
};
729731

730-
self.sequencer
732+
let transition = self
733+
.sequencer
731734
.set_state_with_reason(
732735
power_state,
733736
drv_cpu_seq_api::StateChangeReason::ControlPlane,
734737
)
735738
.map_err(|e| SpError::PowerStateError(e as u32))?;
736-
// TODO(eliza): we should eventually indicate to upstack software
737-
// whether a power state change occurred or not (requires another
738-
// message type in gateway-messages...)
739-
Ok(())
739+
740+
Ok(match transition {
741+
Transition::Changed => PowerStateTransition::Changed,
742+
Transition::Unchanged => PowerStateTransition::Unchanged,
743+
})
740744
}
741745

742746
fn serial_console_attach(

task/control-plane-agent/src/mgs_psc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use gateway_messages::{
1414
ignition, ComponentAction, ComponentActionResponse, ComponentDetails,
1515
ComponentUpdatePrepare, DiscoverResponse, DumpSegment, DumpTask,
1616
IgnitionCommand, IgnitionState, MgsError, MgsRequest, MgsResponse,
17-
PowerState, RotBootInfo, RotRequest, RotResponse, SensorRequest,
18-
SensorResponse, SpComponent, SpError, SpStateV2, SpUpdatePrepare,
19-
UpdateChunk, UpdateId, UpdateStatus,
17+
PowerState, PowerStateTransition, RotBootInfo, RotRequest, RotResponse,
18+
SensorRequest, SensorResponse, SpComponent, SpError, SpStateV2,
19+
SpUpdatePrepare, UpdateChunk, UpdateId, UpdateStatus,
2020
};
2121
use host_sp_messages::HostStartupOptions;
2222
use idol_runtime::{Leased, RequestError};
@@ -359,7 +359,7 @@ impl SpHandler for MgsHandler {
359359
&mut self,
360360
sender: Sender<VLanId>,
361361
power_state: PowerState,
362-
) -> Result<(), SpError> {
362+
) -> Result<PowerStateTransition, SpError> {
363363
ringbuf_entry_root!(
364364
CRITICAL,
365365
CriticalEvent::SetPowerState {

task/control-plane-agent/src/mgs_sidecar.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ use gateway_messages::{
2020
EcdsaSha2Nistp256Challenge, IgnitionCommand, IgnitionState, MgsError,
2121
MgsRequest, MgsResponse, MonorailComponentAction,
2222
MonorailComponentActionResponse, MonorailError as GwMonorailError,
23-
PowerState, RotBootInfo, RotRequest, RotResponse, SensorRequest,
24-
SensorResponse, SpComponent, SpError, SpStateV2, SpUpdatePrepare,
25-
UnlockChallenge, UnlockResponse, UpdateChunk, UpdateId, UpdateStatus,
23+
PowerState, PowerStateTransition, RotBootInfo, RotRequest, RotResponse,
24+
SensorRequest, SensorResponse, SpComponent, SpError, SpStateV2,
25+
SpUpdatePrepare, UnlockChallenge, UnlockResponse, UpdateChunk, UpdateId,
26+
UpdateStatus,
2627
};
2728
use host_sp_messages::HostStartupOptions;
2829
use idol_runtime::{Leased, RequestError};
@@ -800,7 +801,7 @@ impl SpHandler for MgsHandler {
800801
&mut self,
801802
sender: Sender<VLanId>,
802803
power_state: PowerState,
803-
) -> Result<(), SpError> {
804+
) -> Result<PowerStateTransition, SpError> {
804805
ringbuf_entry_root!(
805806
CRITICAL,
806807
CriticalEvent::SetPowerState {
@@ -832,7 +833,11 @@ impl SpHandler for MgsHandler {
832833

833834
self.sequencer
834835
.set_tofino_seq_policy(policy)
835-
.map_err(|e| SpError::PowerStateError(e as u32))
836+
.map_err(|e| SpError::PowerStateError(e as u32))?;
837+
838+
// TODO(eliza): this should probably also be made idempotent, à la the
839+
// compute sled sequencer...
840+
Ok(PowerStateTransition::Changed)
836841
}
837842

838843
fn serial_console_attach(

0 commit comments

Comments
 (0)