Skip to content

Commit

Permalink
bgp and friends
Browse files Browse the repository at this point in the history
  • Loading branch information
rcgoodfellow committed Oct 13, 2023
1 parent 69113e9 commit fc9b0d4
Show file tree
Hide file tree
Showing 105 changed files with 6,678 additions and 1,690 deletions.
4 changes: 2 additions & 2 deletions .github/buildomat/jobs/build-and-test-linux.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
#:
#: name = "build-and-test (ubuntu-20.04)"
#: name = "build-and-test (ubuntu-22.04)"
#: variety = "basic"
#: target = "ubuntu-20.04"
#: target = "ubuntu-22.04"
#: rust_toolchain = "1.72.1"
#: output_rules = [
#: "/var/tmp/omicron_tmp/*",
Expand Down
1 change: 1 addition & 0 deletions .github/buildomat/jobs/clippy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ ptime -m bash ./tools/install_builder_prerequisites.sh -y

banner clippy
ptime -m cargo xtask clippy
ptime -m cargo doc
10 changes: 5 additions & 5 deletions .github/buildomat/jobs/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ infra_ip_first = \"$UPLINK_IP\"
/^infra_ip_last/c\\
infra_ip_last = \"$UPLINK_IP\"
}
/^\\[\\[rack_network_config.uplinks/,/^\$/ {
/^gateway_ip/c\\
gateway_ip = \"$GATEWAY_IP\"
/^uplink_cidr/c\\
uplink_cidr = \"$UPLINK_IP/32\"
/^\\[\\[rack_network_config.ports/,/^\$/ {
/^routes/c\\
routes = \\[{nexthop = \"$GATEWAY_IP\", destination = \"0.0.0.0/0\"}\\]
/^addresses/c\\
addresses = \\[\"$UPLINK_IP/32\"\\]
}
" pkg/config-rss.toml
diff -u pkg/config-rss.toml{~,} || true
Expand Down
6 changes: 3 additions & 3 deletions .github/buildomat/jobs/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ tarball_src_dir="$(pwd)/out/versioned"
stamp_packages() {
for package in "$@"; do
# TODO: remove once https://github.com/oxidecomputer/omicron-package/pull/54 lands
if [[ $package == maghemite ]]; then
if [[ $package == mg-ddm-gz ]]; then
echo "0.0.0" > VERSION
tar rvf "out/$package.tar" VERSION
rm VERSION
Expand All @@ -90,7 +90,7 @@ ptime -m cargo run --locked --release --bin omicron-package -- \
-t host target create -i standard -m gimlet -s asic -r multi-sled
ptime -m cargo run --locked --release --bin omicron-package -- \
-t host package
stamp_packages omicron-sled-agent maghemite propolis-server overlay
stamp_packages omicron-sled-agent mg-ddm-gz propolis-server overlay

# Create global zone package @ /work/global-zone-packages.tar.gz
ptime -m ./tools/build-global-zone-packages.sh "$tarball_src_dir" /work
Expand Down Expand Up @@ -135,7 +135,7 @@ ptime -m cargo run --locked --release --bin omicron-package -- \
-t recovery target create -i trampoline
ptime -m cargo run --locked --release --bin omicron-package -- \
-t recovery package
stamp_packages installinator maghemite
stamp_packages installinator mg-ddm-gz

# Create trampoline global zone package @ /work/trampoline-global-zone-packages.tar.gz
ptime -m ./tools/build-trampoline-global-zone-packages.sh "$tarball_src_dir" /work
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ core
*.vdev
debug.out
rusty-tags.vi
*.sw*
tags
25 changes: 25 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 @@ -10,6 +10,7 @@ members = [
"clients/dpd-client",
"clients/gateway-client",
"clients/installinator-artifact-client",
"clients/mg-admin-client",
"clients/nexus-client",
"clients/oxide-client",
"clients/oximeter-client",
Expand Down Expand Up @@ -82,6 +83,7 @@ default-members = [
"clients/oximeter-client",
"clients/sled-agent-client",
"clients/wicketd-client",
"clients/mg-admin-client",
"common",
"dev-tools/crdb-seed",
"dev-tools/omdb",
Expand Down Expand Up @@ -227,6 +229,7 @@ macaddr = { version = "1.0.1", features = ["serde_std"] }
mime_guess = "2.0.4"
mockall = "0.11"
newtype_derive = "0.1.6"
mg-admin-client = { path = "clients/mg-admin-client" }
nexus-client = { path = "clients/nexus-client" }
nexus-db-model = { path = "nexus/db-model" }
nexus-db-queries = { path = "nexus/db-queries" }
Expand Down
4 changes: 2 additions & 2 deletions bootstore/src/schemes/v0/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//! Storage for the v0 bootstore scheme
//!
//! We write two pieces of data to M.2 devices in production via
//! [`omicron_common::Ledger`]:
//! [`omicron_common::ledger::Ledger`]:
//!
//! 1. [`super::Fsm::State`] for bootstore state itself
//! 1. [`super::State`] for bootstore state itself
//! 2. A network config blob required for pre-rack-unlock configuration
//!
Expand Down
2 changes: 2 additions & 0 deletions clients/bootstrap-agent-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ progenitor::generate_api!(
derives = [schemars::JsonSchema],
replace = {
Ipv4Network = ipnetwork::Ipv4Network,
Ipv6Network = ipnetwork::Ipv6Network,
IpNetwork = ipnetwork::IpNetwork,
}
);

Expand Down
17 changes: 10 additions & 7 deletions clients/ddm-admin-client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ fn main() -> Result<()> {
println!("cargo:rerun-if-changed=../../package-manifest.toml");

let config: Config = toml::from_str(&manifest)
.context("failed to parse ../../package-manifest.toml")?;
let maghemite = config
.context("failed to parse ../package-manifest.toml")?;

let ddm = config
.packages
.get("maghemite")
.context("missing maghemite package in ../../package-manifest.toml")?;
.get("mg-ddm-gz")
.context("missing mg-ddm-gz package in ../package-manifest.toml")?;

let local_path = match &maghemite.source {
let local_path = match &ddm.source {
PackageSource::Prebuilt { commit, .. } => {
// Report a relatively verbose error if we haven't downloaded the requisite
// openapi spec.
let local_path =
format!("../../out/downloads/ddm-admin-{commit}.json");
if !Path::new(&local_path).exists() {
bail!("{local_path} doesn't exist; rerun `tools/ci_download_maghemite_openapi` (after updating `tools/maghemite_openapi_version` if the maghemite commit in package-manifest.toml has changed)");
bail!("{local_path} doesn't exist; rerun `tools/ci_download_maghemite_openapi` (after updating `tools/maghemite_ddm_openapi_version` if the maghemite commit in package-manifest.toml has changed)");
}
println!("cargo:rerun-if-changed={local_path}");
local_path
Expand All @@ -51,7 +52,9 @@ fn main() -> Result<()> {
}

_ => {
bail!("maghemite external package must have type `prebuilt` or `manual`")
bail!(
"mg-ddm external package must have type `prebuilt` or `manual`"
)
}
};

Expand Down
26 changes: 26 additions & 0 deletions clients/mg-admin-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "mg-admin-client"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[dependencies]
either.workspace = true
progenitor-client.workspace = true
reqwest = { workspace = true, features = ["json", "stream", "rustls-tls"] }
serde.workspace = true
slog.workspace = true
thiserror.workspace = true
tokio.workspace = true
omicron-common.workspace = true
sled-hardware.workspace = true
omicron-workspace-hack.workspace = true

[build-dependencies]
anyhow.workspace = true
omicron-zone-package.workspace = true
progenitor.workspace = true
quote.workspace = true
rustfmt-wrapper.workspace = true
serde_json.workspace = true
toml.workspace = true
102 changes: 102 additions & 0 deletions clients/mg-admin-client/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

// Copyright 2022 Oxide Computer Company

use anyhow::bail;
use anyhow::Context;
use anyhow::Result;
use omicron_zone_package::config::Config;
use omicron_zone_package::package::PackageSource;
use quote::quote;
use std::env;
use std::fs;
use std::path::Path;

fn main() -> Result<()> {
// Find the current maghemite repo commit from our package manifest.
let manifest = fs::read_to_string("../../package-manifest.toml")
.context("failed to read ../../package-manifest.toml")?;
println!("cargo:rerun-if-changed=../../package-manifest.toml");

let config: Config = toml::from_str(&manifest)
.context("failed to parse ../../package-manifest.toml")?;
let mg = config
.packages
.get("mgd")
.context("missing mgd package in ../../package-manifest.toml")?;

let local_path = match &mg.source {
PackageSource::Prebuilt { commit, .. } => {
// Report a relatively verbose error if we haven't downloaded the requisite
// openapi spec.
let local_path =
format!("../../out/downloads/mg-admin-{commit}.json");
if !Path::new(&local_path).exists() {
bail!("{local_path} doesn't exist; rerun `tools/ci_download_maghemite_openapi` (after updating `tools/maghemite_mg_openapi_version` if the maghemite commit in package-manifest.toml has changed)");
}
println!("cargo:rerun-if-changed={local_path}");
local_path
}

PackageSource::Manual => {
let local_path =
"../../out/downloads/mg-admin-manual.json".to_string();
if !Path::new(&local_path).exists() {
bail!("{local_path} doesn't exist, please copy manually built mg-admin.json there!");
}
println!("cargo:rerun-if-changed={local_path}");
local_path
}

_ => {
bail!("mgd external package must have type `prebuilt` or `manual`")
}
};

let spec = {
let bytes = fs::read(&local_path)
.with_context(|| format!("failed to read {local_path}"))?;
serde_json::from_slice(&bytes).with_context(|| {
format!("failed to parse {local_path} as openapi spec")
})?
};

let code = progenitor::Generator::new(
progenitor::GenerationSettings::new()
.with_inner_type(quote!(slog::Logger))
.with_pre_hook(quote! {
|log: &slog::Logger, request: &reqwest::Request| {
slog::debug!(log, "client request";
"method" => %request.method(),
"uri" => %request.url(),
"body" => ?&request.body(),
);
}
})
.with_post_hook(quote! {
|log: &slog::Logger, result: &Result<_, _>| {
slog::debug!(log, "client response"; "result" => ?result);
}
}),
)
.generate_tokens(&spec)
.with_context(|| {
format!("failed to generate progenitor client from {local_path}")
})?;

let content = rustfmt_wrapper::rustfmt(code).with_context(|| {
format!("rustfmt failed on progenitor code from {local_path}")
})?;

let out_file =
Path::new(&env::var("OUT_DIR").expect("OUT_DIR env var not set"))
.join("mg-admin-client.rs");

fs::write(&out_file, content).with_context(|| {
format!("failed to write client to {}", out_file.display())
})?;

Ok(())
}
Loading

0 comments on commit fc9b0d4

Please sign in to comment.