Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a background task for update plan execution #4891

Merged
merged 20 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions common/src/nexus_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ pub struct BackgroundTaskConfig {
pub inventory: InventoryConfig,
/// configuration for phantom disks task
pub phantom_disks: PhantomDiskConfig,
/// configuration for blueprint related tasks
pub blueprints: BlueprintTasksConfig,
/// configuration for service zone nat sync task
pub sync_service_zone_nat: SyncServiceZoneNatConfig,
}
Expand Down Expand Up @@ -418,6 +420,20 @@ pub struct PhantomDiskConfig {
pub period_secs: Duration,
}

#[serde_as]
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct BlueprintTasksConfig {
/// period (in seconds) for periodic activations of the background task that
/// reads the latest target blueprint from the database
#[serde_as(as = "DurationSeconds<u64>")]
pub period_secs_load: Duration,

/// period (in seconds) for periodic activations of the background task that
/// executes the latest target blueprint
#[serde_as(as = "DurationSeconds<u64>")]
pub period_secs_execute: Duration,
}

/// Configuration for a nexus server
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct PackageConfig {
Expand Down Expand Up @@ -518,12 +534,12 @@ impl std::fmt::Display for SchemeName {
mod test {
use super::{
default_techport_external_server_port, AuthnConfig,
BackgroundTaskConfig, Config, ConfigDropshotWithTls, ConsoleConfig,
Database, DeploymentConfig, DnsTasksConfig, DpdConfig,
ExternalEndpointsConfig, InternalDns, InventoryConfig, LoadError,
LoadErrorKind, MgdConfig, NatCleanupConfig, PackageConfig,
PhantomDiskConfig, SchemeName, TimeseriesDbConfig, Tunables,
UpdatesConfig,
BackgroundTaskConfig, BlueprintTasksConfig, Config,
ConfigDropshotWithTls, ConsoleConfig, Database, DeploymentConfig,
DnsTasksConfig, DpdConfig, ExternalEndpointsConfig, InternalDns,
InventoryConfig, LoadError, LoadErrorKind, MgdConfig, NatCleanupConfig,
PackageConfig, PhantomDiskConfig, SchemeName, TimeseriesDbConfig,
Tunables, UpdatesConfig,
};
use crate::address::{Ipv6Subnet, RACK_PREFIX};
use crate::api::internal::shared::SwitchLocation;
Expand Down Expand Up @@ -676,6 +692,8 @@ mod test {
inventory.nkeep = 11
inventory.disable = false
phantom_disks.period_secs = 30
blueprints.period_secs_load = 10
blueprints.period_secs_execute = 60
sync_service_zone_nat.period_secs = 30
[default_region_allocation_strategy]
type = "random"
Expand Down Expand Up @@ -781,6 +799,10 @@ mod test {
phantom_disks: PhantomDiskConfig {
period_secs: Duration::from_secs(30),
},
blueprints: BlueprintTasksConfig {
period_secs_load: Duration::from_secs(10),
period_secs_execute: Duration::from_secs(60)
},
sync_service_zone_nat: SyncServiceZoneNatConfig {
period_secs: Duration::from_secs(30)
}
Expand Down Expand Up @@ -842,6 +864,8 @@ mod test {
inventory.nkeep = 3
inventory.disable = false
phantom_disks.period_secs = 30
blueprints.period_secs_load = 10
blueprints.period_secs_execute = 60
sync_service_zone_nat.period_secs = 30
[default_region_allocation_strategy]
type = "random"
Expand Down
24 changes: 24 additions & 0 deletions dev-tools/omdb/tests/env.out
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ EXECUTING COMMAND: omdb ["nexus", "--nexus-internal-url", "http://127.0.0.1:REDA
termination: Exited(0)
---------------------------------------------
stdout:
task: "blueprint_executor"
Executes the target blueprint


task: "blueprint_loader"
Loads the current target blueprint from the DB


task: "dns_config_external"
watches external DNS data stored in CockroachDB

Expand Down Expand Up @@ -96,6 +104,14 @@ EXECUTING COMMAND: omdb ["nexus", "background-tasks", "doc"]
termination: Exited(0)
---------------------------------------------
stdout:
task: "blueprint_executor"
Executes the target blueprint


task: "blueprint_loader"
Loads the current target blueprint from the DB


task: "dns_config_external"
watches external DNS data stored in CockroachDB

Expand Down Expand Up @@ -156,6 +172,14 @@ EXECUTING COMMAND: omdb ["--dns-server", "[::1]:REDACTED_PORT", "nexus", "backgr
termination: Exited(0)
---------------------------------------------
stdout:
task: "blueprint_executor"
Executes the target blueprint


task: "blueprint_loader"
Loads the current target blueprint from the DB


task: "dns_config_external"
watches external DNS data stored in CockroachDB

Expand Down
22 changes: 22 additions & 0 deletions dev-tools/omdb/tests/successes.out
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ EXECUTING COMMAND: omdb ["nexus", "background-tasks", "doc"]
termination: Exited(0)
---------------------------------------------
stdout:
task: "blueprint_executor"
Executes the target blueprint


task: "blueprint_loader"
Loads the current target blueprint from the DB


task: "dns_config_external"
watches external DNS data stored in CockroachDB

Expand Down Expand Up @@ -339,6 +347,20 @@ task: "nat_v4_garbage_collector"
started at <REDACTED TIMESTAMP> (<REDACTED DURATION>s ago) and ran for <REDACTED DURATION>ms
warning: unknown background task: "nat_v4_garbage_collector" (don't know how to interpret details: Null)

task: "blueprint_loader"
configured period: every 10s
currently executing: no
last completed activation: iter 2, triggered by an explicit signal
started at <REDACTED TIMESTAMP> (<REDACTED DURATION>s ago) and ran for <REDACTED DURATION>ms
warning: unknown background task: "blueprint_loader" (don't know how to interpret details: Object {"status": String("no target blueprint")})

task: "blueprint_executor"
configured period: every 1m
currently executing: no
last completed activation: iter 2, triggered by an explicit signal
started at <REDACTED TIMESTAMP> (<REDACTED DURATION>s ago) and ran for <REDACTED DURATION>ms
last completion reported error: no blueprint

task: "external_endpoints"
configured period: every 1m
currently executing: no
Expand Down
2 changes: 2 additions & 0 deletions nexus/examples/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ inventory.nkeep = 5
# Disable inventory collection altogether (for emergencies)
inventory.disable = false
phantom_disks.period_secs = 30
blueprints.period_secs_load = 10
blueprints.period_secs_execute = 60
sync_service_zone_nat.period_secs = 30

[default_region_allocation_strategy]
Expand Down
Loading
Loading