Skip to content

Commit 0d3456a

Browse files
committed
propolis, aws: disable sync on ephemeral root pools
1 parent c45f253 commit 0d3456a

File tree

6 files changed

+212
-105
lines changed

6 files changed

+212
-105
lines changed

agent/src/main.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,22 @@ fn zfs_get(dataset: &str, prop: &str) -> Result<String> {
891891
Ok(l[0].to_string())
892892
}
893893

894+
fn zfs_set(dataset: &str, prop: &str, value: &str) -> Result<()> {
895+
let out = Command::new("/sbin/zfs")
896+
.arg("set")
897+
.arg(format!("{prop}={value}"))
898+
.arg(dataset)
899+
.env_clear()
900+
.current_dir("/")
901+
.output()?;
902+
903+
if !out.status.success() {
904+
bail!("zfs set {prop:?}={value:?} {dataset:?}: {}", out.info());
905+
}
906+
907+
Ok(())
908+
}
909+
894910
fn zfs_create_volume(dataset: &str, size_mb: u32) -> Result<()> {
895911
let out = Command::new("/sbin/zfs")
896912
.arg("create")
@@ -948,6 +964,33 @@ fn ensure_dump_device(mbsz: u32) -> Result<()> {
948964
Ok(())
949965
}
950966

967+
#[cfg(target_os = "illumos")]
968+
fn rpool_disable_sync() -> Result<()> {
969+
if !zfs_exists("rpool")? {
970+
/*
971+
* If the system does not have a root pool, there is no point trying to
972+
* disable sync. Note that technically a system could boot from a pool
973+
* with any name, not just "rpool"; in practice the images we use on
974+
* buildomat systems all use "rpool" today.
975+
*/
976+
println!("skipping sync disable as system has no rpool");
977+
} else {
978+
zfs_set("rpool", "sync", "disabled")?;
979+
980+
println!("sync was disabled on rpool!");
981+
}
982+
983+
Ok(())
984+
}
985+
986+
#[cfg(not(target_os = "illumos"))]
987+
fn rpool_disable_sync() -> Result<()> {
988+
/*
989+
* Sure, whatever you say!
990+
*/
991+
Ok(())
992+
}
993+
951994
enum Stage {
952995
Ready,
953996
Download(mpsc::Receiver<download::Activity>),
@@ -1163,6 +1206,7 @@ async fn cmd_run(mut l: Level<()>) -> Result<()> {
11631206
let mut dump_device_configured = false;
11641207
let mut post_diag_script: Option<String> = None;
11651208
let mut pre_diag_done = false;
1209+
let mut sync_disabled = false;
11661210

11671211
/*
11681212
* Check for a file containing a description of the job we are running. If
@@ -1224,6 +1268,14 @@ async fn cmd_run(mut l: Level<()>) -> Result<()> {
12241268
dump_device_configured = true;
12251269
}
12261270
}
1271+
1272+
if !sync_disabled && md.rpool_disable_sync() {
1273+
if let Err(e) = rpool_disable_sync() {
1274+
println!("ERROR: disabling sync on rpool: {e}");
1275+
}
1276+
1277+
sync_disabled = true;
1278+
}
12271279
}
12281280

12291281
if do_ping {

factory/aws/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl Central {
7272
* Allow the per-target diagnostic configuration to override the base
7373
* diagnostic configuration.
7474
*/
75-
Ok(self.config.diag.apply_overrides(&t.diag)?.build()?)
75+
Ok(self.config.diag.apply_overrides(&t.diag).build()?)
7676
}
7777
}
7878

factory/lab/src/worker.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,12 @@ async fn lab_worker_one(log: &Logger, c: &Central) -> Result<()> {
290290
dump_to_rpool: None,
291291
post_job_diagnostic_script: None,
292292
pre_job_diagnostic_script: None,
293+
/*
294+
* The lab worker currently boots
295+
* chiefly UFS ramdisks and does not
296+
* provide a ZFS pool backed by a disk.
297+
*/
298+
rpool_disable_sync: Some(false),
293299
},
294300
)))
295301
})

factory/propolis/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl Central {
3939
* Allow the per-target diagnostic configuration to override the base
4040
* diagnostic configuration.
4141
*/
42-
Ok(self.config.diag.apply_overrides(&t.diag)?.build()?)
42+
Ok(self.config.diag.apply_overrides(&t.diag).build()?)
4343
}
4444
}
4545

0 commit comments

Comments
 (0)