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

Commit

Permalink
fleetctl: on destroy command ignore units that do not exist
Browse files Browse the repository at this point in the history
fleetctl used to ignore requests to destory units which do not actually exist.
This behaviour was changed by commit 9530eed, restore the older behaviour by calling findUnits()
to get the right list of units.

This fixes: #1383
  • Loading branch information
Djalal Harouni committed Feb 1, 2016
1 parent 189dacf commit ad70248
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions fleetctl/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ Destroyed units are impossible to start unless re-submitted.`,
}

func runDestroyUnits(args []string) (exit int) {
for _, v := range args {
name := unitNameMangle(v)
err := cAPI.DestroyUnit(name)
units, err := findUnits(args)
if err != nil {
stderr("%v", err)
return 1
}

for _, v := range units {
err := cAPI.DestroyUnit(v.Name)
if err != nil {
stderr("Error destroying units: %v", err)
exit = 1
Expand All @@ -56,7 +61,7 @@ func runDestroyUnits(args []string) (exit int) {
}

for retry() {
u, err := cAPI.Unit(name)
u, err := cAPI.Unit(v.Name)
if err != nil {
stderr("Error destroying units: %v", err)
exit = 1
Expand All @@ -70,7 +75,7 @@ func runDestroyUnits(args []string) (exit int) {
}
}

stdout("Destroyed %s", name)
stdout("Destroyed %s", v.Name)
}
return
}

0 comments on commit ad70248

Please sign in to comment.