huskies: merge 1200 story Low-disk warning: the fleet tells the operator before the disk takes it down
This commit is contained in:
@@ -168,6 +168,28 @@ fn status_to_stored(event: StatusEvent) -> Option<StoredEvent> {
|
||||
reason,
|
||||
timestamp_ms: now_ms,
|
||||
}),
|
||||
StatusEvent::DiskSpaceWarning {
|
||||
level,
|
||||
free_bytes,
|
||||
target_bytes,
|
||||
worktrees_bytes,
|
||||
host_id,
|
||||
} => Some(StoredEvent::DiskSpaceWarning {
|
||||
level,
|
||||
free_bytes,
|
||||
target_bytes,
|
||||
worktrees_bytes,
|
||||
host_id,
|
||||
timestamp_ms: now_ms,
|
||||
}),
|
||||
StatusEvent::DiskSpaceRecovered {
|
||||
free_bytes,
|
||||
host_id,
|
||||
} => Some(StoredEvent::DiskSpaceRecovered {
|
||||
free_bytes,
|
||||
host_id,
|
||||
timestamp_ms: now_ms,
|
||||
}),
|
||||
// Rate-limit events have no StoredEvent equivalent — skip them.
|
||||
StatusEvent::RateLimitWarning { .. } | StatusEvent::RateLimitHardBlock { .. } => None,
|
||||
}
|
||||
@@ -252,6 +274,36 @@ mod tests {
|
||||
assert!(status_to_stored(ev).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn status_to_stored_disk_space_warning() {
|
||||
let ev = StatusEvent::DiskSpaceWarning {
|
||||
level: "warn".into(),
|
||||
free_bytes: 45_000_000_000,
|
||||
target_bytes: 10_000_000_000,
|
||||
worktrees_bytes: 5_000_000_000,
|
||||
host_id: "sled-a".into(),
|
||||
};
|
||||
let stored = status_to_stored(ev).unwrap();
|
||||
assert!(matches!(
|
||||
stored,
|
||||
StoredEvent::DiskSpaceWarning { ref level, ref host_id, .. }
|
||||
if level == "warn" && host_id == "sled-a"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn status_to_stored_disk_space_recovered() {
|
||||
let ev = StatusEvent::DiskSpaceRecovered {
|
||||
free_bytes: 60_000_000_000,
|
||||
host_id: "sled-a".into(),
|
||||
};
|
||||
let stored = status_to_stored(ev).unwrap();
|
||||
assert!(matches!(
|
||||
stored,
|
||||
StoredEvent::DiskSpaceRecovered { ref host_id, .. } if host_id == "sled-a"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn status_to_stored_rate_limit_hard_block_is_none() {
|
||||
let ev = StatusEvent::RateLimitHardBlock {
|
||||
|
||||
Reference in New Issue
Block a user