Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ build: .cargo/config version-vars
OPENSSL_LIB_DIR=$(shell dirname `whereis libssl.a | cut -d" " -f2`) \
OPENSSL_INCLUDE_DIR=/usr/include/openssl \
TRIDENT_VERSION="$(TRIDENT_CARGO_VERSION)-dev.$(GIT_COMMIT)" \
cargo build --release --features dangerous-options
cargo build --release --features dangerous-options --target x86_64-unknown-linux-musl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, the servicing env is azl3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The *-unknown-linux-musl part makes it produce a statically linked binary that can run on any Linux distribution without having to worry about glibc version conflicts

@mkdir -p bin

.PHONY: format
Expand Down Expand Up @@ -149,7 +149,7 @@ artifacts/osmodifier: packaging/docker/Dockerfile-osmodifier.azl3

bin/trident: build
@mkdir -p bin
@cp -u target/release/trident bin/
@cp -u target/x86_64-unknown-linux-musl/release/trident bin/

# This will do a proper build on azl3, exactly as the pipelines would, with the custom registry and all.
bin/trident-rpms-azl3.tar.gz: packaging/docker/Dockerfile.full packaging/systemd/*.service packaging/rpm/trident.spec artifacts/osmodifier packaging/selinux-policy-trident/* version-vars
Expand Down
4 changes: 4 additions & 0 deletions crates/osutils/src/chroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ impl Chroot {
return Err(TridentError::new(ServicingError::EnterChroot));
}

let _ = fs::create_dir(path.join("dev"));
let _ = fs::create_dir(path.join("proc"));
let _ = fs::create_dir(path.join("sys"));

// Mount special dirs.
debug!("Mounting special directories");
let mounts = vec![
Expand Down
2 changes: 2 additions & 0 deletions crates/trident/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ tracing-subscriber = { version = "0.3.19", features = ["json"] }
url = { version = "2.5.4", features = ["serde"] }
uuid = { version = "1.11.0", features = ["v4", "serde"] }

openssl = { version = "0.10", features = ["vendored"] }

sysdefs = { path = "../sysdefs" }
osutils = { path = "../osutils" }
trident_api = { path = "../trident_api" }
Expand Down
4 changes: 4 additions & 0 deletions crates/trident/src/engine/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ impl Subsystem for BootSubsystem {
debug!("Skipping grub configuration because UKI is in use");
return Ok(());
}
if ctx.spec.storage.raw_cosi {
debug!("Skipping grub configuration because raw COSI is in use");
return Ok(());
}

grub::update_configs(ctx, Path::new(OS_MODIFIER_NEWROOT_PATH))
.structured(ServicingError::UpdateGrubConfigs)?;
Expand Down
6 changes: 6 additions & 0 deletions crates/trident/src/engine/clean_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ pub(crate) fn finalize_clean_install(

// On clean install, need to verify that AZLA entry exists in /mnt/newroot/boot/efi
let esp_path = join_relative(new_root.path(), ESP_MOUNT_POINT_PATH);

if ctx.spec.storage.raw_cosi {
new_root.unmount_all()?;
return Ok(ExitKind::NeedsReboot);
}

bootentries::create_and_update_boot_variables(&ctx, &esp_path)?;

debug!(
Expand Down
6 changes: 6 additions & 0 deletions crates/trident/src/engine/newroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@ impl NewrootMount {

debug!("Mounting tmpfs to '{}'", target_path_full.display());

if !target_path_full.exists() {
fs::create_dir(&target_path_full).structured(ServicingError::MountNewrootSpecialDir {
dir: target_path_full.clone().to_string_lossy().to_string(),
})?;
}

// Do the actual tmpfs mount
MountBuilder::default()
.fstype("tmpfs")
Expand Down
1 change: 1 addition & 0 deletions crates/trident/src/engine/storage/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ fn block_devices_needing_fs_creation(
FileSystemData::Image(ifs)
if ctx.servicing_type == ServicingType::CleanInstall
&& fs.is_esp()
&& !ctx.spec.storage.raw_cosi
&& !ctx
.storage_graph
.is_adopted(&ifs.device_id)
Expand Down
13 changes: 11 additions & 2 deletions crates/trident/src/engine/storage/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,20 @@ pub(super) fn deploy_images(ctx: &EngineContext) -> Result<(), TridentError> {
"No OS image available for deployment",
))?;

let images = os_img
let mut images = os_img
.filesystems()
.map(|fs| (fs.mount_point.to_owned(), fs))
.collect::<HashMap<_, _>>();

if ctx.spec.storage.raw_cosi {
images.insert(
"/boot/efi".into(),
os_img
.esp_filesystem()
.structured(InternalError::Internal("COSI doesn't have ESP"))?,
);
}

// Now, deploy the filesystems sourced from the OS image
for (id, mpp, fs) in fs_from_img {
let image = images
Expand Down Expand Up @@ -136,7 +145,7 @@ fn filesystems_from_image(
continue;
};

if img_fs.is_esp() {
if img_fs.is_esp() && !ctx.spec.storage.raw_cosi {
debug!(
"Skipping deployment of filesystem [{}] sourced from OS Image, as it is the ESP.",
filesystem.description()
Expand Down
5 changes: 3 additions & 2 deletions crates/trident/src/subsystems/esp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ impl Subsystem for EspSubsystem {
// Perform file-based deployment of ESP images, if needed, after filesystems have been
// mounted and initialized.

// Deploy ESP image
deploy_esp(ctx, mount_path).structured(ServicingError::DeployESPImages)?;
if !ctx.spec.storage.raw_cosi {
deploy_esp(ctx, mount_path).structured(ServicingError::DeployESPImages)?;
}

Ok(())
}
Expand Down
4 changes: 4 additions & 0 deletions crates/trident/src/subsystems/initrd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ impl Subsystem for InitrdSubsystem {
debug!("Skipping initrd regeneration because UKI is in use");
return Ok(());
}
if ctx.spec.storage.raw_cosi {
debug!("Skipping initrd regeneration because raw COSI is in use");
return Ok(());
}

// We could autodetect configurations on the fly, but for more predictable
// behavior and speedier subsequent boots, we will regenerate the host-specific initrd
Expand Down
4 changes: 4 additions & 0 deletions crates/trident/src/subsystems/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ impl Subsystem for StorageSubsystem {
debug!("Skipping storage configuration because UKI root-verity is in use");
return Ok(());
}
if ctx.spec.storage.raw_cosi {
debug!("Skipping storage configuration because raw COSI is in use");
return Ok(());
}

fstab::generate_fstab(ctx, Path::new(fstab::DEFAULT_FSTAB_PATH)).structured(
ServicingError::GenerateFstab {
Expand Down
4 changes: 4 additions & 0 deletions crates/trident/src/subsystems/storage/osimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ pub fn validate_host_config(ctx: &EngineContext) -> Result<(), TridentError> {
return Ok(());
};

if ctx.spec.storage.raw_cosi {
return Ok(());
}

debug!("Validating Host Configuration filesystems against OS image");
validate_filesystems(os_image, ctx)?;

Expand Down
4 changes: 4 additions & 0 deletions crates/trident_api/src/config/host/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ pub struct Storage {
)
)]
pub swap: Vec<Swap>,

/// Source the storage configuration from the COSI.
#[serde(default, skip_serializing_if = "is_default")]
pub raw_cosi: bool,
}

impl Storage {
Expand Down
Loading