1use std::{env::current_dir, os::unix::fs::symlink, path::PathBuf, str::FromStr, time::Duration};23use anyhow::{anyhow, bail, Result};4use clap::{Parser, ValueEnum};5use fleet_base::{6 host::{Config, ConfigHost},7 opts::FleetOpts,8};9use itertools::Itertools as _;10use nix_eval::{nix_go, NixBuildBatch};11use tokio::{task::LocalSet, time::sleep};12use tracing::{error, field, info, info_span, warn, Instrument};1314#[derive(Parser)]15pub struct Deploy {16 17 #[clap(long)]18 disable_rollback: bool,19 20 action: DeployAction,21}2223#[derive(ValueEnum, Clone, Copy)]24enum DeployAction {25 26 Upload,27 28 Test,29 30 Boot,31 32 Switch,33}3435impl DeployAction {36 pub(crate) fn name(&self) -> Option<&'static str> {37 match self {38 Self::Upload => None,39 Self::Test => Some("test"),40 Self::Boot => Some("boot"),41 Self::Switch => Some("switch"),42 }43 }44 pub(crate) fn should_switch_profile(&self) -> bool {45 matches!(self, Self::Switch | Self::Boot)46 }47 pub(crate) fn should_activate(&self) -> bool {48 matches!(self, Self::Switch | Self::Test | Self::Boot)49 }50 pub(crate) fn should_create_rollback_marker(&self) -> bool {51 52 53 !matches!(self, Self::Upload)54 }55 pub(crate) fn should_schedule_rollback_run(&self) -> bool {56 matches!(self, Self::Switch | Self::Test)57 }58}5960#[derive(Parser, Clone)]61pub struct BuildSystems {62 63 64 #[clap(long, default_value = "toplevel")]65 build_attr: String,66}6768struct Generation {69 id: u32,70 current: bool,71 datetime: String,72}7374fn parse_generation_line(g: &str) -> Option<Generation> {75 let mut parts = g.split_whitespace();76 let id = parts.next()?;77 let id: u32 = id.parse().ok()?;78 let date = parts.next()?;79 let time = parts.next()?;80 let current = if let Some(current) = parts.next() {81 if current == "(current)" {82 Some(true)83 } else {84 None85 }86 } else {87 Some(false)88 };89 let current = current?;90 if parts.next().is_some() {91 warn!("unexpected text after generation: {g}");92 }93 Some(Generation {94 id,95 current,96 datetime: format!("{date} {time}"),97 })98}99100async fn get_current_generation(host: &ConfigHost) -> Result<Generation> {101 let mut cmd = host.cmd("nix-env").await?;102 cmd.comparg("--profile", "/nix/var/nix/profiles/system")103 .arg("--list-generations");104 105 let data = cmd.sudo().run_string().await?;106 let generations = data107 .split('\n')108 .map(|e| e.trim())109 .filter(|&l| !l.is_empty())110 .filter_map(|g| {111 let gen = parse_generation_line(g);112 if gen.is_none() {113 warn!("bad generation: {g}");114 }115 gen116 })117 .collect::<Vec<_>>();118 let current = generations119 .into_iter()120 .filter(|g| g.current)121 .at_most_one()122 .map_err(|_e| anyhow!("bad list-generations output"))?123 .ok_or_else(|| anyhow!("failed to find generation"))?;124 Ok(current)125}126127async fn deploy_task(128 action: DeployAction,129 host: &ConfigHost,130 built: PathBuf,131 specialisation: Option<String>,132 disable_rollback: bool,133) -> Result<()> {134 let mut failed = false;135136 137 138 139 140 141 if !disable_rollback && action.should_create_rollback_marker() {142 let _span = info_span!("preparing").entered();143 info!("preparing for rollback");144 let generation = get_current_generation(host).await?;145 info!(146 "rollback target would be {} {}",147 generation.id, generation.datetime148 );149 {150 let mut cmd = host.cmd("sh").await?;151 cmd.arg("-c").arg(format!("mark=$(mktemp -p /etc -t fleet_rollback_marker.XXXXX) && echo -n {} > $mark && mv --no-clobber $mark /etc/fleet_rollback_marker", generation.id));152 if let Err(e) = cmd.sudo().run().await {153 error!("failed to set rollback marker: {e}");154 failed = true;155 }156 }157 158 159 160 161 162163 164 165 166 167 if action.should_schedule_rollback_run() {168 let mut cmd = host.cmd("systemd-run").await?;169 cmd.comparg("--on-active", "3min")170 .comparg("--unit", "rollback-watchdog-run")171 .arg("systemctl")172 .arg("start")173 .arg("rollback-watchdog.service");174 if let Err(e) = cmd.sudo().run().await {175 error!("failed to schedule rollback run: {e}");176 failed = true;177 }178 }179 }180181 if action.should_switch_profile() && !failed {182 info!("switching system profile generation");183 184 185 let mut cmd = host.cmd("nix").await?;186 cmd.arg("build");187 cmd.comparg("--profile", "/nix/var/nix/profiles/system");188 cmd.arg(&built);189 if let Err(e) = cmd.sudo().run_nix().await {190 error!("failed to switch system profile generation: {e}");191 failed = true;192 }193 }194195 196197 if action.should_activate() && !failed {198 let _span = info_span!("activating").entered();199 info!("executing activation script");200 let specialised = if let Some(specialisation) = specialisation {201 let mut specialised = built.join("specialisation");202 specialised.push(specialisation);203 specialised204 } else {205 built.clone()206 };207 let switch_script = specialised.join("bin/switch-to-configuration");208 let mut cmd = host.cmd(switch_script).in_current_span().await?;209 cmd.arg(action.name().expect("upload.should_activate == false"));210 if let Err(e) = cmd.sudo().run().in_current_span().await {211 error!("failed to activate: {e}");212 failed = true;213 }214 }215 if action.should_create_rollback_marker() {216 if !disable_rollback {217 if failed {218 if action.should_schedule_rollback_run() {219 info!("executing rollback");220 if let Err(e) = host221 .systemctl_start("rollback-watchdog.service")222 .instrument(info_span!("rollback"))223 .await224 {225 error!("failed to trigger rollback: {e}")226 }227 }228 } else {229 info!("trying to mark upgrade as successful");230 if let Err(e) = host231 .rm_file("/etc/fleet_rollback_marker", true)232 .in_current_span()233 .await234 {235 error!("failed to remove rollback marker. This is bad, as the system will be rolled back by watchdog: {e}")236 }237 }238 info!("disarming watchdog, just in case");239 if let Err(_e) = host.systemctl_stop("rollback-watchdog.timer").await {240 241 }242 if action.should_schedule_rollback_run() {243 if let Err(e) = host.systemctl_stop("rollback-watchdog-run.timer").await {244 error!("failed to disarm rollback run: {e}");245 }246 }247 } else if let Err(_e) = host248 .rm_file("/etc/fleet_rollback_marker", true)249 .in_current_span()250 .await251 {252 253 }254 }255 Ok(())256}257258async fn build_task(259 config: Config,260 hostname: String,261 build_attr: &str,262 batch: Option<NixBuildBatch>,263) -> Result<PathBuf> {264 info!("building");265 let host = config.host(&hostname).await?;266 267 let nixos = host.nixos_config().await?;268 let drv = nix_go!(nixos.system.build[{ build_attr }]);269 let outputs = drv.build_maybe_batch(batch).await?;270 let out_output = outputs271 .get("out")272 .ok_or_else(|| anyhow!("system build should produce \"out\" output"))?;273274 {275 info!("adding gc root");276 let mut cmd = config.local_host().cmd("nix").await?;277 cmd.arg("build")278 .comparg(279 "--profile",280 format!(281 "/nix/var/nix/profiles/{}-{hostname}",282 config.data().gc_root_prefix283 ),284 )285 .arg(out_output);286 cmd.sudo().run_nix().await?;287 }288289 Ok(out_output.clone())290}291292impl BuildSystems {293 pub async fn run(self, config: &Config, opts: &FleetOpts) -> Result<()> {294 let hosts = opts.filter_skipped(config.list_hosts().await?).await?;295 let set = LocalSet::new();296 let build_attr = self.build_attr.clone();297 let batch = (hosts.len() > 1).then(|| {298 config299 .nix_session300 .new_build_batch("build-hosts".to_string())301 });302 for host in hosts {303 let config = config.clone();304 let span = info_span!("build", host = field::display(&host.name));305 let hostname = host.name;306 let build_attr = build_attr.clone();307 let batch = batch.clone();308 set.spawn_local(309 (async move {310 let built = match build_task(config, hostname.clone(), &build_attr, batch).await311 {312 Ok(path) => path,313 Err(e) => {314 error!("failed to deploy host: {}", e);315 return;316 }317 };318 319 let mut out = current_dir().expect("cwd exists");320 out.push(format!("built-{}", hostname));321322 info!("linking iso image to {:?}", out);323 if let Err(e) = symlink(built, out) {324 error!("failed to symlink: {e}")325 }326 })327 .instrument(span),328 );329 }330 drop(batch);331 set.await;332 Ok(())333 }334}335336#[derive(Clone, PartialEq, Copy)]337enum DeployKind {338 339 UpgradeToFleet,340 341 Fleet,342}343impl FromStr for DeployKind {344 type Err = anyhow::Error;345 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {346 match s {347 "upgrade-to-fleet" => Ok(Self::UpgradeToFleet),348 "fleet" => Ok(Self::Fleet),349 v => bail!("unknown deploy_kind: {v}; expected on of \"upgrade-to-fleet\", \"fleet\""),350 }351 }352}353354impl Deploy {355 pub async fn run(self, config: &Config, opts: &FleetOpts) -> Result<()> {356 let hosts = opts.filter_skipped(config.list_hosts().await?).await?;357 let set = LocalSet::new();358 let batch = (hosts.len() > 1).then(|| {359 config360 .nix_session361 .new_build_batch("deploy-hosts".to_string())362 });363 for host in hosts.into_iter() {364 let config = config.clone();365 let span = info_span!("deploy", host = field::display(&host.name));366 let hostname = host.name.clone();367 let local_host = config.local_host();368 let opts = opts.clone();369 let batch = batch.clone();370 let mut deploy_kind: Option<DeployKind> =371 opts.action_attr(&host, "deploy_kind").await?;372373 set.spawn_local(374 (async move {375 let built =376 match build_task(config.clone(), hostname.clone(), "toplevel", batch).await377 {378 Ok(path) => path,379 Err(e) => {380 error!("failed to build host system closure: {}", e);381 return;382 }383 };384 if deploy_kind == None {385 let is_fleet_managed = match host.file_exists("/etc/FLEET_HOST").await {386 Ok(v) => v,387 Err(e) => {388 error!("failed to query remote system kind: {}", e);389 return;390 },391 };392 if !is_fleet_managed {393 error!(indoc::indoc!{"394 host is not marked as managed by fleet395 if you're not trying to lustrate/install system from scratch,396 you should either397 1. manually create /etc/FLEET_HOST file on the target host,398 2. use ?deploy_kind=fleet host argument if you're upgrading from older version of fleet399 3. use ?deploy_kind=upgrade_to_fleet if you're upgrading from plain nixos to fleet-managed nixos400 "});401 return;402 }403 deploy_kind = Some(DeployKind::Fleet);404 }405 let deploy_kind = deploy_kind.expect("deploy_kind is set");406407 408 let mut disable_rollback = self.disable_rollback;409 if !disable_rollback && deploy_kind != DeployKind::Fleet {410 warn!("disabling rollback, as not supported by non-fleet deployment kinds");411 disable_rollback = true;412 }413414 if !opts.is_local(&hostname) {415 info!("uploading system closure");416 {417 418 419 420 421 422 let Ok(mut sign) = local_host.cmd("nix").await else {423 error!("failed to setup local");424 return;425 };426 427 sign.arg("store")428 .arg("sign")429 .comparg("--key-file", "/etc/nix/private-key")430 .arg("-r")431 .arg(&built);432 if let Err(e) = sign.sudo().run_nix().await {433 warn!("failed to sign store paths: {e}");434 };435 }436 let mut tries = 0;437 loop {438 match host.remote_derivation(&built).await {439 Ok(remote) => {440 assert!(remote == built, "CA derivations aren't implemented");441 break;442 }443 Err(e) if tries < 3 => {444 tries += 1;445 warn!("copy failure ({}/3): {}", tries, e);446 sleep(Duration::from_millis(5000)).await;447 }448 Err(e) => {449 error!("upload failed: {e}");450 return;451 }452 }453 }454 }455 if let Err(e) = deploy_task(456 self.action,457 &host,458 built,459 if let Ok(v) = opts.action_attr(&host, "specialisation").await {460 v461 } else {462 error!("unreachable? failed to get specialization");463 return;464 },465 disable_rollback,466 )467 .await468 {469 error!("activation failed: {e}");470 }471 })472 .instrument(span),473 );474 }475 drop(batch);476 set.await;477 Ok(())478 }479}
1use std::{env::current_dir, os::unix::fs::symlink, path::PathBuf, time::Duration};23use anyhow::{anyhow, bail, Result};4use clap::{Parser, ValueEnum};5use fleet_base::{6 host::{Config, ConfigHost, DeployKind},7 opts::FleetOpts,8};9use itertools::Itertools as _;10use nix_eval::{nix_go, NixBuildBatch};11use tokio::{task::LocalSet, time::sleep};12use tracing::{error, field, info, info_span, warn, Instrument};1314#[derive(Parser)]15pub struct Deploy {16 17 #[clap(long)]18 disable_rollback: bool,19 20 action: DeployAction,21}2223#[derive(ValueEnum, Clone, Copy)]24enum DeployAction {25 26 Upload,27 28 Test,29 30 Boot,31 32 Switch,33}3435impl DeployAction {36 pub(crate) fn name(&self) -> Option<&'static str> {37 match self {38 Self::Upload => None,39 Self::Test => Some("test"),40 Self::Boot => Some("boot"),41 Self::Switch => Some("switch"),42 }43 }44 pub(crate) fn should_switch_profile(&self) -> bool {45 matches!(self, Self::Switch | Self::Boot)46 }47 pub(crate) fn should_activate(&self) -> bool {48 matches!(self, Self::Switch | Self::Test | Self::Boot)49 }50 pub(crate) fn should_create_rollback_marker(&self) -> bool {51 52 53 !matches!(self, Self::Upload)54 }55 pub(crate) fn should_schedule_rollback_run(&self) -> bool {56 matches!(self, Self::Switch | Self::Test)57 }58}5960#[derive(Parser, Clone)]61pub struct BuildSystems {62 63 64 #[clap(long, default_value = "toplevel")]65 build_attr: String,66}6768struct Generation {69 id: u32,70 current: bool,71 datetime: String,72}7374fn parse_generation_line(g: &str) -> Option<Generation> {75 let mut parts = g.split_whitespace();76 let id = parts.next()?;77 let id: u32 = id.parse().ok()?;78 let date = parts.next()?;79 let time = parts.next()?;80 let current = if let Some(current) = parts.next() {81 if current == "(current)" {82 Some(true)83 } else {84 None85 }86 } else {87 Some(false)88 };89 let current = current?;90 if parts.next().is_some() {91 warn!("unexpected text after generation: {g}");92 }93 Some(Generation {94 id,95 current,96 datetime: format!("{date} {time}"),97 })98}99100async fn get_current_generation(host: &ConfigHost) -> Result<Generation> {101 let mut cmd = host.cmd("nix-env").await?;102 cmd.comparg("--profile", "/nix/var/nix/profiles/system")103 .arg("--list-generations");104 105 let data = cmd.sudo().run_string().await?;106 let generations = data107 .split('\n')108 .map(|e| e.trim())109 .filter(|&l| !l.is_empty())110 .filter_map(|g| {111 let gen = parse_generation_line(g);112 if gen.is_none() {113 warn!("bad generation: {g}");114 }115 gen116 })117 .collect::<Vec<_>>();118 let current = generations119 .into_iter()120 .filter(|g| g.current)121 .at_most_one()122 .map_err(|_e| anyhow!("bad list-generations output"))?123 .ok_or_else(|| anyhow!("failed to find generation"))?;124 Ok(current)125}126127async fn deploy_task(128 action: DeployAction,129 host: &ConfigHost,130 built: PathBuf,131 specialisation: Option<String>,132 disable_rollback: bool,133) -> Result<()> {134 let deploy_kind = host.deploy_kind().await?;135 if deploy_kind == DeployKind::NixosInstall136 && !matches!(action, DeployAction::Boot | DeployAction::Upload)137 {138 bail!("nixos-install deploy kind only supports boot and upload actions");139 }140141 let mut failed = false;142143 144 145 146 147 148 if !disable_rollback && action.should_create_rollback_marker() {149 let _span = info_span!("preparing").entered();150 info!("preparing for rollback");151 let generation = get_current_generation(host).await?;152 info!(153 "rollback target would be {} {}",154 generation.id, generation.datetime155 );156 {157 let mut cmd = host.cmd("sh").await?;158 cmd.arg("-c").arg(format!("mark=$(mktemp -p /etc -t fleet_rollback_marker.XXXXX) && echo -n {} > $mark && mv --no-clobber $mark /etc/fleet_rollback_marker", generation.id));159 if let Err(e) = cmd.sudo().run().await {160 error!("failed to set rollback marker: {e}");161 failed = true;162 }163 }164 165 166 167 168 169170 171 172 173 174 if action.should_schedule_rollback_run() {175 let mut cmd = host.cmd("systemd-run").await?;176 cmd.comparg("--on-active", "3min")177 .comparg("--unit", "rollback-watchdog-run")178 .arg("systemctl")179 .arg("start")180 .arg("rollback-watchdog.service");181 if let Err(e) = cmd.sudo().run().await {182 error!("failed to schedule rollback run: {e}");183 failed = true;184 }185 }186 }187 if deploy_kind == DeployKind::NixosInstall {188 info!(189 "running nixos-install to switch profile, install bootloader, and perform activation"190 );191 let mut cmd = host.cmd("nixos-install").await?;192 cmd.arg("--system").arg(&built).args([193 194 195 "--no-channel-copy",196 "--root",197 "/mnt",198 ]);199 if let Err(e) = cmd.sudo().run().await {200 error!("failed to execute nixos-install: {e}");201 failed = true;202 }203 } else {204 if action.should_switch_profile() && !failed {205 info!("switching system profile generation");206207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 let mut cmd = host.nix_cmd().await?;227 cmd.arg("build");228 cmd.comparg("--profile", "/nix/var/nix/profiles/system");229 cmd.arg(&built);230 if let Err(e) = cmd.sudo().run_nix().await {231 error!("failed to switch system profile generation: {e}");232 failed = true;233 }234 }235236 237238 if action.should_activate() && !failed {239 let _span = info_span!("activating").entered();240 info!("executing activation script");241 let specialised = if let Some(specialisation) = specialisation {242 let mut specialised = built.join("specialisation");243 specialised.push(specialisation);244 specialised245 } else {246 built.clone()247 };248 let switch_script = specialised.join("bin/switch-to-configuration");249 let mut cmd = host.cmd(switch_script).in_current_span().await?;250 cmd.arg(action.name().expect("upload.should_activate == false"));251 if let Err(e) = cmd.sudo().run().in_current_span().await {252 error!("failed to activate: {e}");253 failed = true;254 }255 }256 }257 if action.should_create_rollback_marker() {258 if !disable_rollback {259 if failed {260 if action.should_schedule_rollback_run() {261 info!("executing rollback");262 if let Err(e) = host263 .systemctl_start("rollback-watchdog.service")264 .instrument(info_span!("rollback"))265 .await266 {267 error!("failed to trigger rollback: {e}")268 }269 }270 } else {271 info!("trying to mark upgrade as successful");272 if let Err(e) = host273 .rm_file("/etc/fleet_rollback_marker", true)274 .in_current_span()275 .await276 {277 error!("failed to remove rollback marker. This is bad, as the system will be rolled back by watchdog: {e}")278 }279 }280 info!("disarming watchdog, just in case");281 if let Err(_e) = host.systemctl_stop("rollback-watchdog.timer").await {282 283 }284 if action.should_schedule_rollback_run() {285 if let Err(e) = host.systemctl_stop("rollback-watchdog-run.timer").await {286 error!("failed to disarm rollback run: {e}");287 }288 }289 } else if let Err(_e) = host290 .rm_file("/etc/fleet_rollback_marker", true)291 .in_current_span()292 .await293 {294 295 }296 }297 Ok(())298}299300async fn build_task(301 config: Config,302 hostname: String,303 build_attr: &str,304 batch: Option<NixBuildBatch>,305) -> Result<PathBuf> {306 info!("building");307 let host = config.host(&hostname).await?;308 309 let nixos = host.nixos_config().await?;310 let drv = nix_go!(nixos.system.build[{ build_attr }]);311 let outputs = drv.build_maybe_batch(batch).await?;312 let out_output = outputs313 .get("out")314 .ok_or_else(|| anyhow!("system build should produce \"out\" output"))?;315316 {317 info!("adding gc root");318 let mut cmd = config.local_host().cmd("nix").await?;319 cmd.arg("build")320 .comparg(321 "--profile",322 format!(323 "/nix/var/nix/profiles/{}-{hostname}",324 config.data().gc_root_prefix325 ),326 )327 .arg(out_output);328 cmd.sudo().run_nix().await?;329 }330331 Ok(out_output.clone())332}333334impl BuildSystems {335 pub async fn run(self, config: &Config, opts: &FleetOpts) -> Result<()> {336 let hosts = opts.filter_skipped(config.list_hosts().await?).await?;337 let set = LocalSet::new();338 let build_attr = self.build_attr.clone();339 let batch = (hosts.len() > 1).then(|| {340 config341 .nix_session342 .new_build_batch("build-hosts".to_string())343 });344 for host in hosts {345 let config = config.clone();346 let span = info_span!("build", host = field::display(&host.name));347 let hostname = host.name;348 let build_attr = build_attr.clone();349 let batch = batch.clone();350 set.spawn_local(351 (async move {352 let built = match build_task(config, hostname.clone(), &build_attr, batch).await353 {354 Ok(path) => path,355 Err(e) => {356 error!("failed to deploy host: {}", e);357 return;358 }359 };360 361 let mut out = current_dir().expect("cwd exists");362 out.push(format!("built-{}", hostname));363364 info!("linking iso image to {:?}", out);365 if let Err(e) = symlink(built, out) {366 error!("failed to symlink: {e}")367 }368 })369 .instrument(span),370 );371 }372 drop(batch);373 set.await;374 Ok(())375 }376}377378impl Deploy {379 pub async fn run(self, config: &Config, opts: &FleetOpts) -> Result<()> {380 let hosts = opts.filter_skipped(config.list_hosts().await?).await?;381 let set = LocalSet::new();382 let batch = (hosts.len() > 1).then(|| {383 config384 .nix_session385 .new_build_batch("deploy-hosts".to_string())386 });387 for host in hosts.into_iter() {388 let config = config.clone();389 let span = info_span!("deploy", host = field::display(&host.name));390 let hostname = host.name.clone();391 let local_host = config.local_host();392 let opts = opts.clone();393 let batch = batch.clone();394 if let Some(deploy_kind) = opts.action_attr::<DeployKind>(&host, "deploy_kind").await? {395 host.set_deploy_kind(deploy_kind);396 };397398 set.spawn_local(399 (async move {400 let built =401 match build_task(config.clone(), hostname.clone(), "toplevel", batch).await402 {403 Ok(path) => path,404 Err(e) => {405 error!("failed to build host system closure: {}", e);406 return;407 }408 };409410 let deploy_kind = match host.deploy_kind().await {411 Ok(v) => v,412 Err(e) => {413 error!("failed to query target deploy kind: {e}");414 return;415 }416 };417418 419 let mut disable_rollback = self.disable_rollback;420 if !disable_rollback && deploy_kind != DeployKind::Fleet {421 warn!("disabling rollback, as not supported by non-fleet deployment kinds");422 disable_rollback = true;423 }424425 if !opts.is_local(&hostname) {426 info!("uploading system closure");427 {428 429 430 431 432 433 let Ok(mut sign) = local_host.cmd("nix").await else {434 error!("failed to setup local");435 return;436 };437 438 sign.arg("store")439 .arg("sign")440 .comparg("--key-file", "/etc/nix/private-key")441 .arg("-r")442 .arg(&built);443 if let Err(e) = sign.sudo().run_nix().await {444 warn!("failed to sign store paths: {e}");445 };446 }447 let mut tries = 0;448 loop {449 match host.remote_derivation(&built).await {450 Ok(remote) => {451 assert!(remote == built, "CA derivations aren't implemented");452 break;453 }454 Err(e) if tries < 3 => {455 tries += 1;456 warn!("copy failure ({}/3): {}", tries, e);457 sleep(Duration::from_millis(5000)).await;458 }459 Err(e) => {460 error!("upload failed: {e}");461 return;462 }463 }464 }465 }466 if let Err(e) = deploy_task(467 self.action,468 &host,469 built,470 if let Ok(v) = opts.action_attr(&host, "specialisation").await {471 v472 } else {473 error!("unreachable? failed to get specialization");474 return;475 },476 disable_rollback,477 )478 .await479 {480 error!("activation failed: {e}");481 }482 })483 .instrument(span),484 );485 }486 drop(batch);487 set.await;488 Ok(())489 }490}