Skip to content

Commit

Permalink
allocator: Fix Array parsing to slice parsing (#346)
Browse files Browse the repository at this point in the history
Fixes a bug where the `--target` parameter was being ignored due to the
flag parsing using `GetStringSlice` when the flag decaration is `Array`.

The bug changes the type from an ArrayString to SliceString.

Additionally, fixes `--maintenance` call which is missing a region value.

Signed-off-by: Marc Lopez <marc5.12@outlook.com>
  • Loading branch information
marclop committed Jul 20, 2020
1 parent 1e9d805 commit 500e04a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions cmd/platform/allocator/vacate.go
Expand Up @@ -89,7 +89,7 @@ var vacateAllocatorCmd = &cobra.Command{
return err
}

resources, err := cmd.Flags().GetStringArray("resource-id")
resources, err := cmd.Flags().GetStringSlice("resource-id")
if err != nil {
return err
}
Expand Down Expand Up @@ -143,8 +143,9 @@ var vacateAllocatorCmd = &cobra.Command{
if setAllocatorMaintenance {
for _, id := range args {
var params = allocatorapi.MaintenanceParams{
API: ecctl.Get().API,
ID: id,
API: ecctl.Get().API,
ID: id,
Region: ecctl.Get().Config.Region,
}
if err := allocatorapi.StartMaintenance(params); err != nil {
merr = merr.Append(err)
Expand Down Expand Up @@ -197,8 +198,8 @@ func init() {
Command.AddCommand(vacateAllocatorCmd)
vacateAllocatorCmd.Flags().Bool("skip-tracking", false, "Skips tracking the vacate progress causing the command to return after the move operation has been executed. Not recommended.")
vacateAllocatorCmd.Flags().StringP("kind", "k", "", "Kind of workload to vacate (elasticsearch|kibana|apm|appsearch|enterprise_search)")
vacateAllocatorCmd.Flags().StringArrayP("resource-id", "r", nil, "Resource IDs to include in the vacate")
vacateAllocatorCmd.Flags().StringArrayP("target", "t", nil, "Target allocator(s) on which to place the vacated workload")
vacateAllocatorCmd.Flags().StringSliceP("resource-id", "r", nil, "Resource IDs to include in the vacate")
vacateAllocatorCmd.Flags().StringSliceP("target", "t", nil, "Target allocator(s) on which to place the vacated workload")
vacateAllocatorCmd.Flags().BoolP("maintenance", "m", false, "Whether to set the allocator(s) in maintenance before performing the vacate")
vacateAllocatorCmd.Flags().Uint("concurrency", 8, "Maximum number of concurrent moves to perform at any time")
vacateAllocatorCmd.Flags().String("allocator-down", "", "Disables the allocator health auto-discovery, setting the allocator-down to either [true|false]")
Expand Down
4 changes: 2 additions & 2 deletions docs/ecctl_platform_allocator_vacate.adoc
Expand Up @@ -63,11 +63,11 @@ ecctl platform allocator vacate <allocator-id> [flags]
--move-only Keeps the resource in its current -possibly broken- state and just does the bare minimum to move the requested instances across to another allocator. [true|false] (default true)
--override-failsafe If false (the default) then the plan will fail out if it believes the requested sequence of operations can result in data loss - this flag will override some of these restraints. [true|false]
--poll-frequency duration Optional polling frequency to check for plan change updates (default 10s)
-r, --resource-id stringArray Resource IDs to include in the vacate
-r, --resource-id strings Resource IDs to include in the vacate
--skip-data-migration string Skips the data-migration operation on the specified resource IDs. ONLY available when the resource IDs are specified and --move-only is true. [true|false]
--skip-snapshot string Skips the snapshot operation on the specified resource IDs. ONLY available when the resource IDs are specified. [true|false]
--skip-tracking Skips tracking the vacate progress causing the command to return after the move operation has been executed. Not recommended.
-t, --target stringArray Target allocator(s) on which to place the vacated workload
-t, --target strings Target allocator(s) on which to place the vacated workload
----

[float]
Expand Down
4 changes: 2 additions & 2 deletions docs/ecctl_platform_allocator_vacate.md
Expand Up @@ -60,11 +60,11 @@ ecctl platform allocator vacate <allocator-id> [flags]
--move-only Keeps the resource in its current -possibly broken- state and just does the bare minimum to move the requested instances across to another allocator. [true|false] (default true)
--override-failsafe If false (the default) then the plan will fail out if it believes the requested sequence of operations can result in data loss - this flag will override some of these restraints. [true|false]
--poll-frequency duration Optional polling frequency to check for plan change updates (default 10s)
-r, --resource-id stringArray Resource IDs to include in the vacate
-r, --resource-id strings Resource IDs to include in the vacate
--skip-data-migration string Skips the data-migration operation on the specified resource IDs. ONLY available when the resource IDs are specified and --move-only is true. [true|false]
--skip-snapshot string Skips the snapshot operation on the specified resource IDs. ONLY available when the resource IDs are specified. [true|false]
--skip-tracking Skips tracking the vacate progress causing the command to return after the move operation has been executed. Not recommended.
-t, --target stringArray Target allocator(s) on which to place the vacated workload
-t, --target strings Target allocator(s) on which to place the vacated workload
```

### Options inherited from parent commands
Expand Down

0 comments on commit 500e04a

Please sign in to comment.