Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit b9eca79

Browse files
committed
Merge pull request #1333 from mischief/global
fleetctl: wait for DesiredState instead of CurrentState for global units
2 parents d5ff500 + 371dd3b commit b9eca79

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

fleetctl/fleetctl.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ func checkUnitState(name string, js job.JobState, maxAttempts int, out io.Writer
792792
}
793793

794794
func assertUnitState(name string, js job.JobState, out io.Writer) (ret bool) {
795+
var state string
796+
795797
u, err := cAPI.Unit(name)
796798
if err != nil {
797799
log.Warningf("Error retrieving Unit(%s) from Registry: %v", name, err)
@@ -801,8 +803,16 @@ func assertUnitState(name string, js job.JobState, out io.Writer) (ret bool) {
801803
log.Warningf("Unit %s not found", name)
802804
return
803805
}
804-
if job.JobState(u.CurrentState) != js {
805-
log.Debugf("Waiting for Unit(%s) state(%s) to be %s", name, job.JobState(u.CurrentState), js)
806+
807+
// If this is a global unit, CurrentState will never be set. Instead, wait for DesiredState.
808+
if suToGlobal(*u) {
809+
state = u.DesiredState
810+
} else {
811+
state = u.CurrentState
812+
}
813+
814+
if job.JobState(state) != js {
815+
log.Debugf("Waiting for Unit(%s) state(%s) to be %s", name, job.JobState(state), js)
806816
return
807817
}
808818

0 commit comments

Comments
 (0)