Skip to content

Commit

Permalink
[2/3 sled-agent] move some common types into their own crate (#6122)
Browse files Browse the repository at this point in the history
These are core API types used by the bootstrap agent. This is almost
entirely pure code movement with no functional changes.

These types will be exposed via the upcoming bootstrap-agent-api crate,
and I don't want to clutter the API crate too much. In the future we could
also batch-replace these with the new progenitor stuff if desired.

Depends on #6089.
  • Loading branch information
sunshowers authored Jul 19, 2024
1 parent dea7eb6 commit 204ea7d
Show file tree
Hide file tree
Showing 28 changed files with 1,496 additions and 1,370 deletions.
26 changes: 26 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ members = [
"passwords",
"rpaths",
"sled-agent",
"sled-agent/types",
"sled-hardware",
"sled-hardware/types",
"sled-storage",
Expand Down Expand Up @@ -170,6 +171,7 @@ default-members = [
"passwords",
"rpaths",
"sled-agent",
"sled-agent/types",
"sled-hardware",
"sled-hardware/types",
"sled-storage",
Expand Down Expand Up @@ -472,6 +474,7 @@ similar-asserts = "1.5.0"
# server zones.
sled = "=0.34.7"
sled-agent-client = { path = "clients/sled-agent-client" }
sled-agent-types = { path = "sled-agent/types" }
sled-hardware = { path = "sled-hardware" }
sled-hardware-types = { path = "sled-hardware/types" }
sled-storage = { path = "sled-storage" }
Expand Down
1 change: 1 addition & 0 deletions end-to-end-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ russh = "0.43.0"
russh-keys = "0.43.0"
serde.workspace = true
serde_json.workspace = true
sled-agent-types.workspace = true
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
toml.workspace = true
trust-dns-resolver.workspace = true
Expand Down
10 changes: 5 additions & 5 deletions end-to-end-tests/src/helpers/ctx.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::helpers::generate_name;
use anyhow::{anyhow, Context as _, Result};
use chrono::Utc;
use omicron_sled_agent::rack_setup::config::SetupServiceConfig;
use omicron_test_utils::dev::poll::{wait_for_condition, CondCheckError};
use oxide_client::types::{Name, ProjectCreate};
use oxide_client::CustomDnsResolver;
use oxide_client::{Client, ClientImagesExt, ClientProjectsExt, ClientVpcsExt};
use reqwest::dns::Resolve;
use reqwest::header::{HeaderMap, HeaderValue};
use reqwest::Url;
use sled_agent_types::rack_init::RackInitializeRequest;
use std::net::IpAddr;
use std::net::SocketAddr;
use std::sync::Arc;
Expand Down Expand Up @@ -73,23 +73,23 @@ impl Context {
}
}

fn rss_config() -> Result<SetupServiceConfig> {
fn rss_config() -> Result<RackInitializeRequest> {
let path = "/opt/oxide/sled-agent/pkg/config-rss.toml";
let content =
std::fs::read_to_string(&path).unwrap_or(RSS_CONFIG_STR.to_string());
toml::from_str(&content)
.with_context(|| "parsing config-rss as TOML".to_string())
}

fn nexus_external_dns_name(config: &SetupServiceConfig) -> String {
fn nexus_external_dns_name(config: &RackInitializeRequest) -> String {
format!(
"{}.sys.{}",
config.recovery_silo.silo_name.as_str(),
config.external_dns_zone_name
)
}

fn external_dns_addr(config: &SetupServiceConfig) -> Result<SocketAddr> {
fn external_dns_addr(config: &RackInitializeRequest) -> Result<SocketAddr> {
// From the RSS config, grab the first address from the configured services
// IP pool as the DNS server's IP address.
let dns_ip = config
Expand Down Expand Up @@ -138,7 +138,7 @@ pub async fn nexus_addr() -> Result<IpAddr> {
}

pub struct ClientParams {
rss_config: SetupServiceConfig,
rss_config: RackInitializeRequest,
nexus_dns_name: String,
resolver: Arc<CustomDnsResolver>,
proto: &'static str,
Expand Down
2 changes: 1 addition & 1 deletion openapi/sled-agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -2658,7 +2658,7 @@
]
},
"EarlyNetworkConfig": {
"description": "Network configuration required to bring up the control plane\n\nThe fields in this structure are those from [`super::params::RackInitializeRequest`] necessary for use beyond RSS. This is just for the initial rack configuration and cold boot purposes. Updates come from Nexus.",
"description": "Network configuration required to bring up the control plane\n\nThe fields in this structure are those from [`crate::rack_init::RackInitializeRequest`] necessary for use beyond RSS. This is just for the initial rack configuration and cold boot purposes. Updates come from Nexus.",
"type": "object",
"properties": {
"body": {
Expand Down
1 change: 1 addition & 0 deletions sled-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ serde_human_bytes.workspace = true
serde_json = { workspace = true, features = ["raw_value"] }
sha3.workspace = true
sled-agent-client.workspace = true
sled-agent-types.workspace = true
sled-hardware.workspace = true
sled-hardware-types.workspace = true
sled-storage.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions sled-agent/src/bin/sled-agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use omicron_common::cmd::fatal;
use omicron_common::cmd::CmdError;
use omicron_sled_agent::bootstrap::server as bootstrap_server;
use omicron_sled_agent::bootstrap::RssAccessError;
use omicron_sled_agent::rack_setup::config::SetupServiceConfig as RssConfig;
use omicron_sled_agent::{config::Config as SledConfig, server as sled_server};
use sled_agent_types::rack_init::RackInitializeRequest;

#[derive(Subcommand, Debug)]
enum OpenapiFlavor {
Expand Down Expand Up @@ -81,7 +81,7 @@ async fn do_run() -> Result<(), CmdError> {
};
let rss_config = if rss_config_path.exists() {
Some(
RssConfig::from_file(rss_config_path)
RackInitializeRequest::from_file(rss_config_path)
.map_err(|e| CmdError::Failure(anyhow!(e)))?,
)
} else {
Expand Down
Loading

0 comments on commit 204ea7d

Please sign in to comment.