Skip to content

Commit 609bd77

Browse files
authored
Sync support bundle data during finalization (#8723)
1 parent 46b7f4e commit 609bd77

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

sled-agent/src/support_bundle/storage.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,23 @@ impl<'a> SupportBundleManager<'a> {
836836
}
837837

838838
// Finalize the transfer of the bundle
839-
tokio::fs::rename(support_bundle_path_tmp, support_bundle_path).await?;
839+
tokio::fs::rename(&support_bundle_path_tmp, &support_bundle_path)
840+
.await?;
841+
842+
// Sync the data (and parent directory) to durable storage.
843+
//
844+
// The ordering of these "sync" calls doesn't matter *too* much, because
845+
// Nexus won't mark the support bundle as ready unless the call to
846+
// "finalize" returns successfully. If we crash while any of these files
847+
// are only partially written, the checksum would prevent corrupted
848+
// bundles from being used.
849+
tokio::fs::File::open(&support_bundle_path).await?.sync_all().await?;
850+
if let Some(parent) = support_bundle_path.parent() {
851+
// This really should never be "None"; there will always be a parent
852+
// directory.
853+
tokio::fs::File::open(parent).await?.sync_all().await?;
854+
}
855+
840856
return Ok(metadata);
841857
}
842858

0 commit comments

Comments
 (0)