Skip to content

Commit 0ab9525

Browse files
authored
cmd: Change --cluster flag to --resource-id (#270)
Changes the --cluster flag to --resource-id for allocator vacate and improves wording within the command
1 parent e6fdaf1 commit 0ab9525

File tree

6 files changed

+84
-84
lines changed

6 files changed

+84
-84
lines changed

cmd/platform/allocator/vacate.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,43 +33,43 @@ import (
3333
"github.com/elastic/ecctl/pkg/platform/allocator"
3434
)
3535

36-
const vacateExamples = ` ecctl [globalFlags] allocator vacate i-05e245252362f7f1d
36+
const vacateExamples = ` ecctl platform allocator vacate i-05e245252362f7f1d
3737
# Move everything from multiple allocators
38-
ecctl [globalFlags] allocator vacate i-05e245252362f7f1d i-2362f7f1d252362f7
38+
ecctl platform allocator vacate i-05e245252362f7f1d i-2362f7f1d252362f7
3939
40-
# filter by a cluster kind
41-
ecctl [globalFlags] allocator vacate -k kibana i-05e245252362f7f1d
40+
# filter by a resource kind
41+
ecctl platform allocator vacate -k kibana i-05e245252362f7f1d
4242
43-
# Only move specific cluster IDs
44-
ecctl [globalFlags] allocator vacate -c f521dedb07194c478fbbc6624f3bbf8f -c f404eea372cc4ea5bd553d47a09705cd i-05e245252362f7f1d
43+
# Only move specific resource IDs
44+
ecctl platform allocator vacate -r f521dedb07194c478fbbc6624f3bbf8f -r f404eea372cc4ea5bd553d47a09705cd i-05e245252362f7f1d
4545
4646
# Specify multiple allocator targets
47-
ecctl [globalFlags] allocator vacate -t i-05e245252362f7f2d -t i-2362f7f1d252362f7 i-05e245252362f7f1d
48-
ecctl [globalFlags] allocator vacate --target i-05e245252362f7f2d --target i-2362f7f1d252362f7 --kind kibana i-05e245252362f7f1d
47+
ecctl platform allocator vacate -t i-05e245252362f7f2d -t i-2362f7f1d252362f7 i-05e245252362f7f1d
48+
ecctl platform allocator vacate --target i-05e245252362f7f2d --target i-2362f7f1d252362f7 --kind kibana i-05e245252362f7f1d
4949
5050
# Set the allocators to maintenance mode before vacating them
51-
ecctl [globalFlags] allocator vacate --maintenance -t i-05e245252362f7f2d -t i-2362f7f1d252362f7 i-05e245252362f7f1d
51+
ecctl platform allocator vacate --maintenance -t i-05e245252362f7f2d -t i-2362f7f1d252362f7 i-05e245252362f7f1d
5252
5353
# Set the amount of maximum moves to happen at any time
54-
ecctl [globalFlags] allocator vacate --concurrency 10 i-05e245252362f7f1d
54+
ecctl platform allocator vacate --concurrency 10 i-05e245252362f7f1d
5555
5656
# Override the allocator health auto discovery
57-
ecctl [globalFlags] allocator vacate --allocator-down=true i-05e245252362f7f1d
57+
ecctl platform allocator vacate --allocator-down=true i-05e245252362f7f1d
5858
5959
# Override the skip_snapshot setting
60-
ecctl [globalFlags] allocator vacate --skip-snapshot=true i-05e245252362f7f1d -c f521dedb07194c478fbbc6624f3bbf8f
60+
ecctl platform allocator vacate --skip-snapshot=true i-05e245252362f7f1d -r f521dedb07194c478fbbc6624f3bbf8f
6161
6262
# Override the skip_data_migration setting
63-
ecctl [globalFlags] allocator vacate --skip-data-migration=true i-05e245252362f7f1d -c f521dedb07194c478fbbc6624f3bbf8f
63+
ecctl platform allocator vacate --skip-data-migration=true i-05e245252362f7f1d -r f521dedb07194c478fbbc6624f3bbf8f
6464
6565
# Skips tracking the vacate progress which will cause the command to return almost immediately.
6666
# Not recommended since it can lead to failed vacates without the operator knowing about them.
67-
ecctl [globalFlags] allocator vacate --skip-tracking i-05e245252362f7f1d
67+
ecctl platform allocator vacate --skip-tracking i-05e245252362f7f1d
6868
`
6969

7070
var vacateAllocatorCmd = &cobra.Command{
71-
Use: "vacate <source>",
72-
Short: "Moves all the clusters from the specified allocator",
71+
Use: "vacate <allocator-id>",
72+
Short: "Moves all the resources from the specified allocator",
7373
Example: vacateExamples,
7474
PreRunE: cobra.MinimumNArgs(1),
7575
Aliases: []string{"move-nodes"},
@@ -89,7 +89,7 @@ var vacateAllocatorCmd = &cobra.Command{
8989
return err
9090
}
9191

92-
clusters, err := cmd.Flags().GetStringArray("cluster")
92+
resources, err := cmd.Flags().GetStringArray("resource-id")
9393
if err != nil {
9494
return err
9595
}
@@ -121,7 +121,7 @@ var vacateAllocatorCmd = &cobra.Command{
121121
return err
122122
}
123123

124-
err = validateSkipDataMigration(clusters, moveOnly)
124+
err = validateSkipDataMigration(resources, moveOnly)
125125
if err != nil && skipDataMigrationRaw != "" {
126126
return err
127127
}
@@ -161,7 +161,7 @@ var vacateAllocatorCmd = &cobra.Command{
161161
API: ecctl.Get().API,
162162
Allocators: args,
163163
PreferredAllocators: target,
164-
ClusterFilter: clusters,
164+
ClusterFilter: resources,
165165
KindFilter: kind,
166166
Concurrency: uint16(concurrency),
167167
Output: ecctl.Get().Config.OutputDevice,
@@ -184,9 +184,9 @@ var vacateAllocatorCmd = &cobra.Command{
184184
},
185185
}
186186

187-
func validateSkipDataMigration(clusters []string, moveOnly bool) error {
188-
if len(clusters) < 1 || !moveOnly {
189-
return errors.New("skip data migration is not available if there are no cluster IDs specified or move-only is set to false")
187+
func validateSkipDataMigration(resources []string, moveOnly bool) error {
188+
if len(resources) < 1 || !moveOnly {
189+
return errors.New("skip data migration is not available if there are no resource IDs specified or move-only is set to false")
190190
}
191191

192192
return nil
@@ -196,14 +196,14 @@ func init() {
196196
Command.AddCommand(vacateAllocatorCmd)
197197
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.")
198198
vacateAllocatorCmd.Flags().StringP("kind", "k", "", "Kind of workload to vacate (elasticsearch|kibana)")
199-
vacateAllocatorCmd.Flags().StringArrayP("cluster", "c", nil, "Cluster IDs to include in the vacate")
199+
vacateAllocatorCmd.Flags().StringArrayP("resource-id", "r", nil, "Resource IDs to include in the vacate")
200200
vacateAllocatorCmd.Flags().StringArrayP("target", "t", nil, "Target allocator(s) on which to place the vacated workload")
201201
vacateAllocatorCmd.Flags().BoolP("maintenance", "m", false, "Whether to set the allocator(s) in maintenance before performing the vacate")
202202
vacateAllocatorCmd.Flags().Uint("concurrency", 8, "Maximum number of concurrent moves to perform at any time")
203203
vacateAllocatorCmd.Flags().String("allocator-down", "", "Disables the allocator health auto-discovery, setting the allocator-down to either [true|false]")
204-
vacateAllocatorCmd.Flags().Bool("move-only", true, "Keeps the cluster in its current -possibly broken- state and just does the bare minimum to move the requested instances across to another allocator. [true|false]")
204+
vacateAllocatorCmd.Flags().Bool("move-only", true, "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]")
205205
vacateAllocatorCmd.Flags().Bool("override-failsafe", false, "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]")
206-
vacateAllocatorCmd.Flags().String("skip-snapshot", "", "Skips the snapshot operation on the specified cluster IDs. ONLY available when the cluster IDs are specified. [true|false]")
207-
vacateAllocatorCmd.Flags().String("skip-data-migration", "", "Skips the data-migration operation on the specified cluster IDs. ONLY available when the cluster IDs are specified and --move-only is true. [true|false]")
206+
vacateAllocatorCmd.Flags().String("skip-snapshot", "", "Skips the snapshot operation on the specified resource IDs. ONLY available when the resource IDs are specified. [true|false]")
207+
vacateAllocatorCmd.Flags().String("skip-data-migration", "", "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]")
208208
cmdutil.AddTrackFlags(vacateAllocatorCmd)
209209
}

cmd/platform/allocator/vacate_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424

2525
func TestValidateSkipDataMigration(t *testing.T) {
2626
type args struct {
27-
clusters []string
28-
moveOnly bool
27+
resources []string
28+
moveOnly bool
2929
}
3030
tests := []struct {
3131
name string
@@ -34,35 +34,35 @@ func TestValidateSkipDataMigration(t *testing.T) {
3434
err error
3535
}{
3636
{
37-
name: "Succeeds if a cluster has been set and moveOnly is set to true",
37+
name: "Succeeds if a resource has been set and moveOnly is set to true",
3838
args: args{
39-
clusters: []string{"0f32fa44e"},
40-
moveOnly: true,
39+
resources: []string{"0f32fa44e"},
40+
moveOnly: true,
4141
},
4242
wantErr: false,
4343
},
4444
{
45-
name: "Returns an error if a cluster has been set and moveOnly is set to false",
45+
name: "Returns an error if a resource has been set and moveOnly is set to false",
4646
args: args{
47-
clusters: []string{"0f32fa44e"},
48-
moveOnly: false,
47+
resources: []string{"0f32fa44e"},
48+
moveOnly: false,
4949
},
5050
wantErr: true,
51-
err: errors.New("skip data migration is not available if there are no cluster IDs specified or move-only is set to false"),
51+
err: errors.New("skip data migration is not available if there are no resource IDs specified or move-only is set to false"),
5252
},
5353
{
54-
name: "Returns an error if no cluster has been set and moveOnly is set to true",
54+
name: "Returns an error if no resource has been set and moveOnly is set to true",
5555
args: args{
56-
clusters: []string{},
57-
moveOnly: true,
56+
resources: []string{},
57+
moveOnly: true,
5858
},
5959
wantErr: true,
60-
err: errors.New("skip data migration is not available if there are no cluster IDs specified or move-only is set to false"),
60+
err: errors.New("skip data migration is not available if there are no resource IDs specified or move-only is set to false"),
6161
},
6262
}
6363
for _, tt := range tests {
6464
t.Run(tt.name, func(t *testing.T) {
65-
err := validateSkipDataMigration(tt.args.clusters, tt.args.moveOnly)
65+
err := validateSkipDataMigration(tt.args.resources, tt.args.moveOnly)
6666

6767
if (err != nil) != tt.wantErr {
6868
t.Errorf("validateSkipDataMigration() error = %v, wantErr %v", err, tt.wantErr)

docs/ecctl_platform_allocator.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ ecctl platform allocator [flags]
5050
* xref:ecctl_platform_allocator_metadata[ecctl platform allocator metadata] - Manages an allocator's metadata
5151
* xref:ecctl_platform_allocator_search[ecctl platform allocator search] - Performs advanced allocator searching
5252
* xref:ecctl_platform_allocator_show[ecctl platform allocator show] - Returns information about the allocator
53-
* xref:ecctl_platform_allocator_vacate[ecctl platform allocator vacate] - Moves all the clusters from the specified allocator
53+
* xref:ecctl_platform_allocator_vacate[ecctl platform allocator vacate] - Moves all the resources from the specified allocator

docs/ecctl_platform_allocator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ ecctl platform allocator [flags]
4545
* [ecctl platform allocator metadata](ecctl_platform_allocator_metadata.md) - Manages an allocator's metadata
4646
* [ecctl platform allocator search](ecctl_platform_allocator_search.md) - Performs advanced allocator searching
4747
* [ecctl platform allocator show](ecctl_platform_allocator_show.md) - Returns information about the allocator
48-
* [ecctl platform allocator vacate](ecctl_platform_allocator_vacate.md) - Moves all the clusters from the specified allocator
48+
* [ecctl platform allocator vacate](ecctl_platform_allocator_vacate.md) - Moves all the resources from the specified allocator
4949

docs/ecctl_platform_allocator_vacate.adoc

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
11
[#ecctl_platform_allocator_vacate]
22
== ecctl platform allocator vacate
33

4-
Moves all the clusters from the specified allocator
4+
Moves all the resources from the specified allocator
55

66
[float]
77
=== Synopsis
88

9-
Moves all the clusters from the specified allocator
9+
Moves all the resources from the specified allocator
1010

1111
----
12-
ecctl platform allocator vacate <source> [flags]
12+
ecctl platform allocator vacate <allocator-id> [flags]
1313
----
1414

1515
[float]
1616
=== Examples
1717

1818
----
19-
ecctl [globalFlags] allocator vacate i-05e245252362f7f1d
19+
ecctl platform allocator vacate i-05e245252362f7f1d
2020
# Move everything from multiple allocators
21-
ecctl [globalFlags] allocator vacate i-05e245252362f7f1d i-2362f7f1d252362f7
21+
ecctl platform allocator vacate i-05e245252362f7f1d i-2362f7f1d252362f7
2222
23-
# filter by a cluster kind
24-
ecctl [globalFlags] allocator vacate -k kibana i-05e245252362f7f1d
23+
# filter by a resource kind
24+
ecctl platform allocator vacate -k kibana i-05e245252362f7f1d
2525
26-
# Only move specific cluster IDs
27-
ecctl [globalFlags] allocator vacate -c f521dedb07194c478fbbc6624f3bbf8f -c f404eea372cc4ea5bd553d47a09705cd i-05e245252362f7f1d
26+
# Only move specific resource IDs
27+
ecctl platform allocator vacate -r f521dedb07194c478fbbc6624f3bbf8f -r f404eea372cc4ea5bd553d47a09705cd i-05e245252362f7f1d
2828
2929
# Specify multiple allocator targets
30-
ecctl [globalFlags] allocator vacate -t i-05e245252362f7f2d -t i-2362f7f1d252362f7 i-05e245252362f7f1d
31-
ecctl [globalFlags] allocator vacate --target i-05e245252362f7f2d --target i-2362f7f1d252362f7 --kind kibana i-05e245252362f7f1d
30+
ecctl platform allocator vacate -t i-05e245252362f7f2d -t i-2362f7f1d252362f7 i-05e245252362f7f1d
31+
ecctl platform allocator vacate --target i-05e245252362f7f2d --target i-2362f7f1d252362f7 --kind kibana i-05e245252362f7f1d
3232
3333
# Set the allocators to maintenance mode before vacating them
34-
ecctl [globalFlags] allocator vacate --maintenance -t i-05e245252362f7f2d -t i-2362f7f1d252362f7 i-05e245252362f7f1d
34+
ecctl platform allocator vacate --maintenance -t i-05e245252362f7f2d -t i-2362f7f1d252362f7 i-05e245252362f7f1d
3535
3636
# Set the amount of maximum moves to happen at any time
37-
ecctl [globalFlags] allocator vacate --concurrency 10 i-05e245252362f7f1d
37+
ecctl platform allocator vacate --concurrency 10 i-05e245252362f7f1d
3838
3939
# Override the allocator health auto discovery
40-
ecctl [globalFlags] allocator vacate --allocator-down=true i-05e245252362f7f1d
40+
ecctl platform allocator vacate --allocator-down=true i-05e245252362f7f1d
4141
4242
# Override the skip_snapshot setting
43-
ecctl [globalFlags] allocator vacate --skip-snapshot=true i-05e245252362f7f1d -c f521dedb07194c478fbbc6624f3bbf8f
43+
ecctl platform allocator vacate --skip-snapshot=true i-05e245252362f7f1d -r f521dedb07194c478fbbc6624f3bbf8f
4444
4545
# Override the skip_data_migration setting
46-
ecctl [globalFlags] allocator vacate --skip-data-migration=true i-05e245252362f7f1d -c f521dedb07194c478fbbc6624f3bbf8f
46+
ecctl platform allocator vacate --skip-data-migration=true i-05e245252362f7f1d -r f521dedb07194c478fbbc6624f3bbf8f
4747
4848
# Skips tracking the vacate progress which will cause the command to return almost immediately.
4949
# Not recommended since it can lead to failed vacates without the operator knowing about them.
50-
ecctl [globalFlags] allocator vacate --skip-tracking i-05e245252362f7f1d
50+
ecctl platform allocator vacate --skip-tracking i-05e245252362f7f1d
5151
----
5252

5353
[float]
5454
=== Options
5555

5656
----
5757
--allocator-down string Disables the allocator health auto-discovery, setting the allocator-down to either [true|false]
58-
-c, --cluster stringArray Cluster IDs to include in the vacate
5958
--concurrency uint Maximum number of concurrent moves to perform at any time (default 8)
6059
-h, --help help for vacate
6160
-k, --kind string Kind of workload to vacate (elasticsearch|kibana)
6261
-m, --maintenance Whether to set the allocator(s) in maintenance before performing the vacate
6362
--max-poll-retries int Optional maximum plan tracking retries (default 2)
64-
--move-only Keeps the cluster 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)
63+
--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)
6564
--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]
6665
--poll-frequency duration Optional polling frequency to check for plan change updates (default 10s)
67-
--skip-data-migration string Skips the data-migration operation on the specified cluster IDs. ONLY available when the cluster IDs are specified and --move-only is true. [true|false]
68-
--skip-snapshot string Skips the snapshot operation on the specified cluster IDs. ONLY available when the cluster IDs are specified. [true|false]
66+
-r, --resource-id stringArray Resource IDs to include in the vacate
67+
--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]
68+
--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.
7070
-t, --target stringArray Target allocator(s) on which to place the vacated workload
7171
----

0 commit comments

Comments
 (0)