Skip to content

Commit f15fa4b

Browse files
committed
comments, enums, set_..._nexuses
1 parent 690ea16 commit f15fa4b

File tree

5 files changed

+91
-47
lines changed

5 files changed

+91
-47
lines changed

nexus/reconfigurator/planning/src/planner.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7784,11 +7784,12 @@ pub(crate) mod test {
77847784
let new_bp =
77857785
bp_generator.plan_new_blueprint("test_blocked_by_non_nexus");
77867786
// The blueprint should have a report showing what's blocked
7787-
assert!(new_bp.report.nexus_generation_bump.waiting_on.is_some());
77887787
assert!(
77897788
matches!(
7790-
new_bp.report.nexus_generation_bump.waiting_on,
7791-
Some(NexusGenerationBumpWaitingOn::NonNexusZoneUpdate)
7789+
new_bp.report.nexus_generation_bump,
7790+
PlanningNexusGenerationBumpReport::WaitingOn(
7791+
NexusGenerationBumpWaitingOn::NonNexusZoneUpdate
7792+
),
77927793
),
77937794
"Unexpected Nexus Generation report: {:?}",
77947795
new_bp.report.nexus_generation_bump
@@ -7831,10 +7832,10 @@ pub(crate) mod test {
78317832
assert_eq!(summary.total_zones_modified(), 0);
78327833
assert!(
78337834
matches!(
7834-
new_bp.report.nexus_generation_bump.waiting_on,
7835-
Some(
7835+
new_bp.report.nexus_generation_bump,
7836+
PlanningNexusGenerationBumpReport::WaitingOn(
78367837
NexusGenerationBumpWaitingOn::NexusDatabasePropagation
7837-
)
7838+
),
78387839
),
78397840
"Unexpected Nexus Generation report: {:?}",
78407841
new_bp.report.nexus_generation_bump
@@ -7883,8 +7884,10 @@ pub(crate) mod test {
78837884
assert_eq!(summary.total_zones_modified(), 0);
78847885
assert!(
78857886
matches!(
7886-
new_bp.report.nexus_generation_bump.waiting_on,
7887-
Some(NexusGenerationBumpWaitingOn::ZonePropagation)
7887+
new_bp.report.nexus_generation_bump,
7888+
PlanningNexusGenerationBumpReport::WaitingOn(
7889+
NexusGenerationBumpWaitingOn::ZonePropagation
7890+
),
78887891
),
78897892
"Unexpected Nexus Generation report: {:?}",
78907893
new_bp.report.nexus_generation_bump
@@ -7912,10 +7915,10 @@ pub(crate) mod test {
79127915

79137916
assert!(
79147917
matches!(
7915-
new_bp.report.nexus_generation_bump.waiting_on,
7916-
Some(
7918+
new_bp.report.nexus_generation_bump,
7919+
PlanningNexusGenerationBumpReport::WaitingOn(
79177920
NexusGenerationBumpWaitingOn::NexusDatabasePropagation
7918-
)
7921+
),
79197922
),
79207923
"Unexpected Nexus Generation report: {:?}",
79217924
new_bp.report.nexus_generation_bump
@@ -7931,9 +7934,12 @@ pub(crate) mod test {
79317934
let new_bp = bp_generator.plan_new_blueprint("update_generation");
79327935
// Finally, the top-level Nexus generation should get bumped.
79337936
assert!(
7934-
new_bp.report.nexus_generation_bump.waiting_on.is_none(),
7937+
matches!(
7938+
new_bp.report.nexus_generation_bump,
7939+
PlanningNexusGenerationBumpReport::NothingToReport
7940+
),
79357941
"Unexpected nexus generation report: {:?}",
7936-
new_bp.report.nexus_generation_bump.waiting_on
7942+
new_bp.report.nexus_generation_bump
79377943
);
79387944
assert_eq!(new_bp.nexus_generation, new_generation);
79397945
bp_generator.blueprint = new_bp;

nexus/reconfigurator/preparation/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ impl PlanningInputFromDb<'_> {
284284
self.external_dns_version.into(),
285285
self.cockroachdb_settings.clone(),
286286
);
287-
builder.add_active_nexuses(
287+
builder.set_active_nexuses(
288288
self.active_nexus_zones.clone().into_iter().collect(),
289289
);
290-
builder.add_not_yet_nexuses(
290+
builder.set_not_yet_nexuses(
291291
self.not_yet_nexus_zones.clone().into_iter().collect(),
292292
);
293293

nexus/types/src/deployment/planning_input.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ pub struct PlanningInput {
127127

128128
/// IDs of the currently running Nexus zones
129129
///
130-
/// This is used to identify which Nexus is currently executing the planning
131-
/// operation, which is needed for safe shutdown decisions during handoff.
130+
/// This is used to determine which Nexus instances are currently in
131+
/// control, which is needed for safe shutdown decisions during handoff.
132132
active_nexus_zones: BTreeSet<OmicronZoneUuid>,
133133

134134
/// IDs of the about-to-be-running Nexus zones
@@ -1349,14 +1349,14 @@ impl PlanningInputBuilder {
13491349
}
13501350
}
13511351

1352-
pub fn add_active_nexuses(
1352+
pub fn set_active_nexuses(
13531353
&mut self,
13541354
active_nexus_zones: BTreeSet<OmicronZoneUuid>,
13551355
) {
13561356
self.active_nexus_zones = active_nexus_zones;
13571357
}
13581358

1359-
pub fn add_not_yet_nexuses(
1359+
pub fn set_not_yet_nexuses(
13601360
&mut self,
13611361
not_yet_nexus_zones: BTreeSet<OmicronZoneUuid>,
13621362
) {

nexus/types/src/deployment/planning_report.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,49 +1073,52 @@ impl fmt::Display for ZoneUnsafeToShutdown {
10731073
#[derive(
10741074
Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Diffable, JsonSchema,
10751075
)]
1076-
pub struct PlanningNexusGenerationBumpReport {
1077-
/// What are we waiting on to increase the generation number?
1078-
pub waiting_on: Option<NexusGenerationBumpWaitingOn>,
1076+
#[serde(tag = "component", rename_all = "snake_case", content = "value")]
1077+
pub enum PlanningNexusGenerationBumpReport {
1078+
/// We have no reason to bump the Nexus generation number.
1079+
NothingToReport,
10791080

1080-
pub next_generation: Option<Generation>,
1081+
/// We are waiting on some condition before we can bump the
1082+
/// Nexus generation.
1083+
WaitingOn(NexusGenerationBumpWaitingOn),
1084+
1085+
/// We are bumping the Nexus generation number to this value.
1086+
BumpingGeneration(Generation),
10811087
}
10821088

10831089
impl PlanningNexusGenerationBumpReport {
10841090
pub fn new() -> Self {
1085-
Self { waiting_on: None, next_generation: None }
1091+
Self::NothingToReport
10861092
}
10871093

10881094
pub fn is_empty(&self) -> bool {
1089-
self.waiting_on.is_none() && self.next_generation.is_none()
1095+
matches!(self, Self::NothingToReport)
10901096
}
10911097

10921098
pub fn set_waiting_on(&mut self, why: NexusGenerationBumpWaitingOn) {
1093-
self.waiting_on = Some(why);
1099+
*self = Self::WaitingOn(why);
10941100
}
10951101

10961102
pub fn set_next_generation(&mut self, next_generation: Generation) {
1097-
self.next_generation = Some(next_generation);
1103+
*self = Self::BumpingGeneration(next_generation);
10981104
}
10991105
}
11001106

11011107
impl fmt::Display for PlanningNexusGenerationBumpReport {
11021108
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1103-
let PlanningNexusGenerationBumpReport { waiting_on, next_generation } =
1104-
self;
1105-
1106-
match (waiting_on, next_generation) {
1107-
(Some(why), _) => {
1109+
match self {
1110+
Self::WaitingOn(why) => {
11081111
writeln!(
11091112
f,
11101113
"* waiting to update top-level nexus_generation: {}",
11111114
why.as_str()
11121115
)?;
11131116
}
1114-
(None, Some(gen)) => {
1117+
Self::BumpingGeneration(gen) => {
11151118
writeln!(f, "* updating top-level nexus_generation to: {gen}")?;
11161119
}
11171120
// Nothing to report
1118-
(None, None) => (),
1121+
Self::NothingToReport => (),
11191122
}
11201123
Ok(())
11211124
}

openapi/nexus-internal.json

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7020,26 +7020,61 @@
70207020
]
70217021
},
70227022
"PlanningNexusGenerationBumpReport": {
7023-
"type": "object",
7024-
"properties": {
7025-
"next_generation": {
7026-
"nullable": true,
7027-
"allOf": [
7028-
{
7029-
"$ref": "#/components/schemas/Generation"
7023+
"oneOf": [
7024+
{
7025+
"description": "We have no reason to bump the Nexus generation number.",
7026+
"type": "object",
7027+
"properties": {
7028+
"component": {
7029+
"type": "string",
7030+
"enum": [
7031+
"nothing_to_report"
7032+
]
70307033
}
7034+
},
7035+
"required": [
7036+
"component"
70317037
]
70327038
},
7033-
"waiting_on": {
7034-
"nullable": true,
7035-
"description": "What are we waiting on to increase the generation number?",
7036-
"allOf": [
7037-
{
7039+
{
7040+
"description": "We are waiting on some condition before we can bump the Nexus generation.",
7041+
"type": "object",
7042+
"properties": {
7043+
"component": {
7044+
"type": "string",
7045+
"enum": [
7046+
"waiting_on"
7047+
]
7048+
},
7049+
"value": {
70387050
"$ref": "#/components/schemas/NexusGenerationBumpWaitingOn"
70397051
}
7052+
},
7053+
"required": [
7054+
"component",
7055+
"value"
7056+
]
7057+
},
7058+
{
7059+
"description": "We are bumping the Nexus generation number to this value.",
7060+
"type": "object",
7061+
"properties": {
7062+
"component": {
7063+
"type": "string",
7064+
"enum": [
7065+
"bumping_generation"
7066+
]
7067+
},
7068+
"value": {
7069+
"$ref": "#/components/schemas/Generation"
7070+
}
7071+
},
7072+
"required": [
7073+
"component",
7074+
"value"
70407075
]
70417076
}
7042-
}
7077+
]
70437078
},
70447079
"PlanningNoopImageSourceConverted": {
70457080
"description": "How many of the total install-dataset zones and/or host phase 2 slots were noop-converted to use the artifact store on a particular sled.",

0 commit comments

Comments
 (0)