Пример #1
0
Файл: run.go Проект: pulcy/j2
// isFailedPredicate creates a predicate that returns true when the given unit file is in the failed status.
func (d *Deployment) isFailedPredicate(sg scalingGroupUnits, f scheduler.Scheduler, ui *stateUI) func(string) bool {
	return func(unitName string) bool {
		ui.MessageSink <- fmt.Sprintf("Checking state of %s", unitName)
		unitState, err := f.GetState(unitName)
		if scheduler.IsNotFound(err) {
			ui.Verbosef("Unit '%s' is not found\n", unitName)
			return true
		} else if err != nil {
			ui.Warningf("GetState(%s) failed: %#v", unitName, err)
		}
		if unitState.Failed {
			ui.Verbosef("Unit '%s' is in failed state\n", unitName)
			return true
		}
		return false
	}
}