Skip to content

Commit 500e04a

Browse files
authored
allocator: Fix Array parsing to slice parsing (#346)
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>
1 parent 1e9d805 commit 500e04a

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

cmd/platform/allocator/vacate.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ var vacateAllocatorCmd = &cobra.Command{
8989
return err
9090
}
9191

92-
resources, err := cmd.Flags().GetStringArray("resource-id")
92+
resources, err := cmd.Flags().GetStringSlice("resource-id")
9393
if err != nil {
9494
return err
9595
}
@@ -143,8 +143,9 @@ var vacateAllocatorCmd = &cobra.Command{
143143
if setAllocatorMaintenance {
144144
for _, id := range args {
145145
var params = allocatorapi.MaintenanceParams{
146-
API: ecctl.Get().API,
147-
ID: id,
146+
API: ecctl.Get().API,
147+
ID: id,
148+
Region: ecctl.Get().Config.Region,
148149
}
149150
if err := allocatorapi.StartMaintenance(params); err != nil {
150151
merr = merr.Append(err)
@@ -197,8 +198,8 @@ func init() {
197198
Command.AddCommand(vacateAllocatorCmd)
198199
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.")
199200
vacateAllocatorCmd.Flags().StringP("kind", "k", "", "Kind of workload to vacate (elasticsearch|kibana|apm|appsearch|enterprise_search)")
200-
vacateAllocatorCmd.Flags().StringArrayP("resource-id", "r", nil, "Resource IDs to include in the vacate")
201-
vacateAllocatorCmd.Flags().StringArrayP("target", "t", nil, "Target allocator(s) on which to place the vacated workload")
201+
vacateAllocatorCmd.Flags().StringSliceP("resource-id", "r", nil, "Resource IDs to include in the vacate")
202+
vacateAllocatorCmd.Flags().StringSliceP("target", "t", nil, "Target allocator(s) on which to place the vacated workload")
202203
vacateAllocatorCmd.Flags().BoolP("maintenance", "m", false, "Whether to set the allocator(s) in maintenance before performing the vacate")
203204
vacateAllocatorCmd.Flags().Uint("concurrency", 8, "Maximum number of concurrent moves to perform at any time")
204205
vacateAllocatorCmd.Flags().String("allocator-down", "", "Disables the allocator health auto-discovery, setting the allocator-down to either [true|false]")

docs/ecctl_platform_allocator_vacate.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ ecctl platform allocator vacate <allocator-id> [flags]
6363
--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)
6464
--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]
6565
--poll-frequency duration Optional polling frequency to check for plan change updates (default 10s)
66-
-r, --resource-id stringArray Resource IDs to include in the vacate
66+
-r, --resource-id strings Resource IDs to include in the vacate
6767
--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]
6868
--skip-snapshot string Skips the snapshot operation on the specified resource IDs. ONLY available when the resource IDs are specified. [true|false]
6969
--skip-tracking Skips tracking the vacate progress causing the command to return after the move operation has been executed. Not recommended.
70-
-t, --target stringArray Target allocator(s) on which to place the vacated workload
70+
-t, --target strings Target allocator(s) on which to place the vacated workload
7171
----
7272

7373
[float]

docs/ecctl_platform_allocator_vacate.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ ecctl platform allocator vacate <allocator-id> [flags]
6060
--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)
6161
--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]
6262
--poll-frequency duration Optional polling frequency to check for plan change updates (default 10s)
63-
-r, --resource-id stringArray Resource IDs to include in the vacate
63+
-r, --resource-id strings Resource IDs to include in the vacate
6464
--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]
6565
--skip-snapshot string Skips the snapshot operation on the specified resource IDs. ONLY available when the resource IDs are specified. [true|false]
6666
--skip-tracking Skips tracking the vacate progress causing the command to return after the move operation has been executed. Not recommended.
67-
-t, --target stringArray Target allocator(s) on which to place the vacated workload
67+
-t, --target strings Target allocator(s) on which to place the vacated workload
6868
```
6969

7070
### Options inherited from parent commands

0 commit comments

Comments
 (0)