git.delta.rocks / jrsonnet / refs/commits / deac38eb1c8f

difftreelog

fix do not prepare for rollback on upload

Yaroslav Bolyukin2024-01-05parent: #c0c9b96.patch.diff
in: trunk

1 file changed

modifiedcmds/fleet/src/cmds/build_systems.rsdiffbeforeafterboth
16 /// Disable automatic rollback16 /// Disable automatic rollback
17 #[clap(long)]17 #[clap(long)]
18 disable_rollback: bool,18 disable_rollback: bool,
19 /// Action to execute after system is built
19 action: DeployAction,20 action: DeployAction,
20}21}
2122
46 pub(crate) fn should_activate(&self) -> bool {47 pub(crate) fn should_activate(&self) -> bool {
47 matches!(self, Self::Switch | Self::Test)48 matches!(self, Self::Switch | Self::Test)
48 }49 }
50 pub(crate) fn should_create_rollback_marker(&self) -> bool {
51 // Upload does nothing on the target machine, other than uploading the closure.
52 // In boot case we want to have rollback marker prepared, so that the system may rollback itself on the next boot.
53 !matches!(self, Self::Upload)
54 }
49 pub(crate) fn should_schedule_rollback_run(&self) -> bool {55 pub(crate) fn should_schedule_rollback_run(&self) -> bool {
50 matches!(self, Self::Switch | Self::Test)56 matches!(self, Self::Switch | Self::Test)
51 }57 }
127 // is scheduler on next boot (default behavior). On current boot - rollback activator will fail due to133 // is scheduler on next boot (default behavior). On current boot - rollback activator will fail due to
128 // unit name conflict in systemd-run134 // unit name conflict in systemd-run
129 // This code is tied to rollback.nix135 // This code is tied to rollback.nix
130 if !disable_rollback {136 if !disable_rollback && action.should_create_rollback_marker() {
131 let _span = info_span!("preparing").entered();137 let _span = info_span!("preparing").entered();
132 info!("preparing for rollback");138 info!("preparing for rollback");
133 let generation = get_current_generation(host).await?;139 let generation = get_current_generation(host).await?;
193 failed = true;199 failed = true;
194 }200 }
195 }201 }
196 if !disable_rollback {202 if action.should_create_rollback_marker() {
203 if !disable_rollback {
197 if failed {204 if failed {
205 if action.should_schedule_rollback_run() {
198 info!("executing rollback");206 info!("executing rollback");
199 if let Err(e) = host207 if let Err(e) = host
200 .systemctl_start("rollback-watchdog.service")208 .systemctl_start("rollback-watchdog.service")
203 {211 {
204 error!("failed to trigger rollback: {e}")212 error!("failed to trigger rollback: {e}")
205 }213 }
206 } else {214 }
215 } else {
207 info!("trying to mark upgrade as successful");216 info!("trying to mark upgrade as successful");
208 if let Err(e) = host217 if let Err(e) = host
229 {238 {
230 // Marker might not exist, yet better try to remove it.239 // Marker might not exist, yet better try to remove it.
231 }240 }
241 }
232 Ok(())242 Ok(())
233}243}
234244