Skip to content

Commit

Permalink
[sled-agent] Remove non self-assembling zone code (#6162)
Browse files Browse the repository at this point in the history
This commit removes all code that is no longer necessary now that the
self assembling zone work is finished.

Additionally, the `smf_helper` module has been moved to `illumos_utils`
where all the Illumos helper code lives.

Closes: #1898
  • Loading branch information
karencfv authored Jul 28, 2024
1 parent 9e58f1b commit 013df0a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 85 deletions.
1 change: 1 addition & 0 deletions illumos-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub mod opte;
pub mod route;
pub mod running_zone;
pub mod scf;
pub mod smf_helper;
pub mod svc;
pub mod svcadm;
pub mod vmm_reservoir;
Expand Down
55 changes: 1 addition & 54 deletions illumos-utils/src/running_zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::dladm::Etherstub;
use crate::link::{Link, VnicAllocator};
use crate::opte::{Port, PortTicket};
use crate::svc::wait_for_service;
use crate::zone::{AddressRequest, IPADM, ZONE_PREFIX};
use crate::zone::{AddressRequest, ZONE_PREFIX};
use crate::zpool::{PathInPool, ZpoolName};
use camino::{Utf8Path, Utf8PathBuf};
use camino_tempfile::Utf8TempDir;
Expand Down Expand Up @@ -487,65 +487,12 @@ impl RunningZone {
zone: zone.name.to_string(),
})?;

// TODO https://github.com/oxidecomputer/omicron/issues/1898:
// Remove all non-self assembling code

// If the zone is self-assembling, then SMF service(s) inside the zone
// will be creating the listen address for the zone's service(s),
// setting the appropriate ifprop MTU, and so on. The idea behind
// self-assembling zones is that once they boot there should be *no*
// zlogin required.

// Use the zone ID in order to check if /var/svc/profile/site.xml
// exists.
let id = Zones::id(&zone.name)
.await?
.ok_or_else(|| BootError::NoZoneId { zone: zone.name.clone() })?;
let site_profile_xml_exists =
std::path::Path::new(&zone.site_profile_xml_path()).exists();

let running_zone = RunningZone { id: Some(id), inner: zone };

if !site_profile_xml_exists {
// If the zone is not self-assembling, make sure the control vnic
// has an IP MTU of 9000 inside the zone.
const CONTROL_VNIC_MTU: usize = 9000;
let vnic = running_zone.inner.control_vnic.name().to_string();

let commands = vec![
vec![
IPADM.to_string(),
"create-if".to_string(),
"-t".to_string(),
vnic.clone(),
],
vec![
IPADM.to_string(),
"set-ifprop".to_string(),
"-t".to_string(),
"-p".to_string(),
format!("mtu={}", CONTROL_VNIC_MTU),
"-m".to_string(),
"ipv4".to_string(),
vnic.clone(),
],
vec![
IPADM.to_string(),
"set-ifprop".to_string(),
"-t".to_string(),
"-p".to_string(),
format!("mtu={}", CONTROL_VNIC_MTU),
"-m".to_string(),
"ipv6".to_string(),
vnic,
],
];

for args in &commands {
running_zone.run_cmd(args)?;
}
}

Ok(running_zone)
}

Expand Down
24 changes: 10 additions & 14 deletions sled-agent/src/smf_helper.rs → illumos-utils/src/smf_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
// 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/.

use illumos_utils::running_zone::RunningZone;
use crate::running_zone::RunningZone;
use crate::zone::SVCCFG;

#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("Failed to do '{intent}' by running command in zone: {err}")]
ZoneCommand {
intent: String,
#[source]
err: illumos_utils::running_zone::RunCommandError,
err: crate::running_zone::RunCommandError,
},
}

Expand Down Expand Up @@ -44,7 +45,7 @@ impl<'t> SmfHelper<'t> {
{
self.running_zone
.run_cmd(&[
illumos_utils::zone::SVCCFG,
SVCCFG,
"-s",
&self.default_smf_name,
"setprop",
Expand All @@ -70,7 +71,7 @@ impl<'t> SmfHelper<'t> {
{
self.running_zone
.run_cmd(&[
illumos_utils::zone::SVCCFG,
SVCCFG,
"-s",
&self.smf_name,
"addpropvalue",
Expand Down Expand Up @@ -98,7 +99,7 @@ impl<'t> SmfHelper<'t> {
{
self.running_zone
.run_cmd(&[
illumos_utils::zone::SVCCFG,
SVCCFG,
"-s",
&self.default_smf_name,
"addpropvalue",
Expand All @@ -124,7 +125,7 @@ impl<'t> SmfHelper<'t> {
{
self.running_zone
.run_cmd(&[
illumos_utils::zone::SVCCFG,
SVCCFG,
"-s",
&self.smf_name,
"addpg",
Expand All @@ -148,7 +149,7 @@ impl<'t> SmfHelper<'t> {
{
self.running_zone
.run_cmd(&[
illumos_utils::zone::SVCCFG,
SVCCFG,
"-s",
&self.smf_name,
"delpg",
Expand Down Expand Up @@ -176,7 +177,7 @@ impl<'t> SmfHelper<'t> {
match self
.running_zone
.run_cmd(&[
illumos_utils::zone::SVCCFG,
SVCCFG,
"-s",
&self.default_smf_name,
"delpropvalue",
Expand All @@ -202,12 +203,7 @@ impl<'t> SmfHelper<'t> {

pub fn refresh(&self) -> Result<(), Error> {
self.running_zone
.run_cmd(&[
illumos_utils::zone::SVCCFG,
"-s",
&self.default_smf_name,
"refresh",
])
.run_cmd(&[SVCCFG, "-s", &self.default_smf_name, "refresh"])
.map_err(|err| Error::ZoneCommand {
intent: format!(
"Refresh SMF manifest {}",
Expand Down
1 change: 0 additions & 1 deletion sled-agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ pub mod rack_setup;
pub mod server;
pub mod services;
mod sled_agent;
mod smf_helper;
mod storage_monitor;
mod swap_device;
mod updates;
Expand Down
9 changes: 0 additions & 9 deletions sled-agent/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,6 @@ impl OmicronZoneTypeExt for OmicronZoneConfig {
}
}

impl crate::smf_helper::Service for OmicronZoneType {
fn service_name(&self) -> String {
self.kind().service_prefix().to_owned()
}
fn smf_name(&self) -> String {
format!("svc:/oxide/{}", self.service_name())
}
}

#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
pub struct TimeSync {
/// The synchronization state of the sled, true when the system clock
Expand Down
10 changes: 3 additions & 7 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ use crate::params::{
ZoneBundleCause, ZoneBundleMetadata,
};
use crate::profile::*;
use crate::smf_helper::SmfHelper;
use crate::zone_bundle::BundleError;
use crate::zone_bundle::ZoneBundler;
use anyhow::anyhow;
Expand All @@ -55,6 +54,7 @@ use illumos_utils::running_zone::{
EnsureAddressError, InstalledZone, RunCommandError, RunningZone,
ZoneBuilderFactory,
};
use illumos_utils::smf_helper::SmfHelper;
use illumos_utils::zfs::ZONE_ZFS_RAMDISK_DATASET_MOUNTPOINT;
use illumos_utils::zone::AddressRequest;
use illumos_utils::zpool::{PathInPool, ZpoolName};
Expand Down Expand Up @@ -157,7 +157,7 @@ pub enum Error {
SledLocalZone(anyhow::Error),

#[error("Failed to issue SMF command: {0}")]
SmfCommand(#[from] crate::smf_helper::Error),
SmfCommand(#[from] illumos_utils::smf_helper::Error),

#[error("{}", display_zone_init_errors(.0))]
ZoneInitialize(Vec<(String, Box<Error>)>),
Expand Down Expand Up @@ -498,7 +498,7 @@ enum SwitchService {
SpSim,
}

impl crate::smf_helper::Service for SwitchService {
impl illumos_utils::smf_helper::Service for SwitchService {
fn service_name(&self) -> String {
match self {
SwitchService::ManagementGatewayService => "mgs",
Expand Down Expand Up @@ -1507,10 +1507,6 @@ impl ServiceManager {
ServiceBuilder::new("network/dns/client")
.add_instance(ServiceInstanceBuilder::new("default"));

// TODO(https://github.com/oxidecomputer/omicron/issues/1898):
//
// These zones are self-assembling -- after they boot, there should
// be no "zlogin" necessary to initialize.
match &request {
ZoneArgs::Omicron(OmicronZoneConfigLocal {
zone:
Expand Down

0 comments on commit 013df0a

Please sign in to comment.