From 25f223ec89dd2cec802a13b82af82bba1a73ef8e Mon Sep 17 00:00:00 2001 From: Kristian Amlie Date: Wed, 25 Sep 2024 10:54:35 +0200 Subject: [PATCH] chore: Increase robustness of `--stop-before flag. First and foremost, make sure that repeated resuming before the same state, with the same `--stop-before` flag, is a noop. It should keep stopping there. Also make sure that once we have started executing the path after that, it should no longer be possible to go back. For this we introduce some new DB flags, but since the existing ones have not been released yet, this should be fine. Finally, simplify test conditions by removing the query states from the log, since they have no effect on the flow. Signed-off-by: Kristian Amlie --- src/mender-update/standalone.hpp | 16 +- src/mender-update/standalone/context.cpp | 4 +- src/mender-update/standalone/context.hpp | 4 +- src/mender-update/standalone/standalone.cpp | 194 ++++++----- src/mender-update/standalone/states.cpp | 12 +- src/mender-update/standalone/states.hpp | 16 +- tests/src/mender-update/cli/cli_test.cpp | 351 +++++++++++++------- 7 files changed, 384 insertions(+), 213 deletions(-) diff --git a/src/mender-update/standalone.hpp b/src/mender-update/standalone.hpp index c40cc3c5e..600e4c266 100644 --- a/src/mender-update/standalone.hpp +++ b/src/mender-update/standalone.hpp @@ -81,7 +81,8 @@ class StateMachine { ScriptRunnerState download_leave_state_; ScriptRunnerState download_error_state_; - SaveState save_artifact_install_state_; + JustSaveState save_before_artifact_install_state_; + JustSaveState save_artifact_install_state_; ScriptRunnerState artifact_install_enter_state_; ArtifactInstallState artifact_install_state_; ScriptRunnerState artifact_install_leave_state_; @@ -89,27 +90,28 @@ class StateMachine { RebootAndRollbackQueryState reboot_and_rollback_query_state_; - SaveState save_artifact_commit_state_; + JustSaveState save_before_artifact_commit_state_; + JustSaveState save_artifact_commit_state_; ScriptRunnerState artifact_commit_enter_state_; ArtifactCommitState artifact_commit_state_; - SaveState save_post_artifact_commit_state_; - SaveState save_artifact_commit_leave_state_; + JustSaveState save_before_artifact_commit_leave_state_; + JustSaveState save_artifact_commit_leave_state_; ScriptRunnerState artifact_commit_leave_state_; ScriptRunnerState artifact_commit_error_state_; RollbackQueryState rollback_query_state_; - SaveState save_artifact_rollback_state_; + JustSaveState save_artifact_rollback_state_; ScriptRunnerState artifact_rollback_enter_state_; ArtifactRollbackState artifact_rollback_state_; ScriptRunnerState artifact_rollback_leave_state_; - SaveState save_artifact_failure_state_; + JustSaveState save_artifact_failure_state_; ScriptRunnerState artifact_failure_enter_state_; ArtifactFailureState artifact_failure_state_; ScriptRunnerState artifact_failure_leave_state_; - SaveState save_cleanup_state_; + JustSaveState save_cleanup_state_; CleanupState cleanup_state_; ExitState exit_state_; diff --git a/src/mender-update/standalone/context.cpp b/src/mender-update/standalone/context.cpp index 11fb6afbb..303700a42 100644 --- a/src/mender-update/standalone/context.cpp +++ b/src/mender-update/standalone/context.cpp @@ -28,9 +28,11 @@ const string StateDataKeys::in_state {"InState"}; const string StateDataKeys::failed {"Failed"}; const string StateDataKeys::rolled_back {"RolledBack"}; +const string StateData::kBeforeStateArtifactInstall_Enter {"Before_ArtifactInstall_Enter"}; const string StateData::kInStateArtifactInstall_Enter {"ArtifactInstall_Enter"}; +const string StateData::kBeforeStateArtifactCommit_Enter {"Before_ArtifactCommit_Enter"}; const string StateData::kInStateArtifactCommit_Enter {"ArtifactCommit_Enter"}; -const string StateData::kInStatePostArtifactCommit {"PostArtifactCommit"}; +const string StateData::kBeforeStateArtifactCommit_Leave {"Before_ArtifactCommit_Leave"}; const string StateData::kInStateArtifactCommit_Leave {"ArtifactCommit_Leave"}; const string StateData::kInStateArtifactRollback_Enter {"ArtifactRollback_Enter"}; const string StateData::kInStateArtifactFailure_Enter {"ArtifactFailure_Enter"}; diff --git a/src/mender-update/standalone/context.hpp b/src/mender-update/standalone/context.hpp index 74023cd78..1de0acfcf 100644 --- a/src/mender-update/standalone/context.hpp +++ b/src/mender-update/standalone/context.hpp @@ -76,9 +76,11 @@ struct StateData { bool failed {false}; bool rolled_back {false}; + static const string kBeforeStateArtifactInstall_Enter; static const string kInStateArtifactInstall_Enter; + static const string kBeforeStateArtifactCommit_Enter; static const string kInStateArtifactCommit_Enter; - static const string kInStatePostArtifactCommit; + static const string kBeforeStateArtifactCommit_Leave; static const string kInStateArtifactCommit_Leave; static const string kInStateArtifactRollback_Enter; static const string kInStateArtifactFailure_Enter; diff --git a/src/mender-update/standalone/standalone.cpp b/src/mender-update/standalone/standalone.cpp index c87152f7b..2c4c62874 100644 --- a/src/mender-update/standalone/standalone.cpp +++ b/src/mender-update/standalone/standalone.cpp @@ -240,6 +240,7 @@ StateMachine::StateMachine(Context &ctx) : executor::Action::Error, executor::OnError::Ignore, Result::NoResult}, + save_before_artifact_install_state_ {StateData::kBeforeStateArtifactInstall_Enter}, save_artifact_install_state_ {StateData::kInStateArtifactInstall_Enter}, artifact_install_enter_state_ { executor::State::ArtifactInstall, @@ -256,13 +257,14 @@ StateMachine::StateMachine(Context &ctx) : executor::Action::Error, executor::OnError::Ignore, Result::NoResult}, + save_before_artifact_commit_state_ {StateData::kBeforeStateArtifactCommit_Enter}, save_artifact_commit_state_ {StateData::kInStateArtifactCommit_Enter}, artifact_commit_enter_state_ { executor::State::ArtifactCommit, executor::Action::Enter, executor::OnError::Fail, Result::CommitFailed | Result::Failed}, - save_post_artifact_commit_state_ {StateData::kInStatePostArtifactCommit}, + save_before_artifact_commit_leave_state_ {StateData::kBeforeStateArtifactCommit_Leave}, save_artifact_commit_leave_state_ {StateData::kInStateArtifactCommit_Leave}, artifact_commit_leave_state_ { executor::State::ArtifactCommit, @@ -305,101 +307,122 @@ StateMachine::StateMachine(Context &ctx) : auto &s = state_machine_; // clang-format off - s.AddTransition(prepare_download_state_, se::Success, download_enter_state_, tf::Immediate); - s.AddTransition(prepare_download_state_, se::Failure, exit_state_, tf::Immediate); - s.AddTransition(prepare_download_state_, se::EmptyPayloadArtifact, exit_state_, tf::Immediate); + s.AddTransition(prepare_download_state_, se::Success, download_enter_state_, tf::Immediate); + s.AddTransition(prepare_download_state_, se::Failure, exit_state_, tf::Immediate); + s.AddTransition(prepare_download_state_, se::EmptyPayloadArtifact, exit_state_, tf::Immediate); - s.AddTransition(download_enter_state_, se::Success, download_state_, tf::Immediate); - s.AddTransition(download_enter_state_, se::Failure, download_error_state_, tf::Immediate); + s.AddTransition(download_enter_state_, se::Success, download_state_, tf::Immediate); + s.AddTransition(download_enter_state_, se::Failure, download_error_state_, tf::Immediate); - s.AddTransition(download_state_, se::Success, download_leave_state_, tf::Immediate); - s.AddTransition(download_state_, se::Failure, download_error_state_, tf::Immediate); + s.AddTransition(download_state_, se::Success, download_leave_state_, tf::Immediate); + s.AddTransition(download_state_, se::Failure, download_error_state_, tf::Immediate); - s.AddTransition(download_leave_state_, se::Success, save_artifact_install_state_, tf::Immediate); - s.AddTransition(download_leave_state_, se::Failure, download_error_state_, tf::Immediate); + s.AddTransition(download_leave_state_, se::Success, save_before_artifact_install_state_, tf::Immediate); + s.AddTransition(download_leave_state_, se::Failure, download_error_state_, tf::Immediate); - s.AddTransition(download_error_state_, se::Success, save_cleanup_state_, tf::Immediate); - s.AddTransition(download_error_state_, se::Failure, save_cleanup_state_, tf::Immediate); + s.AddTransition(download_error_state_, se::Success, save_cleanup_state_, tf::Immediate); + s.AddTransition(download_error_state_, se::Failure, save_cleanup_state_, tf::Immediate); - s.AddTransition(save_artifact_install_state_, se::Success, artifact_install_enter_state_, tf::Immediate); - s.AddTransition(save_artifact_install_state_, se::Failure, save_cleanup_state_, tf::Immediate); + // The reason we have a "save_before" state followed by a "save" state is the + // `--stop-before` argument. We want to make sure that: - s.AddTransition(artifact_install_enter_state_, se::Success, artifact_install_state_, tf::Immediate); - s.AddTransition(artifact_install_enter_state_, se::Failure, artifact_install_error_state_, tf::Immediate); + // 1. If you specify the flag twice in a row, the second run is a noop (just stops at the + // same point). This is accomplished using the "save_before" state, which we return to + // during a DB recovery. - s.AddTransition(artifact_install_state_, se::Success, artifact_install_leave_state_, tf::Immediate); - s.AddTransition(artifact_install_state_, se::Failure, artifact_install_error_state_, tf::Immediate); + // 2. If we have started executing the following states, it should no longer we possible to + // use the `--stop-before` flag for that state, since the state execution has started + // already. This is done by saving a different value in the "save" state, and is thus + // preserved even after a spontaneous reboot. Once we have gone there, there is no going + // back. + s.AddTransition(save_before_artifact_install_state_, se::Success, save_artifact_install_state_, tf::Immediate); + s.AddTransition(save_before_artifact_install_state_, se::Failure, save_cleanup_state_, tf::Immediate); - s.AddTransition(artifact_install_leave_state_, se::Success, save_artifact_commit_state_, tf::Immediate); - s.AddTransition(artifact_install_leave_state_, se::Failure, artifact_install_error_state_, tf::Immediate); + s.AddTransition(save_artifact_install_state_, se::Success, artifact_install_enter_state_, tf::Immediate); + s.AddTransition(save_artifact_install_state_, se::Failure, save_cleanup_state_, tf::Immediate); - s.AddTransition(artifact_install_error_state_, se::Success, rollback_query_state_, tf::Immediate); - s.AddTransition(artifact_install_error_state_, se::Failure, rollback_query_state_, tf::Immediate); + s.AddTransition(artifact_install_enter_state_, se::Success, artifact_install_state_, tf::Immediate); + s.AddTransition(artifact_install_enter_state_, se::Failure, artifact_install_error_state_, tf::Immediate); - s.AddTransition(save_artifact_commit_state_, se::Success, reboot_and_rollback_query_state_, tf::Immediate); - s.AddTransition(save_artifact_commit_state_, se::Failure, reboot_and_rollback_query_state_, tf::Immediate); + s.AddTransition(artifact_install_state_, se::Success, artifact_install_leave_state_, tf::Immediate); + s.AddTransition(artifact_install_state_, se::Failure, artifact_install_error_state_, tf::Immediate); - s.AddTransition(reboot_and_rollback_query_state_, se::Success, artifact_commit_enter_state_, tf::Immediate); - s.AddTransition(reboot_and_rollback_query_state_, se::Failure, rollback_query_state_, tf::Immediate); - s.AddTransition(reboot_and_rollback_query_state_, se::NeedsInteraction, exit_state_, tf::Immediate); + s.AddTransition(artifact_install_leave_state_, se::Success, reboot_and_rollback_query_state_, tf::Immediate); + s.AddTransition(artifact_install_leave_state_, se::Failure, artifact_install_error_state_, tf::Immediate); - s.AddTransition(artifact_commit_enter_state_, se::Success, artifact_commit_state_, tf::Immediate); - s.AddTransition(artifact_commit_enter_state_, se::Failure, artifact_commit_error_state_, tf::Immediate); + s.AddTransition(artifact_install_error_state_, se::Success, rollback_query_state_, tf::Immediate); + s.AddTransition(artifact_install_error_state_, se::Failure, rollback_query_state_, tf::Immediate); - s.AddTransition(artifact_commit_state_, se::Success, save_post_artifact_commit_state_, tf::Immediate); - s.AddTransition(artifact_commit_state_, se::Failure, artifact_commit_error_state_, tf::Immediate); + s.AddTransition(reboot_and_rollback_query_state_, se::Success, save_before_artifact_commit_state_, tf::Immediate); + s.AddTransition(reboot_and_rollback_query_state_, se::Failure, rollback_query_state_, tf::Immediate); + s.AddTransition(reboot_and_rollback_query_state_, se::NeedsInteraction, exit_state_, tf::Immediate); - // The reason we have two save states in a row here, is that using the `--stop-before` - // option, one can exit at the point of save_post_artifact_commit_state, and it is allowed - // both to resume and roll back from here. However, once we have started executing the - // `ArtifactCommit_Leave` scripts, it is no longer allowed to roll back, therefore it is - // important to save that as a *separate* state. - s.AddTransition(save_post_artifact_commit_state_, se::Success, save_artifact_commit_leave_state_, tf::Immediate); - s.AddTransition(save_post_artifact_commit_state_, se::Failure, artifact_commit_error_state_, tf::Immediate); + // See `save_before_artifact_install_state_` for an explanation of the following two states. + s.AddTransition(save_before_artifact_commit_state_, se::Success, save_artifact_commit_state_, tf::Immediate); + s.AddTransition(save_before_artifact_commit_state_, se::Failure, rollback_query_state_, tf::Immediate); - s.AddTransition(save_artifact_commit_leave_state_, se::Success, artifact_commit_leave_state_, tf::Immediate); - s.AddTransition(save_artifact_commit_leave_state_, se::Failure, artifact_commit_error_state_, tf::Immediate); + s.AddTransition(save_artifact_commit_state_, se::Success, artifact_commit_enter_state_, tf::Immediate); + s.AddTransition(save_artifact_commit_state_, se::Failure, rollback_query_state_, tf::Immediate); - s.AddTransition(artifact_commit_leave_state_, se::Success, save_cleanup_state_, tf::Immediate); - s.AddTransition(artifact_commit_leave_state_, se::Failure, save_cleanup_state_, tf::Immediate); + s.AddTransition(artifact_commit_enter_state_, se::Success, artifact_commit_state_, tf::Immediate); + s.AddTransition(artifact_commit_enter_state_, se::Failure, artifact_commit_error_state_, tf::Immediate); - s.AddTransition(rollback_query_state_, se::Success, save_artifact_rollback_state_, tf::Immediate); - s.AddTransition(rollback_query_state_, se::NothingToDo, save_artifact_failure_state_, tf::Immediate); - s.AddTransition(rollback_query_state_, se::Failure, save_artifact_failure_state_, tf::Immediate); - s.AddTransition(rollback_query_state_, se::NeedsInteraction, exit_state_, tf::Immediate); + s.AddTransition(artifact_commit_state_, se::Success, save_before_artifact_commit_leave_state_, tf::Immediate); + s.AddTransition(artifact_commit_state_, se::Failure, artifact_commit_error_state_, tf::Immediate); - s.AddTransition(artifact_commit_error_state_, se::Success, rollback_query_state_, tf::Immediate); - s.AddTransition(artifact_commit_error_state_, se::Failure, rollback_query_state_, tf::Immediate); + // See `save_before_artifact_install_state_` for an explanation of the following two states. + s.AddTransition(save_before_artifact_commit_leave_state_, se::Success, save_artifact_commit_leave_state_, tf::Immediate); + s.AddTransition(save_before_artifact_commit_leave_state_, se::Failure, artifact_commit_error_state_, tf::Immediate); - s.AddTransition(save_artifact_rollback_state_, se::Success, artifact_rollback_enter_state_, tf::Immediate); - s.AddTransition(save_artifact_rollback_state_, se::Failure, artifact_rollback_enter_state_, tf::Immediate); + s.AddTransition(save_artifact_commit_leave_state_, se::Success, artifact_commit_leave_state_, tf::Immediate); + s.AddTransition(save_artifact_commit_leave_state_, se::Failure, artifact_commit_error_state_, tf::Immediate); - s.AddTransition(artifact_rollback_enter_state_, se::Success, artifact_rollback_state_, tf::Immediate); - s.AddTransition(artifact_rollback_enter_state_, se::Failure, artifact_rollback_state_, tf::Immediate); + s.AddTransition(artifact_commit_leave_state_, se::Success, save_cleanup_state_, tf::Immediate); + s.AddTransition(artifact_commit_leave_state_, se::Failure, save_cleanup_state_, tf::Immediate); - s.AddTransition(artifact_rollback_state_, se::Success, artifact_rollback_leave_state_, tf::Immediate); - s.AddTransition(artifact_rollback_state_, se::Failure, artifact_rollback_leave_state_, tf::Immediate); + s.AddTransition(rollback_query_state_, se::Success, save_artifact_rollback_state_, tf::Immediate); + s.AddTransition(rollback_query_state_, se::NothingToDo, save_artifact_failure_state_, tf::Immediate); + s.AddTransition(rollback_query_state_, se::Failure, save_artifact_failure_state_, tf::Immediate); + s.AddTransition(rollback_query_state_, se::NeedsInteraction, exit_state_, tf::Immediate); - s.AddTransition(artifact_rollback_leave_state_, se::Success, save_artifact_failure_state_, tf::Immediate); - s.AddTransition(artifact_rollback_leave_state_, se::Failure, save_artifact_failure_state_, tf::Immediate); + s.AddTransition(artifact_commit_error_state_, se::Success, rollback_query_state_, tf::Immediate); + s.AddTransition(artifact_commit_error_state_, se::Failure, rollback_query_state_, tf::Immediate); - s.AddTransition(save_artifact_failure_state_, se::Success, artifact_failure_enter_state_, tf::Immediate); - s.AddTransition(save_artifact_failure_state_, se::Failure, artifact_failure_enter_state_, tf::Immediate); + // Note: States on the error path are supposed to be idempotent, and may execute several + // times if interrupted by a powerloss. Hence they don't need `save_before` states. See + // `save_before_artifact_install_state_` for more context. + s.AddTransition(save_artifact_rollback_state_, se::Success, artifact_rollback_enter_state_, tf::Immediate); + s.AddTransition(save_artifact_rollback_state_, se::Failure, artifact_rollback_enter_state_, tf::Immediate); - s.AddTransition(artifact_failure_enter_state_, se::Success, artifact_failure_state_, tf::Immediate); - s.AddTransition(artifact_failure_enter_state_, se::Failure, artifact_failure_state_, tf::Immediate); + s.AddTransition(artifact_rollback_enter_state_, se::Success, artifact_rollback_state_, tf::Immediate); + s.AddTransition(artifact_rollback_enter_state_, se::Failure, artifact_rollback_state_, tf::Immediate); - s.AddTransition(artifact_failure_state_, se::Success, artifact_failure_leave_state_, tf::Immediate); - s.AddTransition(artifact_failure_state_, se::Failure, artifact_failure_leave_state_, tf::Immediate); + s.AddTransition(artifact_rollback_state_, se::Success, artifact_rollback_leave_state_, tf::Immediate); + s.AddTransition(artifact_rollback_state_, se::Failure, artifact_rollback_leave_state_, tf::Immediate); - s.AddTransition(artifact_failure_leave_state_, se::Success, save_cleanup_state_, tf::Immediate); - s.AddTransition(artifact_failure_leave_state_, se::Failure, save_cleanup_state_, tf::Immediate); + s.AddTransition(artifact_rollback_leave_state_, se::Success, save_artifact_failure_state_, tf::Immediate); + s.AddTransition(artifact_rollback_leave_state_, se::Failure, save_artifact_failure_state_, tf::Immediate); - s.AddTransition(save_cleanup_state_, se::Success, cleanup_state_, tf::Immediate); - s.AddTransition(save_cleanup_state_, se::Failure, cleanup_state_, tf::Immediate); + // See comment for `save_artifact_rollback_state_`. + s.AddTransition(save_artifact_failure_state_, se::Success, artifact_failure_enter_state_, tf::Immediate); + s.AddTransition(save_artifact_failure_state_, se::Failure, artifact_failure_enter_state_, tf::Immediate); - s.AddTransition(cleanup_state_, se::Success, exit_state_, tf::Immediate); - s.AddTransition(cleanup_state_, se::Failure, exit_state_, tf::Immediate); + s.AddTransition(artifact_failure_enter_state_, se::Success, artifact_failure_state_, tf::Immediate); + s.AddTransition(artifact_failure_enter_state_, se::Failure, artifact_failure_state_, tf::Immediate); + + s.AddTransition(artifact_failure_state_, se::Success, artifact_failure_leave_state_, tf::Immediate); + s.AddTransition(artifact_failure_state_, se::Failure, artifact_failure_leave_state_, tf::Immediate); + + s.AddTransition(artifact_failure_leave_state_, se::Success, save_cleanup_state_, tf::Immediate); + s.AddTransition(artifact_failure_leave_state_, se::Failure, save_cleanup_state_, tf::Immediate); + + // See comment for `save_artifact_rollback_state_`. While cleanup is not strictly an error + // state, it is idempotent. + s.AddTransition(save_cleanup_state_, se::Success, cleanup_state_, tf::Immediate); + s.AddTransition(save_cleanup_state_, se::Failure, cleanup_state_, tf::Immediate); + + s.AddTransition(cleanup_state_, se::Success, exit_state_, tf::Immediate); + s.AddTransition(cleanup_state_, se::Failure, exit_state_, tf::Immediate); // clang-format on } @@ -414,12 +437,16 @@ void StateMachine::Run() { } error::Error StateMachine::SetStartStateFromStateData(const string &in_state) { - if (in_state == StateData::kInStateArtifactInstall_Enter) { - start_state_ = &artifact_install_enter_state_; + if (in_state == StateData::kBeforeStateArtifactInstall_Enter) { + start_state_ = &save_before_artifact_install_state_; + } else if (in_state == StateData::kInStateArtifactInstall_Enter) { + start_state_ = &save_artifact_rollback_state_; + } else if (in_state == StateData::kBeforeStateArtifactCommit_Enter) { + start_state_ = &save_before_artifact_commit_state_; } else if (in_state == StateData::kInStateArtifactCommit_Enter) { - start_state_ = &artifact_commit_enter_state_; - } else if (in_state == StateData::kInStatePostArtifactCommit) { - start_state_ = &save_artifact_commit_leave_state_; + start_state_ = &save_artifact_rollback_state_; + } else if (in_state == StateData::kBeforeStateArtifactCommit_Leave) { + start_state_ = &save_before_artifact_commit_leave_state_; } else if (in_state == StateData::kInStateArtifactCommit_Leave) { start_state_ = &artifact_commit_leave_state_; } else if (in_state == StateData::kInStateCleanup) { @@ -443,22 +470,28 @@ error::Error StateMachine::AddStopBeforeState(const string &state) { // Replace transition in state machine in order to exit at given point. if (state == "ArtifactInstall_Enter") { - s.AddTransition(save_artifact_install_state_, se::Success, exit_state_, tf::Immediate); + s.AddTransition( + save_before_artifact_install_state_, se::Success, exit_state_, tf::Immediate); } else if (state == "ArtifactCommit_Enter") { - s.AddTransition(save_artifact_commit_state_, se::Success, exit_state_, tf::Immediate); + s.AddTransition( + save_before_artifact_commit_state_, se::Success, exit_state_, tf::Immediate); } else if (state == "ArtifactCommit_Leave") { - s.AddTransition(save_post_artifact_commit_state_, se::Success, exit_state_, tf::Immediate); + s.AddTransition( + save_before_artifact_commit_leave_state_, se::Success, exit_state_, tf::Immediate); } else if (state == "ArtifactRollback_Enter") { s.AddTransition(save_artifact_rollback_state_, se::Success, exit_state_, tf::Immediate); + s.AddTransition(save_artifact_rollback_state_, se::Failure, exit_state_, tf::Immediate); } else if (state == "ArtifactFailure_Enter") { s.AddTransition(save_artifact_failure_state_, se::Success, exit_state_, tf::Immediate); + s.AddTransition(save_artifact_failure_state_, se::Failure, exit_state_, tf::Immediate); } else if (state == "Cleanup") { s.AddTransition(save_cleanup_state_, se::Success, exit_state_, tf::Immediate); + s.AddTransition(save_cleanup_state_, se::Failure, exit_state_, tf::Immediate); } else if (state != "") { return context::MakeError( @@ -609,7 +642,8 @@ ResultAndError Commit(Context &ctx) { } ctx.state_data = in_progress.value(); - if (ctx.state_data.in_state != StateData::kInStateArtifactCommit_Enter) { + if (ctx.state_data.in_state != StateData::kBeforeStateArtifactCommit_Enter + and ctx.state_data.in_state != StateData::kInStateArtifactCommit_Enter) { return { Result::Failed, context::MakeError( @@ -661,9 +695,11 @@ ResultAndError Rollback(Context &ctx) { } ctx.state_data = in_progress.value(); - if (ctx.state_data.in_state != StateData::kInStateArtifactInstall_Enter + if (ctx.state_data.in_state != StateData::kBeforeStateArtifactInstall_Enter + and ctx.state_data.in_state != StateData::kInStateArtifactInstall_Enter + and ctx.state_data.in_state != StateData::kBeforeStateArtifactCommit_Enter and ctx.state_data.in_state != StateData::kInStateArtifactCommit_Enter - and ctx.state_data.in_state != StateData::kInStatePostArtifactCommit + and ctx.state_data.in_state != StateData::kBeforeStateArtifactCommit_Leave and ctx.state_data.in_state != StateData::kInStateArtifactRollback_Enter) { return { Result::Failed, diff --git a/src/mender-update/standalone/states.cpp b/src/mender-update/standalone/states.cpp index 4cb80e294..9dd51ef6a 100644 --- a/src/mender-update/standalone/states.cpp +++ b/src/mender-update/standalone/states.cpp @@ -69,6 +69,11 @@ void SaveState::OnEnter(Context &ctx, sm::EventPoster &poster) { return; } + OnEnterSaveState(ctx, poster); +} + +void JustSaveState::OnEnterSaveState(Context &ctx, sm::EventPoster &poster) { + // Nothing other than saving, which has already happened. poster.PostEvent(StateEvent::Success); } @@ -362,7 +367,12 @@ void ArtifactInstallState::OnEnter(Context &ctx, sm::EventPoster &po poster.PostEvent(StateEvent::Success); } -void RebootAndRollbackQueryState::OnEnter(Context &ctx, sm::EventPoster &poster) { +RebootAndRollbackQueryState::RebootAndRollbackQueryState() : + SaveState(StateData::kBeforeStateArtifactCommit_Enter) { +} + +void RebootAndRollbackQueryState::OnEnterSaveState( + Context &ctx, sm::EventPoster &poster) { auto reboot = ctx.update_module->NeedsReboot(); if (!reboot) { log::Error("Could not query for reboot: " + reboot.error().String()); diff --git a/src/mender-update/standalone/states.hpp b/src/mender-update/standalone/states.hpp index 597e01f3a..96178efc5 100644 --- a/src/mender-update/standalone/states.hpp +++ b/src/mender-update/standalone/states.hpp @@ -35,12 +35,21 @@ class SaveState : virtual public StateType { SaveState(const string &state) : state_ {state} { } - void OnEnter(Context &ctx, sm::EventPoster &poster) override; + void OnEnter(Context &ctx, sm::EventPoster &poster) override final; + virtual void OnEnterSaveState(Context &ctx, sm::EventPoster &poster) = 0; private: string state_; }; +class JustSaveState : public SaveState { +public: + JustSaveState(const string &state) : + SaveState {state} { + } + void OnEnterSaveState(Context &ctx, sm::EventPoster &poster) override; +}; + class PrepareDownloadState : virtual public StateType { public: void OnEnter(Context &ctx, sm::EventPoster &poster) override; @@ -56,9 +65,10 @@ class ArtifactInstallState : virtual public StateType { void OnEnter(Context &ctx, sm::EventPoster &poster) override; }; -class RebootAndRollbackQueryState : virtual public StateType { +class RebootAndRollbackQueryState : public SaveState { public: - void OnEnter(Context &ctx, sm::EventPoster &poster) override; + RebootAndRollbackQueryState(); + void OnEnterSaveState(Context &ctx, sm::EventPoster &poster) override; }; class ArtifactCommitState : virtual public StateType { diff --git a/tests/src/mender-update/cli/cli_test.cpp b/tests/src/mender-update/cli/cli_test.cpp index c711b52df..4f110eabd 100644 --- a/tests/src/mender-update/cli/cli_test.cpp +++ b/tests/src/mender-update/cli/cli_test.cpp @@ -434,7 +434,14 @@ TEST(CliTest, InstallAndCommitArtifact) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac exit 0 )")); @@ -463,8 +470,6 @@ Installed and committed. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit Cleanup )")); @@ -489,7 +494,14 @@ TEST(CliTest, InstallAndCommitArtifactCheckProvidesDepends) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac exit 0 )")); @@ -518,8 +530,6 @@ Installed and committed. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit Cleanup )")); @@ -579,7 +589,14 @@ TEST(CliTest, DownloadWithFileSizesInstallAndCommitArtifact) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in ProvidePayloadFileSizes) @@ -620,8 +637,6 @@ Installed and committed. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes DownloadWithFileSizes ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit Cleanup )")); @@ -647,7 +662,14 @@ TEST(CliTest, InstallAndThenCommitArtifact) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in SupportsRollback) @@ -682,8 +704,6 @@ Use 'commit' to update, or 'rollback' to roll back the update. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback )")); { @@ -707,8 +727,6 @@ SupportsRollback path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit Cleanup )")); @@ -733,7 +751,14 @@ TEST(CliTest, InstallAndThenRollBackArtifact) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in SupportsRollback) @@ -768,8 +793,6 @@ Use 'commit' to update, or 'rollback' to roll back the update. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback )")); { @@ -793,9 +816,6 @@ SupportsRollback path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback -SupportsRollback ArtifactRollback ArtifactFailure Cleanup @@ -821,7 +841,14 @@ TEST(CliTest, RollbackAfterFailure) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in ArtifactInstall) @@ -861,7 +888,6 @@ Rolled back. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -SupportsRollback ArtifactRollback ArtifactFailure Cleanup @@ -888,7 +914,14 @@ TEST(CliTest, RollbackAfterFailureInDownload) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in Download) @@ -949,7 +982,14 @@ TEST(CliTest, FailedRollbackAfterFailure) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in ArtifactInstall) @@ -989,7 +1029,6 @@ Rollback failed. System may be in an inconsistent state. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -SupportsRollback ArtifactRollback ArtifactFailure Cleanup @@ -1012,7 +1051,14 @@ TEST(CliTest, NoRollbackAfterFailure) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in ArtifactInstall) @@ -1049,7 +1095,6 @@ Update Module does not support rollback. System may be in an inconsistent state. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -SupportsRollback ArtifactFailure Cleanup )")); @@ -1135,7 +1180,14 @@ TEST(CliTest, TryToRollBackWithoutSupport) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in SupportsRollback) @@ -1170,15 +1222,20 @@ Use 'commit' to update, or 'rollback' to roll back the update. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback )")); ASSERT_TRUE(PrepareUpdateModule(update_module, R"(#!/bin/bash TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac exit 0 )")); @@ -1206,9 +1263,6 @@ exit 0 path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback -SupportsRollback )")); EXPECT_TRUE(VerifyProvides(tmpdir.Path(), R"(rootfs-image.version=previous @@ -1228,7 +1282,14 @@ TEST(CliTest, InstallWithRebootRequiredNoArgument) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in NeedsArtifactReboot) @@ -1264,8 +1325,6 @@ At least one payload requested a reboot of the device it updated. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit Cleanup )")); @@ -1287,7 +1346,14 @@ TEST(CliTest, InstallWithRebootRequiredWithArgument) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in NeedsArtifactReboot) @@ -1324,8 +1390,6 @@ At least one payload requested a reboot of the device it updated. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit Cleanup )")); @@ -1350,7 +1414,14 @@ TEST(CliTest, InstallWhenUpdateInProgress) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in SupportsRollback) @@ -1385,8 +1456,6 @@ Use 'commit' to update, or 'rollback' to roll back the update. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback )")); { @@ -1406,8 +1475,6 @@ SupportsRollback path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback )")); } @@ -1425,7 +1492,21 @@ TEST(CliTest, InstallAndThenFailRollBack) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac + ;; +esac case "$1" in ArtifactRollback) @@ -1463,8 +1544,6 @@ Use 'commit' to update, or 'rollback' to roll back the update. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback )")); { @@ -1491,9 +1570,6 @@ SupportsRollback path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback -SupportsRollback ArtifactRollback ArtifactFailure Cleanup @@ -1534,7 +1610,14 @@ TEST(CliTest, InstallAndFailCleanup) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in Cleanup) @@ -1573,8 +1656,6 @@ Cleanup failed. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit Cleanup )")); @@ -1596,7 +1677,14 @@ TEST(CliTest, FailureInArtifactFailure) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in ArtifactInstall) @@ -1636,7 +1724,6 @@ Rollback failed. System may be in an inconsistent state. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -SupportsRollback ArtifactRollback ArtifactFailure Cleanup @@ -1693,7 +1780,14 @@ TEST(CliTest, InstallAndThenCommitLegacyArtifact) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in SupportsRollback) @@ -1728,8 +1822,6 @@ Use 'commit' to update, or 'rollback' to roll back the update. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback )")); { @@ -1753,8 +1845,6 @@ SupportsRollback path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit Cleanup )")); @@ -1778,7 +1868,14 @@ TEST(CliTest, InstallUsingOldClientAndThenCommitArtifact) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in SupportsRollback) @@ -1815,8 +1912,6 @@ Use 'commit' to update, or 'rollback' to roll back the update. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback )")); // Remove the Update Module working directory. This is what would have happened if upgrading @@ -1847,8 +1942,6 @@ SupportsRollback path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit Cleanup )")); @@ -1874,7 +1967,14 @@ TEST(CliTest, InstallUsingOldClientAndThenRollBackArtifact) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in SupportsRollback) @@ -1911,8 +2011,6 @@ Use 'commit' to update, or 'rollback' to roll back the update. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback )")); // Remove the Update Module working directory. This is what would have happened if upgrading @@ -1943,9 +2041,6 @@ SupportsRollback path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback -SupportsRollback ArtifactRollback ArtifactFailure Cleanup @@ -1997,7 +2092,14 @@ TEST(CliTest, InstallAndCommitArtifactFromNetwork) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac exit 0 )")); @@ -2028,8 +2130,6 @@ Installed and committed. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit Cleanup )")); @@ -2054,7 +2154,14 @@ TEST(CliTest, StopBeforeArtifactInstallThenResume) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac case "$1" in SupportsRollback) @@ -2113,8 +2220,6 @@ Use 'commit' to update, or 'rollback' to roll back the update. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback )")); { @@ -2138,8 +2243,6 @@ SupportsRollback path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit Cleanup )")); @@ -2164,7 +2267,14 @@ TEST(CliTest, StopBeforeArtifactCommit_LeaveThenResume) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac exit 0 )")); @@ -2195,8 +2305,6 @@ Installed and committed. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit )")); @@ -2221,8 +2329,6 @@ ArtifactCommit path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -NeedsArtifactReboot -SupportsRollback ArtifactCommit Cleanup )")); @@ -2259,7 +2365,21 @@ touch )" << commit_leave_run TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac + ;; +esac exit 0 )")); @@ -2381,7 +2501,14 @@ touch )" << commit_leave_run TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac if [ "$1" = "SupportsRollback" ]; then echo "Yes" @@ -2469,7 +2596,6 @@ ArtifactCommit Download ArtifactInstall ArtifactCommit -SupportsRollback ArtifactRollback ArtifactFailure Cleanup @@ -2498,7 +2624,14 @@ TEST(CliTest, StopBeforeArtifactRollback_Enter) { TEST_DIR=")" + tmpdir.Path() + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac if [ "$1" = "SupportsRollback" ]; then echo "Yes" @@ -2535,7 +2668,6 @@ Installation failed. path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -SupportsRollback )")); { @@ -2561,8 +2693,6 @@ SupportsRollback path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -SupportsRollback -SupportsRollback ArtifactRollback )")); @@ -2589,8 +2719,6 @@ ArtifactRollback path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -SupportsRollback -SupportsRollback ArtifactRollback ArtifactFailure )")); @@ -2616,8 +2744,6 @@ ArtifactFailure path::Join(tmpdir.Path(), "call.log"), R"(ProvidePayloadFileSizes Download ArtifactInstall -SupportsRollback -SupportsRollback ArtifactRollback ArtifactFailure Cleanup @@ -2663,8 +2789,6 @@ Download_Leave_01 ArtifactInstall_Enter_01 ArtifactInstall ArtifactInstall_Leave_01 -NeedsArtifactReboot -SupportsRollback ArtifactCommit_Enter_01 ArtifactCommit ArtifactCommit_Leave_01 @@ -2778,7 +2902,6 @@ Download_Leave_01 ArtifactInstall_Enter_01 ArtifactInstall_Error_01 ArtifactInstall_Error_02 -SupportsRollback ArtifactFailure_Enter_01 ArtifactFailure ArtifactFailure_Leave_01 @@ -2810,7 +2933,6 @@ ArtifactInstall_Enter_01 ArtifactInstall ArtifactInstall_Error_01 ArtifactInstall_Error_02 -SupportsRollback ArtifactFailure_Enter_01 ArtifactFailure ArtifactFailure_Leave_01 @@ -2846,7 +2968,6 @@ ArtifactInstall_Leave_01 ArtifactInstall_Leave_02 ArtifactInstall_Error_01 ArtifactInstall_Error_02 -SupportsRollback ArtifactFailure_Enter_01 ArtifactFailure ArtifactFailure_Leave_01 @@ -2881,12 +3002,9 @@ ArtifactInstall_Enter_01 ArtifactInstall_Enter_02 ArtifactInstall ArtifactInstall_Leave_01 -NeedsArtifactReboot -SupportsRollback ArtifactCommit_Enter_01 ArtifactCommit_Error_01 ArtifactCommit_Error_02 -SupportsRollback ArtifactFailure_Enter_01 ArtifactFailure ArtifactFailure_Leave_01 @@ -2919,13 +3037,10 @@ ArtifactInstall_Enter_01 ArtifactInstall_Enter_02 ArtifactInstall ArtifactInstall_Leave_01 -NeedsArtifactReboot -SupportsRollback ArtifactCommit_Enter_01 ArtifactCommit ArtifactCommit_Error_01 ArtifactCommit_Error_02 -SupportsRollback ArtifactFailure_Enter_01 ArtifactFailure ArtifactFailure_Leave_01 @@ -2958,8 +3073,6 @@ ArtifactInstall_Enter_01 ArtifactInstall ArtifactInstall_Leave_01 ArtifactInstall_Leave_02 -NeedsArtifactReboot -SupportsRollback ArtifactCommit_Enter_01 ArtifactCommit ArtifactCommit_Leave_01 @@ -2993,8 +3106,6 @@ ArtifactInstall_Enter_01 ArtifactInstall ArtifactInstall_Leave_01 ArtifactInstall_Leave_02 -NeedsArtifactReboot -SupportsRollback ArtifactCommit_Enter_01 ArtifactCommit ArtifactCommit_Leave_01 @@ -3030,10 +3141,7 @@ ArtifactInstall_Enter_01 ArtifactInstall_Enter_02 ArtifactInstall ArtifactInstall_Leave_01 -NeedsArtifactReboot -SupportsRollback ArtifactCommit_Enter_01 -SupportsRollback ArtifactFailure_Enter_01 ArtifactFailure_Enter_02 ArtifactFailure @@ -3069,10 +3177,7 @@ ArtifactInstall_Enter_01 ArtifactInstall_Enter_02 ArtifactInstall ArtifactInstall_Leave_01 -NeedsArtifactReboot -SupportsRollback ArtifactCommit_Enter_01 -SupportsRollback ArtifactFailure_Enter_01 ArtifactFailure_Enter_02 ArtifactFailure @@ -3109,9 +3214,6 @@ ArtifactInstall_Enter_01 ArtifactInstall_Enter_02 ArtifactInstall ArtifactInstall_Leave_01 -NeedsArtifactReboot -SupportsRollback -SupportsRollback ArtifactRollback_Enter_01 ArtifactRollback ArtifactRollback_Leave_01 @@ -3210,7 +3312,14 @@ TEST_P(StandaloneStateScriptTest, AllScriptSuccess) { string script = R"(#!/bin/bash TEST_DIR=")" + tmpdir_path + R"(" -echo "$1" >> $TEST_DIR/call.log +case "$1" in + NeedsArtifactReboot|SupportsRollback) + : + ;; + *) + echo "$1" >> $TEST_DIR/call.log + ;; +esac )"; if (common::StartsWith(GetParam().case_name, "rollback")) { script += R"(