Skip to content

Commit 2be2c67

Browse files
committed
self-review + regenerate API spec
1 parent e7e246b commit 2be2c67

File tree

5 files changed

+117
-31
lines changed

5 files changed

+117
-31
lines changed

dev-tools/omdb/src/bin/omdb/nexus/quiesce.rs

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,23 @@ async fn quiesce_show(
6161
.context("fetching quiesce state")?
6262
.into_inner();
6363
match quiesce.state {
64+
QuiesceState::Undetermined => {
65+
println!("has not yet determined if it is quiescing");
66+
}
6467
QuiesceState::Running => {
6568
println!("running normally (not quiesced, not quiescing)");
6669
}
67-
QuiesceState::WaitingForSagas { time_requested } => {
70+
QuiesceState::DrainingSagas { time_requested } => {
6871
println!(
6972
"quiescing since {} ({} ago)",
7073
humantime::format_rfc3339_millis(time_requested.into()),
7174
format_time_delta(now - time_requested),
7275
);
7376
println!("details: waiting for running sagas to finish");
7477
}
75-
QuiesceState::WaitingForDb {
78+
QuiesceState::DrainingDb {
7679
time_requested,
77-
duration_waiting_for_sagas,
80+
duration_draining_sagas,
7881
..
7982
} => {
8083
println!(
@@ -87,13 +90,34 @@ async fn quiesce_show(
8790
);
8891
println!(
8992
" previously: waiting for sagas took {}",
90-
format_duration_ms(duration_waiting_for_sagas.into()),
93+
format_duration_ms(duration_draining_sagas.into()),
94+
);
95+
}
96+
QuiesceState::RecordingQuiesce {
97+
time_requested,
98+
duration_draining_sagas,
99+
duration_draining_db,
100+
..
101+
} => {
102+
println!(
103+
"quiescing since {} ({} ago)",
104+
humantime::format_rfc3339_millis(time_requested.into()),
105+
format_time_delta(now - time_requested),
106+
);
107+
println!(
108+
" waiting for sagas took {}",
109+
format_duration_ms(duration_draining_sagas.into()),
110+
);
111+
println!(
112+
" waiting for db quiesce took {}",
113+
format_duration_ms(duration_draining_db.into()),
91114
);
92115
}
93116
QuiesceState::Quiesced {
94117
time_quiesced,
95-
duration_waiting_for_sagas,
96-
duration_waiting_for_db,
118+
duration_draining_sagas,
119+
duration_draining_db,
120+
duration_recording_quiesce,
97121
duration_total,
98122
..
99123
} => {
@@ -104,11 +128,15 @@ async fn quiesce_show(
104128
);
105129
println!(
106130
" waiting for sagas took {}",
107-
format_duration_ms(duration_waiting_for_sagas.into()),
131+
format_duration_ms(duration_draining_sagas.into()),
108132
);
109133
println!(
110134
" waiting for db quiesce took {}",
111-
format_duration_ms(duration_waiting_for_db.into()),
135+
format_duration_ms(duration_draining_db.into()),
136+
);
137+
println!(
138+
" recording quiesce took {}",
139+
format_duration_ms(duration_recording_quiesce.into()),
112140
);
113141
println!(
114142
" total quiesce time: {}",

nexus/src/app/background/tasks/blueprint_execution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl BlueprintExecutor {
108108
// blueprint before enabling sagas, since we already know if we're
109109
// quiescing or not); and (2) because we want to do it even if blueprint
110110
// execution is disabled.
111-
match blueprint.nexus_quiescing(self.nexus_id) {
111+
match blueprint.is_nexus_quiescing(self.nexus_id) {
112112
Ok(quiescing) => {
113113
debug!(
114114
&opctx.log,

nexus/src/app/quiesce.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,24 +250,27 @@ mod test {
250250
let QuiesceState::Quiesced {
251251
time_requested,
252252
time_quiesced,
253-
duration_waiting_for_sagas,
254-
duration_waiting_for_db,
253+
duration_draining_sagas,
254+
duration_draining_db,
255+
duration_recording_quiesce,
255256
duration_total,
256257
} = status.state
257258
else {
258259
panic!("not quiesced");
259260
};
260261
let duration_total = Duration::from(duration_total);
261-
let duration_waiting_for_sagas =
262-
Duration::from(duration_waiting_for_sagas);
263-
let duration_waiting_for_db = Duration::from(duration_waiting_for_db);
262+
let duration_draining_sagas = Duration::from(duration_draining_sagas);
263+
let duration_draining_db = Duration::from(duration_draining_db);
264+
let duration_recording_quiesce =
265+
Duration::from(duration_recording_quiesce);
264266
assert!(time_requested >= before);
265267
assert!(time_requested <= after);
266268
assert!(time_quiesced >= before);
267269
assert!(time_quiesced <= after);
268270
assert!(time_quiesced >= time_requested);
269-
assert!(duration_total >= duration_waiting_for_sagas);
270-
assert!(duration_total >= duration_waiting_for_db);
271+
assert!(duration_total >= duration_draining_sagas);
272+
assert!(duration_total >= duration_draining_db);
273+
assert!(duration_total >= duration_recording_quiesce);
271274
assert!(duration_total <= (after - before).to_std().unwrap());
272275
assert!(status.sagas_pending.is_empty());
273276
assert!(status.db_claims.is_empty());
@@ -341,7 +344,7 @@ mod test {
341344
debug!(log, "found quiesce status"; "status" => ?quiesce_status);
342345
assert_matches!(
343346
quiesce_status.state,
344-
QuiesceState::WaitingForSagas { .. }
347+
QuiesceState::DrainingSagas { .. }
345348
);
346349
assert!(quiesce_status.sagas_pending.contains_key(&demo_saga.saga_id));
347350
// We should see at least one held database claim from the one we took
@@ -404,7 +407,7 @@ mod test {
404407
.map_err(|e| CondCheckError::Failed(e))?
405408
.into_inner();
406409
debug!(log, "found quiesce state"; "state" => ?rv);
407-
if !matches!(rv.state, QuiesceState::WaitingForDb { .. }) {
410+
if !matches!(rv.state, QuiesceState::DrainingDb { .. }) {
408411
return Err(CondCheckError::<NexusClientError>::NotYet);
409412
}
410413
assert!(rv.sagas_pending.is_empty());

nexus/types/src/deployment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl Blueprint {
386386

387387
/// Returns whether the given Nexus instance should be quiescing or quiesced
388388
/// in preparation for handoff to the next generation
389-
pub fn nexus_quiescing(
389+
pub fn is_nexus_quiescing(
390390
&self,
391391
nexus_id: OmicronZoneUuid,
392392
) -> Result<bool, anyhow::Error> {

openapi/nexus-internal.json

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7402,8 +7402,23 @@
74027402
]
74037403
},
74047404
"QuiesceState": {
7405-
"description": "See [`QuiesceStatus`] for more on Nexus quiescing.\n\nAt any given time, Nexus is always in one of these states:\n\n```text Running (normal operation) | | quiesce starts v WaitingForSagas (no new sagas are allowed, but some are still running) | | no more sagas running v WaitingForDb (no sagas running; no new db connections may be acquired by Nexus at-large, but some are still held) | | no more database connections held v Quiesced (no sagas running, no database connections in use) ```\n\nQuiescing is (currently) a one-way trip: once a Nexus process starts quiescing, it will never go back to normal operation. It will never go back to an earlier stage, either.",
7405+
"description": "See [`QuiesceStatus`] for more on Nexus quiescing.\n\nAt any given time, Nexus is always in one of these states:\n\n```text Undetermined (have not loaded persistent state; don't know yet) | | load persistent state and find we're not quiescing v Running (normal operation) | | quiesce starts v DrainingSagas (no new sagas are allowed, but some are still running) | | no more sagas running v DrainingDb (no sagas running; no new db connections may be | acquired by Nexus at-large, but some are still held) | | no more database connections held v RecordingQuiesce (everything is quiesced aside from one connection being | used to record our final quiesced state) | | finish recording quiesce state in database v Quiesced (no sagas running, no database connections in use) ```\n\nQuiescing is (currently) a one-way trip: once a Nexus process starts quiescing, it will never go back to normal operation. It will never go back to an earlier stage, either.",
74067406
"oneOf": [
7407+
{
7408+
"description": "We have not yet determined based on persistent state if we're supposed to be quiesced or not",
7409+
"type": "object",
7410+
"properties": {
7411+
"state": {
7412+
"type": "string",
7413+
"enum": [
7414+
"undetermined"
7415+
]
7416+
}
7417+
},
7418+
"required": [
7419+
"state"
7420+
]
7421+
},
74077422
{
74087423
"description": "Normal operation",
74097424
"type": "object",
@@ -7420,7 +7435,7 @@
74207435
]
74217436
},
74227437
{
7423-
"description": "New sagas disallowed, but some are still running.",
7438+
"description": "New sagas disallowed, but some are still running on some Nexus instances",
74247439
"type": "object",
74257440
"properties": {
74267441
"quiesce_details": {
@@ -7438,7 +7453,7 @@
74387453
"state": {
74397454
"type": "string",
74407455
"enum": [
7441-
"waiting_for_sagas"
7456+
"draining_sagas"
74427457
]
74437458
}
74447459
},
@@ -7448,13 +7463,13 @@
74487463
]
74497464
},
74507465
{
7451-
"description": "No sagas running, no new database connections may be claimed, but some database connections are still held.",
7466+
"description": "No sagas running on any Nexus instances\n\nNo new database connections may be claimed, but some database connections are still held.",
74527467
"type": "object",
74537468
"properties": {
74547469
"quiesce_details": {
74557470
"type": "object",
74567471
"properties": {
7457-
"duration_waiting_for_sagas": {
7472+
"duration_draining_sagas": {
74587473
"$ref": "#/components/schemas/Duration"
74597474
},
74607475
"time_requested": {
@@ -7463,14 +7478,50 @@
74637478
}
74647479
},
74657480
"required": [
7466-
"duration_waiting_for_sagas",
7481+
"duration_draining_sagas",
74677482
"time_requested"
74687483
]
74697484
},
74707485
"state": {
74717486
"type": "string",
74727487
"enum": [
7473-
"waiting_for_db"
7488+
"draining_db"
7489+
]
7490+
}
7491+
},
7492+
"required": [
7493+
"quiesce_details",
7494+
"state"
7495+
]
7496+
},
7497+
{
7498+
"description": "No database connections in use except to record the final \"quiesced\" state",
7499+
"type": "object",
7500+
"properties": {
7501+
"quiesce_details": {
7502+
"type": "object",
7503+
"properties": {
7504+
"duration_draining_db": {
7505+
"$ref": "#/components/schemas/Duration"
7506+
},
7507+
"duration_draining_sagas": {
7508+
"$ref": "#/components/schemas/Duration"
7509+
},
7510+
"time_requested": {
7511+
"type": "string",
7512+
"format": "date-time"
7513+
}
7514+
},
7515+
"required": [
7516+
"duration_draining_db",
7517+
"duration_draining_sagas",
7518+
"time_requested"
7519+
]
7520+
},
7521+
"state": {
7522+
"type": "string",
7523+
"enum": [
7524+
"recording_quiesce"
74747525
]
74757526
}
74767527
},
@@ -7486,13 +7537,16 @@
74867537
"quiesce_details": {
74877538
"type": "object",
74887539
"properties": {
7489-
"duration_total": {
7540+
"duration_draining_db": {
74907541
"$ref": "#/components/schemas/Duration"
74917542
},
7492-
"duration_waiting_for_db": {
7543+
"duration_draining_sagas": {
74937544
"$ref": "#/components/schemas/Duration"
74947545
},
7495-
"duration_waiting_for_sagas": {
7546+
"duration_recording_quiesce": {
7547+
"$ref": "#/components/schemas/Duration"
7548+
},
7549+
"duration_total": {
74967550
"$ref": "#/components/schemas/Duration"
74977551
},
74987552
"time_quiesced": {
@@ -7505,9 +7559,10 @@
75057559
}
75067560
},
75077561
"required": [
7562+
"duration_draining_db",
7563+
"duration_draining_sagas",
7564+
"duration_recording_quiesce",
75087565
"duration_total",
7509-
"duration_waiting_for_db",
7510-
"duration_waiting_for_sagas",
75117566
"time_quiesced",
75127567
"time_requested"
75137568
]

0 commit comments

Comments
 (0)