Skip to content

Commit a8862d5

Browse files
committed
self-review + regenerate API spec
1 parent 051ecaf commit a8862d5

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
@@ -388,7 +388,7 @@ impl Blueprint {
388388

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

openapi/nexus-internal.json

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7477,8 +7477,23 @@
74777477
]
74787478
},
74797479
"QuiesceState": {
7480-
"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.",
7480+
"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.",
74817481
"oneOf": [
7482+
{
7483+
"description": "We have not yet determined based on persistent state if we're supposed to be quiesced or not",
7484+
"type": "object",
7485+
"properties": {
7486+
"state": {
7487+
"type": "string",
7488+
"enum": [
7489+
"undetermined"
7490+
]
7491+
}
7492+
},
7493+
"required": [
7494+
"state"
7495+
]
7496+
},
74827497
{
74837498
"description": "Normal operation",
74847499
"type": "object",
@@ -7495,7 +7510,7 @@
74957510
]
74967511
},
74977512
{
7498-
"description": "New sagas disallowed, but some are still running.",
7513+
"description": "New sagas disallowed, but some are still running on some Nexus instances",
74997514
"type": "object",
75007515
"properties": {
75017516
"quiesce_details": {
@@ -7513,7 +7528,7 @@
75137528
"state": {
75147529
"type": "string",
75157530
"enum": [
7516-
"waiting_for_sagas"
7531+
"draining_sagas"
75177532
]
75187533
}
75197534
},
@@ -7523,13 +7538,13 @@
75237538
]
75247539
},
75257540
{
7526-
"description": "No sagas running, no new database connections may be claimed, but some database connections are still held.",
7541+
"description": "No sagas running on any Nexus instances\n\nNo new database connections may be claimed, but some database connections are still held.",
75277542
"type": "object",
75287543
"properties": {
75297544
"quiesce_details": {
75307545
"type": "object",
75317546
"properties": {
7532-
"duration_waiting_for_sagas": {
7547+
"duration_draining_sagas": {
75337548
"$ref": "#/components/schemas/Duration"
75347549
},
75357550
"time_requested": {
@@ -7538,14 +7553,50 @@
75387553
}
75397554
},
75407555
"required": [
7541-
"duration_waiting_for_sagas",
7556+
"duration_draining_sagas",
75427557
"time_requested"
75437558
]
75447559
},
75457560
"state": {
75467561
"type": "string",
75477562
"enum": [
7548-
"waiting_for_db"
7563+
"draining_db"
7564+
]
7565+
}
7566+
},
7567+
"required": [
7568+
"quiesce_details",
7569+
"state"
7570+
]
7571+
},
7572+
{
7573+
"description": "No database connections in use except to record the final \"quiesced\" state",
7574+
"type": "object",
7575+
"properties": {
7576+
"quiesce_details": {
7577+
"type": "object",
7578+
"properties": {
7579+
"duration_draining_db": {
7580+
"$ref": "#/components/schemas/Duration"
7581+
},
7582+
"duration_draining_sagas": {
7583+
"$ref": "#/components/schemas/Duration"
7584+
},
7585+
"time_requested": {
7586+
"type": "string",
7587+
"format": "date-time"
7588+
}
7589+
},
7590+
"required": [
7591+
"duration_draining_db",
7592+
"duration_draining_sagas",
7593+
"time_requested"
7594+
]
7595+
},
7596+
"state": {
7597+
"type": "string",
7598+
"enum": [
7599+
"recording_quiesce"
75497600
]
75507601
}
75517602
},
@@ -7561,13 +7612,16 @@
75617612
"quiesce_details": {
75627613
"type": "object",
75637614
"properties": {
7564-
"duration_total": {
7615+
"duration_draining_db": {
75657616
"$ref": "#/components/schemas/Duration"
75667617
},
7567-
"duration_waiting_for_db": {
7618+
"duration_draining_sagas": {
75687619
"$ref": "#/components/schemas/Duration"
75697620
},
7570-
"duration_waiting_for_sagas": {
7621+
"duration_recording_quiesce": {
7622+
"$ref": "#/components/schemas/Duration"
7623+
},
7624+
"duration_total": {
75717625
"$ref": "#/components/schemas/Duration"
75727626
},
75737627
"time_quiesced": {
@@ -7580,9 +7634,10 @@
75807634
}
75817635
},
75827636
"required": [
7637+
"duration_draining_db",
7638+
"duration_draining_sagas",
7639+
"duration_recording_quiesce",
75837640
"duration_total",
7584-
"duration_waiting_for_db",
7585-
"duration_waiting_for_sagas",
75867641
"time_quiesced",
75877642
"time_requested"
75887643
]

0 commit comments

Comments
 (0)