File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ import (
1010
1111// handleResult is used to Write the latest States to Backend.
1212func (p * Plan ) handleResult (change * Change ) error {
13- if change .ActionName == statemanager .ActionUninstall {
13+ // uninstall succeeded
14+ if change .ActionName == statemanager .ActionUninstall && change .Result .Succeeded {
1415 p .smgr .DeleteState (change .Tool .Name )
1516 return p .smgr .Write (p .smgr .GetStates ().Format ())
1617 }
@@ -27,9 +28,15 @@ func (p *Plan) handleResult(change *Change) error {
2728 },
2829 )
2930
30- if change .Result .Error != nil {
31+ // uninstall failed
32+ if change .ActionName == statemanager .ActionUninstall && ! change .Result .Succeeded {
33+ state .Status = statemanager .StatusInstalled
34+ log .Printf ("=== plugin %s process failed ===" , change .Tool .Name )
35+ // install or reinstall failed
36+ } else if ! change .Result .Succeeded {
3137 state .Status = statemanager .StatusFailed
3238 log .Printf ("=== plugin %s process failed ===" , change .Tool .Name )
39+ // install or reinstall succeeded
3340 } else {
3441 log .Printf ("=== plugin %s process done ===" , change .Tool .Name )
3542 }
Original file line number Diff line number Diff line change @@ -13,9 +13,11 @@ type ComponentAction string
1313const (
1414 // We should delete the state of the "uninstalled" tool at States.
1515 StatusUninstalled ComponentStatus = "uninstalled"
16+ // We use StatusInstalled when a plugin is installed but we don't know its status is "running" or "failed".
17+ // For example: We try to uninstall a plugin but failed for some reason.
1618 StatusInstalled ComponentStatus = "installed"
1719 StatusRunning ComponentStatus = "running"
18- StatusFailed ComponentStatus = "Failed "
20+ StatusFailed ComponentStatus = "failed "
1921)
2022
2123const (
You can’t perform that action at this time.
0 commit comments