ALPHA: wire is a tool to deploy nixos systems wire.althaea.zone/

add --handle-unreachable arg

+66 -1
+2
CHANGELOG.md
··· 16 16 `https://.../main.tar.gz`, etc). 17 17 - `--flake` is now an alias for `--path`. 18 18 - A terminal bell will be output if a sudo / ssh prompt is ever printed. 19 + - `--handle-unreachable` arg was added. You can use `--handle-unreachable ignore` to 20 + ignore unreachable nodes in the status of the deployment. 19 21 20 22 ### Fixed 21 23
+1
wire/cli/src/apply.rs
··· 108 108 modifiers, 109 109 reboot: args.reboot, 110 110 should_apply_locally, 111 + handle_unreachable: args.handle_unreachable.clone().into(), 111 112 }; 112 113 113 114 GoalExecutor::new(context)
+46 -1
wire/cli/src/cli.rs
··· 1 1 // SPDX-License-Identifier: AGPL-3.0-or-later 2 2 // Copyright 2024-2025 wire Contributors 3 3 4 + use clap::builder::PossibleValue; 4 5 use clap::crate_version; 5 6 use clap::{Args, Parser, Subcommand, ValueEnum}; 6 7 use clap_complete::Shell; ··· 8 9 use clap_verbosity_flag::InfoLevel; 9 10 use lib::SubCommandModifiers; 10 11 use lib::hive::Hive; 11 - use lib::hive::node::{Goal as HiveGoal, Name, SwitchToConfigurationGoal}; 12 + use lib::hive::node::{Goal as HiveGoal, HandleUnreachable, Name, SwitchToConfigurationGoal}; 12 13 13 14 use std::io::IsTerminal; 14 15 use std::{ ··· 92 93 number_range(s, 1, usize::MAX) 93 94 } 94 95 96 + #[derive(Clone)] 97 + pub enum HandleUnreachableArg { 98 + Ignore, 99 + FailNode, 100 + } 101 + 102 + impl Display for HandleUnreachableArg { 103 + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { 104 + match self { 105 + Self::Ignore => write!(f, "ignore"), 106 + Self::FailNode => write!(f, "fail-node"), 107 + } 108 + } 109 + } 110 + 111 + impl clap::ValueEnum for HandleUnreachableArg { 112 + fn value_variants<'a>() -> &'a [Self] { 113 + &[Self::Ignore, Self::FailNode] 114 + } 115 + 116 + fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> { 117 + match self { 118 + Self::Ignore => Some(PossibleValue::new("ignore")), 119 + Self::FailNode => Some(PossibleValue::new("fail-node")), 120 + } 121 + } 122 + } 123 + 124 + impl From<HandleUnreachableArg> for HandleUnreachable { 125 + fn from(value: HandleUnreachableArg) -> Self { 126 + match value { 127 + HandleUnreachableArg::Ignore => Self::Ignore, 128 + HandleUnreachableArg::FailNode => Self::FailNode, 129 + } 130 + } 131 + } 132 + 95 133 #[derive(Args)] 96 134 pub struct ApplyArgs { 97 135 #[arg(value_enum, default_value_t)] ··· 118 156 /// Reboot the nodes after activation 119 157 #[arg(short, long, default_value_t = false)] 120 158 pub reboot: bool, 159 + 160 + /// How to handle an unreachable node in the ping step. 161 + /// 162 + /// This only effects the ping step. 163 + /// wire will still fail the node if it becomes unreachable after activation 164 + #[arg(long, default_value_t = HandleUnreachableArg::FailNode)] 165 + pub handle_unreachable: HandleUnreachableArg, 121 166 122 167 /// Unconditionally accept SSH host keys [!!] 123 168 ///
+17
wire/lib/src/hive/node.rs
··· 113 113 goal: Goal::SwitchToConfiguration(SwitchToConfigurationGoal::Switch), 114 114 reboot: false, 115 115 should_apply_locally: false, 116 + handle_unreachable: HandleUnreachable::default(), 116 117 } 117 118 } 118 119 } ··· 275 276 fn should_execute(&self, context: &Context) -> bool; 276 277 } 277 278 279 + // may include other options such as FailAll in the future 280 + #[non_exhaustive] 281 + #[derive(Clone, Default)] 282 + pub enum HandleUnreachable { 283 + Ignore, 284 + #[default] 285 + FailNode, 286 + } 287 + 278 288 #[derive(Default)] 279 289 pub struct StepState { 280 290 pub evaluation: Option<Derivation>, ··· 293 303 pub goal: Goal, 294 304 pub reboot: bool, 295 305 pub should_apply_locally: bool, 306 + pub handle_unreachable: HandleUnreachable, 296 307 } 297 308 298 309 #[enum_dispatch(ExecuteStep)] ··· 428 439 }) { 429 440 // discard error from cleanup 430 441 let _ = CleanUp.execute(&mut self.context).await; 442 + 443 + if matches!(step, Step::Ping(..)) 444 + && matches!(self.context.handle_unreachable, HandleUnreachable::Ignore) 445 + { 446 + return Ok(()); 447 + } 431 448 432 449 return Err(err); 433 450 }