Preserve millisecond health admission time
This commit is contained in:
parent
7a41cb54bc
commit
6f107e1b9d
1 changed files with 17 additions and 5 deletions
22
src/main.rs
22
src/main.rs
|
|
@ -6481,11 +6481,14 @@ fn command_output_path(kind: &str) -> Result<PathBuf> {
|
|||
}
|
||||
|
||||
fn timestamp() -> Result<String> {
|
||||
let seconds = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.context("system clock is before Unix epoch")?
|
||||
.as_secs();
|
||||
Ok(format!("unix:{seconds}"))
|
||||
timestamp_from_unix_millis(unix_epoch_millis()?)
|
||||
}
|
||||
|
||||
fn timestamp_from_unix_millis(millis: u64) -> Result<String> {
|
||||
let millis = i64::try_from(millis).context("system clock milliseconds exceeded i64")?;
|
||||
let timestamp = chrono::DateTime::from_timestamp_millis(millis)
|
||||
.ok_or_else(|| anyhow!("system clock milliseconds are out of range"))?;
|
||||
Ok(timestamp.to_rfc3339_opts(chrono::SecondsFormat::Millis, true))
|
||||
}
|
||||
|
||||
fn unix_epoch_millis() -> Result<u64> {
|
||||
|
|
@ -6566,6 +6569,15 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_timestamp_preserves_the_health_admission_millisecond() {
|
||||
let timestamp = timestamp_from_unix_millis(42_123).unwrap();
|
||||
|
||||
assert_eq!(timestamp, "1970-01-01T00:00:42.123Z");
|
||||
assert_eq!(parse_timestamp_millis(×tamp), Some(42_123));
|
||||
assert_eq!(parse_admission_ceiling_millis(×tamp), Some(42_123));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deployable_source_authority_ignores_documentation_only_commits() {
|
||||
let root = tempfile::tempdir().unwrap();
|
||||
|
|
|
|||
Loading…
Reference in a new issue