diff --git a/fleetctl/fleetctl.go b/fleetctl/fleetctl.go index cf8048ec2..d7c88c950 100644 --- a/fleetctl/fleetctl.go +++ b/fleetctl/fleetctl.go @@ -595,6 +595,8 @@ func createUnit(name string, uf *unit.UnitFile) (*schema.Unit, error) { // subsequent Jobs are not acted on). An error is also returned if none of the // above conditions match a given Job. func lazyCreateUnits(args []string) error { + errchan := make(chan error) + var wg sync.WaitGroup for _, arg := range args { // TODO(jonboulle): this loop is getting too unwieldy; factor it out @@ -660,7 +662,26 @@ func lazyCreateUnits(args []string) error { if err != nil { return err } + + wg.Add(1) + go checkUnitState(name, job.JobStateInactive, sharedFlags.BlockAttempts, os.Stdout, &wg, errchan) + } + + go func() { + wg.Wait() + close(errchan) + }() + + haserr := false + for msg := range errchan { + stderr("Error waiting on unit creation: %v", msg) + haserr = true } + + if haserr { + return fmt.Errorf("One or more errors creating units") + } + return nil } diff --git a/registry/job.go b/registry/job.go index 72fd6f2cb..2b111842f 100644 --- a/registry/job.go +++ b/registry/job.go @@ -37,7 +37,6 @@ func (r *EtcdRegistry) Schedule() ([]job.ScheduledUnit, error) { opts := &etcd.GetOptions{ Sort: true, Recursive: true, - Quorum: true, } res, err := r.kAPI.Get(r.ctx(), key, opts) if err != nil { @@ -93,7 +92,6 @@ func (r *EtcdRegistry) Units() ([]job.Unit, error) { opts := &etcd.GetOptions{ Sort: true, Recursive: true, - Quorum: true, } res, err := r.kAPI.Get(r.ctx(), key, opts) if err != nil { @@ -136,7 +134,6 @@ func (r *EtcdRegistry) Unit(name string) (*job.Unit, error) { key := r.prefixed(jobPrefix, name) opts := &etcd.GetOptions{ Recursive: true, - Quorum: true, } res, err := r.kAPI.Get(r.ctx(), key, opts) if err != nil { @@ -187,7 +184,6 @@ func (r *EtcdRegistry) ScheduledUnit(name string) (*job.ScheduledUnit, error) { key := r.prefixed(jobPrefix, name) opts := &etcd.GetOptions{ Recursive: true, - Quorum: true, } res, err := r.kAPI.Get(r.ctx(), key, opts) if err != nil { diff --git a/registry/machine.go b/registry/machine.go index 972d7c722..e84a4f5fc 100644 --- a/registry/machine.go +++ b/registry/machine.go @@ -32,7 +32,6 @@ func (r *EtcdRegistry) Machines() (machines []machine.MachineState, err error) { opts := &etcd.GetOptions{ Sort: true, Recursive: true, - Quorum: true, } resp, err := r.kAPI.Get(r.ctx(), key, opts) diff --git a/registry/unit.go b/registry/unit.go index ac1094c2b..4adceb4b9 100644 --- a/registry/unit.go +++ b/registry/unit.go @@ -53,7 +53,6 @@ func (r *EtcdRegistry) getUnitByHash(hash unit.Hash) *unit.UnitFile { key := r.hashedUnitPath(hash) opts := &etcd.GetOptions{ Recursive: true, - Quorum: true, } resp, err := r.kAPI.Get(r.ctx(), key, opts) if err != nil {