Skip to content

Commit

Permalink
initial inventory for automated update
Browse files Browse the repository at this point in the history
This commit matches commit 581e902 in
branch dap/nexus-inventory.  I've just rebased the changes onto "main"
here.
  • Loading branch information
davepacheco committed Oct 18, 2023
1 parent 7d88789 commit 0f01172
Show file tree
Hide file tree
Showing 43 changed files with 3,338 additions and 52 deletions.
19 changes: 19 additions & 0 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ members = [
"nexus/db-model",
"nexus/db-queries",
"nexus/defaults",
"nexus/inventory",
"nexus/test-interface",
"nexus/test-utils-macros",
"nexus/test-utils",
Expand Down Expand Up @@ -106,6 +107,7 @@ default-members = [
"nexus/db-model",
"nexus/db-queries",
"nexus/defaults",
"nexus/inventory",
"nexus/types",
"oximeter/collector",
"oximeter/db",
Expand Down Expand Up @@ -231,6 +233,7 @@ nexus-client = { path = "clients/nexus-client" }
nexus-db-model = { path = "nexus/db-model" }
nexus-db-queries = { path = "nexus/db-queries" }
nexus-defaults = { path = "nexus/defaults" }
nexus-inventory = { path = "nexus/inventory" }
omicron-certificates = { path = "certificates" }
omicron-passwords = { path = "passwords" }
omicron-workspace-hack = "0.1.0"
Expand Down Expand Up @@ -369,8 +372,8 @@ tufaceous = { path = "tufaceous" }
tufaceous-lib = { path = "tufaceous-lib" }
unicode-width = "0.1.10"
update-engine = { path = "update-engine" }
uuid = { version = "1.4.1", features = ["serde", "v4"] }
usdt = "0.3"
uuid = { version = "1.4.1", features = ["serde", "v4"] }
walkdir = "2.4"
wicket = { path = "wicket" }
wicket-common = { path = "wicket-common" }
Expand Down
41 changes: 33 additions & 8 deletions common/src/nexus_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ pub struct BackgroundTaskConfig {
pub dns_external: DnsTasksConfig,
/// configuration for external endpoint list watcher
pub external_endpoints: ExternalEndpointsConfig,
/// configuration for inventory tasks
pub inventory: InventoryConfig,
}

#[serde_as]
Expand Down Expand Up @@ -345,6 +347,24 @@ pub struct ExternalEndpointsConfig {
// allow/disallow wildcard certs, don't serve expired certs, etc.)
}

#[serde_as]
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct InventoryConfig {
/// period (in seconds) for periodic activations of this background task
///
/// Each activation fetches information about all harware and software in
/// the system and inserts it into the database. This generates a moderate
/// amount of data.
#[serde_as(as = "DurationSeconds<u64>")]
pub period_secs: Duration,

/// maximum number of past collections to keep in the database
///
/// This is a very coarse mechanism to keep the system from overwhelming
/// itself with inventory data.
pub nkeep: u32,
}

/// Configuration for a nexus server
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct PackageConfig {
Expand Down Expand Up @@ -440,18 +460,15 @@ impl std::fmt::Display for SchemeName {

#[cfg(test)]
mod test {
use super::Tunables;
use super::{
AuthnConfig, Config, ConsoleConfig, LoadError, PackageConfig,
SchemeName, TimeseriesDbConfig, UpdatesConfig,
AuthnConfig, BackgroundTaskConfig, Config, ConfigDropshotWithTls,
ConsoleConfig, Database, DeploymentConfig, DnsTasksConfig, DpdConfig,
ExternalEndpointsConfig, InternalDns, InventoryConfig, LoadError,
LoadErrorKind, PackageConfig, SchemeName, TimeseriesDbConfig, Tunables,
UpdatesConfig,
};
use crate::address::{Ipv6Subnet, RACK_PREFIX};
use crate::api::internal::shared::SwitchLocation;
use crate::nexus_config::{
BackgroundTaskConfig, ConfigDropshotWithTls, Database,
DeploymentConfig, DnsTasksConfig, DpdConfig, ExternalEndpointsConfig,
InternalDns, LoadErrorKind,
};
use dropshot::ConfigDropshot;
use dropshot::ConfigLogging;
use dropshot::ConfigLoggingIfExists;
Expand Down Expand Up @@ -596,6 +613,8 @@ mod test {
dns_external.period_secs_propagation = 7
dns_external.max_concurrent_server_updates = 8
external_endpoints.period_secs = 9
inventory.period_secs = 10
inventory.nkeep = 11
[default_region_allocation_strategy]
type = "random"
seed = 0
Expand Down Expand Up @@ -680,6 +699,10 @@ mod test {
},
external_endpoints: ExternalEndpointsConfig {
period_secs: Duration::from_secs(9),
},
inventory: InventoryConfig {
period_secs: Duration::from_secs(10),
nkeep: 11,
}
},
default_region_allocation_strategy:
Expand Down Expand Up @@ -733,6 +756,8 @@ mod test {
dns_external.period_secs_propagation = 7
dns_external.max_concurrent_server_updates = 8
external_endpoints.period_secs = 9
inventory.period_secs = 10
inventory.nkeep = 3
[default_region_allocation_strategy]
type = "random"
"##,
Expand Down
Loading

0 comments on commit 0f01172

Please sign in to comment.