|
6 | 6 |
|
7 | 7 | use anyhow::{Context, anyhow, bail};
|
8 | 8 | use camino::{Utf8Path, Utf8PathBuf};
|
| 9 | +use chrono::{DateTime, Utc}; |
9 | 10 | use clap::{ArgAction, ValueEnum};
|
10 | 11 | use clap::{Args, Parser, Subcommand};
|
11 | 12 | use daft::Diffable;
|
@@ -1077,6 +1078,27 @@ enum SetArgs {
|
1077 | 1078 | },
|
1078 | 1079 | /// planner chicken switches
|
1079 | 1080 | ChickenSwitches(SetChickenSwitchesArgs),
|
| 1081 | + /// timestamp for ignoring impossible MGS updates |
| 1082 | + IgnoreImpossibleMgsUpdatesSince { |
| 1083 | + since: SetIgnoreImpossibleMgsUpdatesSinceArgs, |
| 1084 | + }, |
| 1085 | +} |
| 1086 | + |
| 1087 | +#[derive(Debug, Clone)] |
| 1088 | +struct SetIgnoreImpossibleMgsUpdatesSinceArgs(DateTime<Utc>); |
| 1089 | + |
| 1090 | +impl FromStr for SetIgnoreImpossibleMgsUpdatesSinceArgs { |
| 1091 | + type Err = anyhow::Error; |
| 1092 | + |
| 1093 | + fn from_str(s: &str) -> Result<Self, Self::Err> { |
| 1094 | + if s.eq_ignore_ascii_case("now") { |
| 1095 | + return Ok(Self(Utc::now())); |
| 1096 | + } |
| 1097 | + if let Ok(datetime) = humantime::parse_rfc3339(s) { |
| 1098 | + return Ok(Self(datetime.into())); |
| 1099 | + } |
| 1100 | + bail!("invalid timestamp: expected `now` or an RFC3339 timestamp") |
| 1101 | + } |
1080 | 1102 | }
|
1081 | 1103 |
|
1082 | 1104 | #[derive(Debug, Args)]
|
@@ -2394,6 +2416,16 @@ fn cmd_set(
|
2394 | 2416 | )
|
2395 | 2417 | }
|
2396 | 2418 | }
|
| 2419 | + SetArgs::IgnoreImpossibleMgsUpdatesSince { since } => { |
| 2420 | + state |
| 2421 | + .system_mut() |
| 2422 | + .description_mut() |
| 2423 | + .set_ignore_impossible_mgs_updates_since(since.0); |
| 2424 | + format!( |
| 2425 | + "ignoring impossible MGS updates since {}", |
| 2426 | + humantime::format_rfc3339_millis(since.0.into()) |
| 2427 | + ) |
| 2428 | + } |
2397 | 2429 | };
|
2398 | 2430 |
|
2399 | 2431 | sim.commit_and_bump(format!("reconfigurator-cli set: {}", rv), state);
|
|
0 commit comments