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

Commit ad70248

Browse files
author
Djalal Harouni
committed
fleetctl: on destroy command ignore units that do not exist
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
1 parent 189dacf commit ad70248

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

fleetctl/destroy.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ Destroyed units are impossible to start unless re-submitted.`,
3333
}
3434

3535
func runDestroyUnits(args []string) (exit int) {
36-
for _, v := range args {
37-
name := unitNameMangle(v)
38-
err := cAPI.DestroyUnit(name)
36+
units, err := findUnits(args)
37+
if err != nil {
38+
stderr("%v", err)
39+
return 1
40+
}
41+
42+
for _, v := range units {
43+
err := cAPI.DestroyUnit(v.Name)
3944
if err != nil {
4045
stderr("Error destroying units: %v", err)
4146
exit = 1
@@ -56,7 +61,7 @@ func runDestroyUnits(args []string) (exit int) {
5661
}
5762

5863
for retry() {
59-
u, err := cAPI.Unit(name)
64+
u, err := cAPI.Unit(v.Name)
6065
if err != nil {
6166
stderr("Error destroying units: %v", err)
6267
exit = 1
@@ -70,7 +75,7 @@ func runDestroyUnits(args []string) (exit int) {
7075
}
7176
}
7277

73-
stdout("Destroyed %s", name)
78+
stdout("Destroyed %s", v.Name)
7479
}
7580
return
7681
}

0 commit comments

Comments
 (0)