Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Upgrade Details] When state is set to something other than StateFailed, clear related metadata fields #3690

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions internal/pkg/agent/application/upgrade/details/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ func (d *Details) SetState(s State) {
defer d.mu.Unlock()

d.State = s

// If State is something other than StateFailed, make sure to clear
// Metadata.FailedState and Metadata.ErrorMsg as those two fields
// should be set when State is set to StateFailed. See the Fail method.
if s != StateFailed {
d.Metadata.ErrorMsg = ""
d.Metadata.FailedState = ""
}

d.notifyObservers()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ func TestDetailsFail(t *testing.T) {
require.Equal(t, StateFailed, det.State)
require.Equal(t, StateRequested, det.Metadata.FailedState)
require.Equal(t, err.Error(), det.Metadata.ErrorMsg)

// Check that resetting state to something other than StateFailed
// clears Metadata.FailedState and Metadata.ErrorMsg
det.SetState(StateDownloading)
require.Equal(t, State(""), det.Metadata.FailedState)
require.Equal(t, "", det.Metadata.ErrorMsg)
}

func TestDetailsObserver(t *testing.T) {
Expand Down