Skip to content

Commit

Permalink
merge main into branch
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshowers committed Feb 27, 2024
2 parents 1beecc8 + 58f7129 commit 207fd37
Show file tree
Hide file tree
Showing 84 changed files with 3,802 additions and 649 deletions.
4 changes: 2 additions & 2 deletions .github/buildomat/jobs/tuf-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ EOF
done
}
# usage: SERIES ROT_DIR ROT_VERSION BOARDS...
add_hubris_artifacts rot-staging-dev staging/dev cert-staging-dev-v1.0.5 "${ALL_BOARDS[@]}"
add_hubris_artifacts rot-prod-rel prod/rel cert-prod-rel-v1.0.5 "${ALL_BOARDS[@]}"
add_hubris_artifacts rot-staging-dev staging/dev cert-staging-dev-v1.0.6 "${ALL_BOARDS[@]}"
add_hubris_artifacts rot-prod-rel prod/rel cert-prod-rel-v1.0.6 "${ALL_BOARDS[@]}"

for series in "${SERIES_LIST[@]}"; do
/work/tufaceous assemble --no-generate-key /work/manifest-"$series".toml /work/repo-"$series".zip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/hakari.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
toolchain: stable
- name: Install cargo-hakari
uses: taiki-e/install-action@12af778b97addf4c562c75a0564dc7e7dc5339a5 # v2
uses: taiki-e/install-action@4ce8785db2a8a56c9ede16f705c2c49c5c61669c # v2
with:
tool: cargo-hakari
- name: Check workspace-hack Cargo.toml is up-to-date
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

25 changes: 25 additions & 0 deletions illumos-utils/src/ipadm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,29 @@ impl Ipadm {
};
Ok(())
}

// Create gateway on the IP interface if it doesn't already exist
pub fn create_opte_gateway(
opte_iface: &String,
) -> Result<(), ExecutionError> {
let addrobj = format!("{}/public", opte_iface);
let mut cmd = std::process::Command::new(PFEXEC);
let cmd = cmd.args(&[IPADM, "show-addr", &addrobj]);
match execute(cmd) {
Err(_) => {
let mut cmd = std::process::Command::new(PFEXEC);
let cmd = cmd.args(&[
IPADM,
"create-addr",
"-t",
"-T",
"dhcp",
&addrobj,
]);
execute(cmd)?;
}
Ok(_) => (),
};
Ok(())
}
}
8 changes: 6 additions & 2 deletions illumos-utils/src/opte/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct PortInner {
// Name of the port as identified by OPTE
name: String,
// IP address within the VPC Subnet
_ip: IpAddr,
ip: IpAddr,
// VPC-private MAC address
mac: MacAddr6,
// Emulated PCI slot for the guest NIC, passed to Propolis
Expand Down Expand Up @@ -95,7 +95,7 @@ impl Port {
Self {
inner: Arc::new(PortInner {
name,
_ip: ip,
ip,
mac,
slot,
vni,
Expand All @@ -105,6 +105,10 @@ impl Port {
}
}

pub fn ip(&self) -> &IpAddr {
&self.inner.ip
}

pub fn name(&self) -> &str {
&self.inner.name
}
Expand Down
67 changes: 59 additions & 8 deletions illumos-utils/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,76 @@
use crate::zone::ROUTE;
use crate::{execute, inner, output_to_exec_error, ExecutionError, PFEXEC};
use libc::ESRCH;
use std::net::Ipv6Addr;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};

/// Wraps commands for interacting with routing tables.
pub struct Route {}

pub enum Gateway {
Ipv4(Ipv4Addr),
Ipv6(Ipv6Addr),
}

#[cfg_attr(any(test, feature = "testing"), mockall::automock)]
impl Route {
pub fn ensure_default_route_with_gateway(
gateway: &Ipv6Addr,
gateway: Gateway,
) -> Result<(), ExecutionError> {
let inet;
let gw;
match gateway {
Gateway::Ipv4(addr) => {
inet = "-inet";
gw = addr.to_string();
}
Gateway::Ipv6(addr) => {
inet = "-inet6";
gw = addr.to_string();
}
}
// Add the desired route if it doesn't already exist
let destination = "default";
let mut cmd = std::process::Command::new(PFEXEC);
let cmd = cmd.args(&[ROUTE, "-n", "get", inet, destination, inet, &gw]);

let out =
cmd.output().map_err(|err| ExecutionError::ExecutionStart {
command: inner::to_string(cmd),
err,
})?;
match out.status.code() {
Some(0) => (),
// If the entry is not found in the table,
// the exit status of the command will be 3 (ESRCH).
// When that is the case, we'll add the route.
Some(ESRCH) => {
let mut cmd = std::process::Command::new(PFEXEC);
let cmd =
cmd.args(&[ROUTE, "add", inet, destination, inet, &gw]);
execute(cmd)?;
}
Some(_) | None => return Err(output_to_exec_error(cmd, &out)),
};
Ok(())
}

pub fn ensure_opte_route(
gateway: &Ipv4Addr,
iface: &String,
opte_ip: &IpAddr,
) -> Result<(), ExecutionError> {
// Add the desired route if it doesn't already exist
let mut cmd = std::process::Command::new(PFEXEC);
let cmd = cmd.args(&[
ROUTE,
"-n",
"get",
"-inet6",
destination,
"-inet6",
"-host",
&gateway.to_string(),
&opte_ip.to_string(),
"-interface",
"-ifp",
&iface.to_string(),
]);

let out =
Expand All @@ -45,10 +94,12 @@ impl Route {
let cmd = cmd.args(&[
ROUTE,
"add",
"-inet6",
destination,
"-inet6",
"-host",
&gateway.to_string(),
&opte_ip.to_string(),
"-interface",
"-ifp",
&iface.to_string(),
]);
execute(cmd)?;
}
Expand Down
7 changes: 6 additions & 1 deletion illumos-utils/src/running_zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ impl RunningZone {

/// Return references to the OPTE ports for this zone.
pub fn opte_ports(&self) -> impl Iterator<Item = &Port> {
self.inner.opte_ports.iter().map(|(port, _)| port)
self.inner.opte_ports()
}

/// Remove the OPTE ports on this zone from the port manager.
Expand Down Expand Up @@ -1130,6 +1130,11 @@ impl InstalledZone {
path.push("root/var/svc/profile/site.xml");
path
}

/// Returns references to the OPTE ports for this zone.
pub fn opte_ports(&self) -> impl Iterator<Item = &Port> {
self.opte_ports.iter().map(|(port, _)| port)
}
}

#[derive(Clone)]
Expand Down
6 changes: 4 additions & 2 deletions nexus/blueprint-execution/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ mod test {
use nexus_types::deployment::Policy;
use nexus_types::deployment::SledResources;
use nexus_types::deployment::ZpoolName;
use nexus_types::external_api::views::SledProvisionState;
use nexus_types::external_api::views::SledPolicy;
use nexus_types::external_api::views::SledState;
use nexus_types::internal_api::params::DnsConfigParams;
use nexus_types::internal_api::params::DnsConfigZone;
use nexus_types::internal_api::params::DnsRecord;
Expand Down Expand Up @@ -409,7 +410,8 @@ mod test {
.zip(possible_sled_subnets)
.map(|(sled_id, subnet)| {
let sled_resources = SledResources {
provision_state: SledProvisionState::Provisionable,
policy: SledPolicy::provisionable(),
state: SledState::Active,
zpools: BTreeSet::from([ZpoolName::from_str(&format!(
"oxp_{}",
Uuid::new_v4()
Expand Down
13 changes: 11 additions & 2 deletions nexus/blueprint-execution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use uuid::Uuid;

mod dns;
mod omicron_zones;
mod resource_allocation;

struct Sled {
id: Uuid,
Expand Down Expand Up @@ -69,6 +70,14 @@ where
"blueprint_id" => ?blueprint.id
);

resource_allocation::ensure_zone_resources_allocated(
&opctx,
datastore,
&blueprint.omicron_zones,
)
.await
.map_err(|err| vec![err])?;

let sleds_by_id: BTreeMap<Uuid, _> = datastore
.sled_list_all_batched(&opctx)
.await
Expand All @@ -82,9 +91,9 @@ where

dns::deploy_dns(
&opctx,
&datastore,
datastore,
String::from(nexus_label),
&blueprint,
blueprint,
&sleds_by_id,
)
.await
Expand Down
Loading

0 comments on commit 207fd37

Please sign in to comment.