Skip to content

Commit

Permalink
Merge pull request mendersoftware#1581 from SebOpsahl/3.5.x
Browse files Browse the repository at this point in the history
fix: doing so return 1 in Download_Enter state scripts aborts instead of retrying in an endless loop
  • Loading branch information
Kristian Amlie authored Feb 16, 2024
2 parents be40bc8 + 78ae9fd commit a4575f5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
10 changes: 10 additions & 0 deletions app/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,16 @@ func (uf *updateFetchState) Update() *datastore.UpdateInfo {
return &uf.update
}

func (uf *updateFetchState) HandleError(
ctx *StateContext,
c Controller,
err menderError,
) (State, bool) {
log.Error(err.Error())

return NewUpdateErrorState(err, uf.Update()), false
}

func (uf *updateFetchState) PermitLooping() bool {
return false
}
Expand Down
32 changes: 30 additions & 2 deletions app/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,32 @@ var stateTransitionsWithUpdateModulesTestCases []stateTransitionsWithUpdateModul
installOutcome: tests.SuccessfulRollback,
},

{
caseName: "Error in Download state, with rollback",
stateChain: []State{
&updateFetchState{},
&updateStoreState{},
&updateCleanupState{},
&updateStatusReportState{},
&idleState{},
},
artifactStateChain: []string{
"Download_Enter_00",
"Download",
"Download_Error_00",
"Cleanup",
},
reportsLog: []string{
"downloading",
"failure",
},
TestModuleAttr: tests.TestModuleAttr{
ErrorStates: []string{"Download"},
RollbackDisabled: false,
},
installOutcome: tests.SuccessfulRollback,
},

{
caseName: "Killed in Download state, no rollback",
stateChain: []State{
Expand Down Expand Up @@ -2583,14 +2609,16 @@ var stateTransitionsWithUpdateModulesTestCases []stateTransitionsWithUpdateModul
caseName: "Error in Download_Enter_00 state, no rollback",
stateChain: []State{
&updateFetchState{},
&errorState{},
&updateErrorState{},
&updateCleanupState{},
&updateStatusReportState{},
&idleState{},
},
artifactStateChain: []string{
"Download_Enter_00",
"Download_Error_00",
},
reportsLog: []string{""},
reportsLog: []string{"failure"},
TestModuleAttr: tests.TestModuleAttr{
ErrorStates: []string{"Download_Enter_00"},
RollbackDisabled: true,
Expand Down

0 comments on commit a4575f5

Please sign in to comment.