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

Commit

Permalink
Merge pull request #1321 from mischief/wait-create
Browse files Browse the repository at this point in the history
undo quorum=true; wait for unit creation in fleetctl
  • Loading branch information
mischief committed Aug 7, 2015
2 parents 3d0b3d9 + 1816c53 commit d6bef22
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
21 changes: 21 additions & 0 deletions fleetctl/fleetctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 0 additions & 4 deletions registry/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion registry/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion registry/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d6bef22

Please sign in to comment.