Skip to content

Commit

Permalink
rebase on main, fix test
Browse files Browse the repository at this point in the history
Created using spr 1.3.6-beta.1
  • Loading branch information
sunshowers committed Aug 30, 2024
2 parents 318b00b + 61e1b38 commit 3fde731
Show file tree
Hide file tree
Showing 33 changed files with 843 additions and 145 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ dyn-clone = "1.0.17"
either = "1.13.0"
expectorate = "1.1.0"
fatfs = "0.3.6"
filetime = "0.2.24"
filetime = "0.2.25"
flate2 = "1.0.31"
float-ord = "0.3.2"
flume = "0.11.0"
Expand Down
43 changes: 36 additions & 7 deletions dev-tools/omdb/src/bin/omdb/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use nexus_saga_recovery::LastPass;
use nexus_types::deployment::Blueprint;
use nexus_types::internal_api::background::LookupRegionPortStatus;
use nexus_types::internal_api::background::RegionReplacementDriverStatus;
use nexus_types::internal_api::background::RegionSnapshotReplacementFinishStatus;
use nexus_types::internal_api::background::RegionSnapshotReplacementGarbageCollectStatus;
use nexus_types::internal_api::background::RegionSnapshotReplacementStartStatus;
use nexus_types::internal_api::background::RegionSnapshotReplacementStepStatus;
Expand Down Expand Up @@ -1661,6 +1662,30 @@ fn print_task_details(bgtask: &BackgroundTask, details: &serde_json::Value) {
println!("{}", table);
}
}
} else if name == "region_snapshot_replacement_finish" {
match serde_json::from_value::<RegionSnapshotReplacementFinishStatus>(
details.clone(),
) {
Err(error) => eprintln!(
"warning: failed to interpret task details: {:?}: {:?}",
error, details
),

Ok(status) => {
println!(
" total records transitioned to done: {}",
status.records_set_to_done.len(),
);
for line in &status.records_set_to_done {
println!(" > {line}");
}

println!(" errors: {}", status.errors.len());
for line in &status.errors {
println!(" > {line}");
}
}
}
} else {
println!(
"warning: unknown background task: {:?} \
Expand Down Expand Up @@ -1690,16 +1715,17 @@ fn bgtask_apply_kv_style(table: &mut tabled::Table) {
);
}

// Extract and remove the event report. (If we don't do this, the `Debug`
// output can be quite large.)
/// Extract and remove the event report, returning None if it wasn't found and
/// an error if something else went wrong. (If we don't do this, the `Debug`
/// output can be quite large.)
fn extract_event_buffer(
value: &mut serde_json::Value,
) -> anyhow::Result<EventBuffer<NestedSpec>> {
) -> anyhow::Result<Option<EventBuffer<NestedSpec>>> {
let Some(obj) = value.as_object_mut() else {
bail!("expected value to be an object")
};
let Some(event_report) = obj.remove("event_report") else {
bail!("expected 'event_report' field in value")
return Ok(None);
};

// Try deserializing the event report generically. We could deserialize to
Expand All @@ -1714,19 +1740,22 @@ fn extract_event_buffer(

let mut event_buffer = EventBuffer::default();
event_buffer.add_event_report(event_report);
Ok(event_buffer)
Ok(Some(event_buffer))
}

// Make a short summary of the current state of an execution based on an event
// buffer, and add it to the table.
fn push_event_buffer_summary(
event_buffer: anyhow::Result<EventBuffer<NestedSpec>>,
event_buffer: anyhow::Result<Option<EventBuffer<NestedSpec>>>,
builder: &mut tabled::builder::Builder,
) {
match event_buffer {
Ok(buffer) => {
Ok(Some(buffer)) => {
event_buffer_summary_impl(buffer, builder);
}
Ok(None) => {
builder.push_record(["status:", "(no event report found)"]);
}
Err(error) => {
builder.push_record([
"event report error:".to_string(),
Expand Down
12 changes: 12 additions & 0 deletions dev-tools/omdb/tests/env.out
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ task: "region_replacement_driver"
drive region replacements forward to completion


task: "region_snapshot_replacement_finish"
complete a region snapshot replacement if all the steps are done


task: "region_snapshot_replacement_garbage_collection"
clean up all region snapshot replacement step volumes

Expand Down Expand Up @@ -289,6 +293,10 @@ task: "region_replacement_driver"
drive region replacements forward to completion


task: "region_snapshot_replacement_finish"
complete a region snapshot replacement if all the steps are done


task: "region_snapshot_replacement_garbage_collection"
clean up all region snapshot replacement step volumes

Expand Down Expand Up @@ -438,6 +446,10 @@ task: "region_replacement_driver"
drive region replacements forward to completion


task: "region_snapshot_replacement_finish"
complete a region snapshot replacement if all the steps are done


task: "region_snapshot_replacement_garbage_collection"
clean up all region snapshot replacement step volumes

Expand Down
20 changes: 20 additions & 0 deletions dev-tools/omdb/tests/successes.out
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ task: "region_replacement_driver"
drive region replacements forward to completion


task: "region_snapshot_replacement_finish"
complete a region snapshot replacement if all the steps are done


task: "region_snapshot_replacement_garbage_collection"
clean up all region snapshot replacement step volumes

Expand Down Expand Up @@ -594,6 +598,14 @@ task: "region_replacement_driver"
number of region replacement finish sagas started ok: 0
number of errors: 0

task: "region_snapshot_replacement_finish"
configured period: every <REDACTED_DURATION>s
currently executing: no
last completed activation: <REDACTED ITERATIONS>, triggered by a periodic timer firing
started at <REDACTED TIMESTAMP> (<REDACTED DURATION>s ago) and ran for <REDACTED DURATION>ms
total records transitioned to done: 0
errors: 0

task: "region_snapshot_replacement_garbage_collection"
configured period: every <REDACTED_DURATION>s
currently executing: no
Expand Down Expand Up @@ -1012,6 +1024,14 @@ task: "region_replacement_driver"
number of region replacement finish sagas started ok: 0
number of errors: 0

task: "region_snapshot_replacement_finish"
configured period: every <REDACTED_DURATION>s
currently executing: no
last completed activation: <REDACTED ITERATIONS>, triggered by a periodic timer firing
started at <REDACTED TIMESTAMP> (<REDACTED DURATION>s ago) and ran for <REDACTED DURATION>ms
total records transitioned to done: 0
errors: 0

task: "region_snapshot_replacement_garbage_collection"
configured period: every <REDACTED_DURATION>s
currently executing: no
Expand Down
4 changes: 2 additions & 2 deletions end-to-end-tests/src/bin/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use oxide_client::types::{
NameOrId, SiloQuotasUpdate,
};
use oxide_client::{
ClientDisksExt, ClientHiddenExt, ClientProjectsExt,
ClientSystemNetworkingExt, ClientSystemSilosExt,
ClientDisksExt, ClientHiddenExt, ClientProjectsExt, ClientSystemIpPoolsExt,
ClientSystemSilosExt,
};
use serde::{de::DeserializeOwned, Deserialize};
use std::time::Duration;
Expand Down
2 changes: 1 addition & 1 deletion end-to-end-tests/src/bin/commtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use oxide_client::{
UsernamePasswordCredentials,
},
ClientHiddenExt, ClientLoginExt, ClientProjectsExt,
ClientSystemHardwareExt, ClientSystemNetworkingExt, ClientSystemStatusExt,
ClientSystemHardwareExt, ClientSystemIpPoolsExt, ClientSystemStatusExt,
ClientVpcsExt,
};
use std::{
Expand Down
17 changes: 17 additions & 0 deletions nexus-config/src/nexus_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ pub struct BackgroundTaskConfig {
RegionSnapshotReplacementGarbageCollectionConfig,
/// configuration for region snapshot replacement step task
pub region_snapshot_replacement_step: RegionSnapshotReplacementStepConfig,
/// configuration for region snapshot replacement finisher task
pub region_snapshot_replacement_finish:
RegionSnapshotReplacementFinishConfig,
}

#[serde_as]
Expand Down Expand Up @@ -658,6 +661,14 @@ pub struct RegionSnapshotReplacementStepConfig {
pub period_secs: Duration,
}

#[serde_as]
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct RegionSnapshotReplacementFinishConfig {
/// period (in seconds) for periodic activations of this background task
#[serde_as(as = "DurationSeconds<u64>")]
pub period_secs: Duration,
}

/// Configuration for a nexus server
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct PackageConfig {
Expand Down Expand Up @@ -908,6 +919,7 @@ mod test {
region_snapshot_replacement_start.period_secs = 30
region_snapshot_replacement_garbage_collection.period_secs = 30
region_snapshot_replacement_step.period_secs = 30
region_snapshot_replacement_finish.period_secs = 30
[default_region_allocation_strategy]
type = "random"
seed = 0
Expand Down Expand Up @@ -1082,6 +1094,10 @@ mod test {
RegionSnapshotReplacementStepConfig {
period_secs: Duration::from_secs(30),
},
region_snapshot_replacement_finish:
RegionSnapshotReplacementFinishConfig {
period_secs: Duration::from_secs(30),
},
},
default_region_allocation_strategy:
crate::nexus_config::RegionAllocationStrategy::Random {
Expand Down Expand Up @@ -1161,6 +1177,7 @@ mod test {
region_snapshot_replacement_start.period_secs = 30
region_snapshot_replacement_garbage_collection.period_secs = 30
region_snapshot_replacement_step.period_secs = 30
region_snapshot_replacement_finish.period_secs = 30
[default_region_allocation_strategy]
type = "random"
"##,
Expand Down
1 change: 1 addition & 0 deletions nexus/examples/config-second.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ lookup_region_port.period_secs = 60
region_snapshot_replacement_start.period_secs = 30
region_snapshot_replacement_garbage_collection.period_secs = 30
region_snapshot_replacement_step.period_secs = 30
region_snapshot_replacement_finish.period_secs = 30

[default_region_allocation_strategy]
# allocate region on 3 random distinct zpools, on 3 random distinct sleds.
Expand Down
1 change: 1 addition & 0 deletions nexus/examples/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ lookup_region_port.period_secs = 60
region_snapshot_replacement_start.period_secs = 30
region_snapshot_replacement_garbage_collection.period_secs = 30
region_snapshot_replacement_step.period_secs = 30
region_snapshot_replacement_finish.period_secs = 30

[default_region_allocation_strategy]
# allocate region on 3 random distinct zpools, on 3 random distinct sleds.
Expand Down
13 changes: 8 additions & 5 deletions nexus/external-api/output/nexus_tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ sled_view GET /v1/system/hardware/sleds/{sle
switch_list GET /v1/system/hardware/switches
switch_view GET /v1/system/hardware/switches/{switch_id}

API operations found with tag "system/metrics"
OPERATION ID METHOD URL PATH
system_metric GET /v1/system/metrics/{metric_name}

API operations found with tag "system/networking"
API operations found with tag "system/ip-pools"
OPERATION ID METHOD URL PATH
ip_pool_create POST /v1/system/ip-pools
ip_pool_delete DELETE /v1/system/ip-pools/{pool}
Expand All @@ -169,6 +165,13 @@ ip_pool_silo_update PUT /v1/system/ip-pools/{pool}/sil
ip_pool_update PUT /v1/system/ip-pools/{pool}
ip_pool_utilization_view GET /v1/system/ip-pools/{pool}/utilization
ip_pool_view GET /v1/system/ip-pools/{pool}

API operations found with tag "system/metrics"
OPERATION ID METHOD URL PATH
system_metric GET /v1/system/metrics/{metric_name}

API operations found with tag "system/networking"
OPERATION ID METHOD URL PATH
networking_address_lot_block_list GET /v1/system/networking/address-lot/{address_lot}/blocks
networking_address_lot_create POST /v1/system/networking/address-lot
networking_address_lot_delete DELETE /v1/system/networking/address-lot/{address_lot}
Expand Down
Loading

0 comments on commit 3fde731

Please sign in to comment.