Merge "services/device/device: exclude certain states from update/revert by default"
diff --git a/services/device/device/doc.go b/services/device/device/doc.go
index 76fa353..c048770 100644
--- a/services/device/device/doc.go
+++ b/services/device/device/doc.go
@@ -259,12 +259,12 @@
to the device manager service, or to application installations and instances.
The device revert flags are:
- -installation-state=
+ -installation-state=!Uninstalled
If non-empty, specifies allowed installation states (all others installations
get filtered out). The value of the flag is a comma-separated list of values
from among: [Active Uninstalled]. If the value is prefixed by '!', the list
acts as a blacklist (all matching installations get filtered out).
- -instance-state=
+ -instance-state=!Deleted
If non-empty, specifies allowed instance states (all other instances get
filtered out). The value of the flag is a comma-separated list of values from
among: [Launching Running Dying NotRunning Updating Deleted]. If the value is
@@ -289,12 +289,12 @@
to the device manager service, or to application installations and instances.
The device update flags are:
- -installation-state=
+ -installation-state=!Uninstalled
If non-empty, specifies allowed installation states (all others installations
get filtered out). The value of the flag is a comma-separated list of values
from among: [Active Uninstalled]. If the value is prefixed by '!', the list
acts as a blacklist (all matching installations get filtered out).
- -instance-state=
+ -instance-state=!Deleted
If non-empty, specifies allowed instance states (all other instances get
filtered out). The value of the flag is a comma-separated list of values from
among: [Launching Running Dying NotRunning Updating Deleted]. If the value is
diff --git a/services/device/device/update.go b/services/device/device/update.go
index 5829d05..e05b412 100644
--- a/services/device/device/update.go
+++ b/services/device/device/update.go
@@ -29,7 +29,11 @@
}
func init() {
- globify(cmdUpdate, runUpdate, &GlobSettings{HandlerParallelism: KindParallelism})
+ globify(cmdUpdate, runUpdate, &GlobSettings{
+ HandlerParallelism: KindParallelism,
+ InstanceStateFilter: ExcludeInstanceStates(device.InstanceStateDeleted),
+ InstallationStateFilter: ExcludeInstallationStates(device.InstallationStateUninstalled),
+ })
}
var cmdRevert = &cmdline.Command{
@@ -42,7 +46,11 @@
}
func init() {
- globify(cmdRevert, runRevert, &GlobSettings{HandlerParallelism: KindParallelism})
+ globify(cmdRevert, runRevert, &GlobSettings{
+ HandlerParallelism: KindParallelism,
+ InstanceStateFilter: ExcludeInstanceStates(device.InstanceStateDeleted),
+ InstallationStateFilter: ExcludeInstallationStates(device.InstallationStateUninstalled),
+ })
}
func instanceIsRunning(ctx *context.T, von string) (bool, error) {
diff --git a/services/device/device/update_test.go b/services/device/device/update_test.go
index d39981b..338c358 100644
--- a/services/device/device/update_test.go
+++ b/services/device/device/update_test.go
@@ -62,11 +62,18 @@
expectedError string
}{
{ // Everything succeeds.
- []string{"app/2", "app/1", "app/3"},
+ []string{"app/2", "app/1", "app/5", "app/3", "app/4"},
map[string][]interface{}{
"app/1": []interface{}{instanceRunning, nil, nil, nil},
"app/2": []interface{}{instanceNotRunning, nil},
"app/3": []interface{}{installationActive, nil},
+ // The uninstalled installation and the
+ // deleted instance should be excluded
+ // from the Update and Revert as per the
+ // default GlobSettings for the update
+ // and revert commands.
+ "app/4": []interface{}{installationUninstalled, nil},
+ "app/5": []interface{}{instanceDeleted, nil},
},
map[string][]interface{}{
"app/1": []interface{}{"Status", KillStimulus{"Kill", 10 * time.Second}, capitalize(cmd), "Run"},
diff --git a/services/device/device/util_test.go b/services/device/device/util_test.go
index 9b4bc6c..29c79eb 100644
--- a/services/device/device/util_test.go
+++ b/services/device/device/util_test.go
@@ -45,6 +45,10 @@
State: device.InstanceStateNotRunning,
Version: "special edition",
}}
+ instanceDeleted = device.StatusInstance{device.InstanceStatus{
+ State: device.InstanceStateDeleted,
+ Version: "mini series",
+ }}
deviceService = device.StatusDevice{device.DeviceStatus{
State: device.InstanceStateRunning,
Version: "han shot first",