Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label tasks and clusters #3934

Merged
merged 10 commits into from
Jul 23, 2024
11 changes: 10 additions & 1 deletion docs/source/sctool/partials/sctool_backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ options:
Patterns are evaluated from left to right.
If a pattern starts with '!' it unselects items that were selected by previous patterns i.e. 'a?,!aa' selects *ab* but not *aa*.

- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
- name: location
shorthand: L
default_value: '[]'
Expand All @@ -80,7 +89,7 @@ options:
The 'bucket' parameter is a bucket name, it must be an alphanumeric string and **may contain a dash and or a dot, but other characters are forbidden**.
- name: name
usage: |
Task name that can be used insead of ID.
Task name that can be used instead of ID.
- name: num-retries
shorthand: r
default_value: "3"
Expand Down
11 changes: 10 additions & 1 deletion docs/source/sctool/partials/sctool_backup_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ options:
Patterns are evaluated from left to right.
If a pattern starts with '!' it unselects items that were selected by previous patterns i.e. 'a?,!aa' selects *ab* but not *aa*.

- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
- name: location
shorthand: L
default_value: '[]'
Expand All @@ -81,7 +90,7 @@ options:
The 'bucket' parameter is a bucket name, it must be an alphanumeric string and **may contain a dash and or a dot, but other characters are forbidden**.
- name: name
usage: |
Task name that can be used insead of ID.
Task name that can be used instead of ID.
- name: num-retries
shorthand: r
default_value: "3"
Expand Down
11 changes: 10 additions & 1 deletion docs/source/sctool/partials/sctool_backup_validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ options:

The task run date is aligned with '--start date' value.
For example, if you select '--interval 7d' task would run weekly at the '--start-date' time.
- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
- name: location
shorthand: L
default_value: '[]'
Expand All @@ -54,7 +63,7 @@ options:
The 'bucket' parameter is a bucket name, it must be an alphanumeric string and **may contain a dash and or a dot, but other characters are forbidden**.
- name: name
usage: |
Task name that can be used insead of ID.
Task name that can be used instead of ID.
- name: num-retries
shorthand: r
default_value: "3"
Expand Down
11 changes: 10 additions & 1 deletion docs/source/sctool/partials/sctool_backup_validate_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ options:

The task run date is aligned with '--start date' value.
For example, if you select '--interval 7d' task would run weekly at the '--start-date' time.
- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
- name: location
shorthand: L
default_value: '[]'
Expand All @@ -51,7 +60,7 @@ options:
The 'bucket' parameter is a bucket name, it must be an alphanumeric string and **may contain a dash and or a dot, but other characters are forbidden**.
- name: name
usage: |
Task name that can be used insead of ID.
Task name that can be used instead of ID.
- name: num-retries
shorthand: r
default_value: "3"
Expand Down
9 changes: 9 additions & 0 deletions docs/source/sctool/partials/sctool_cluster_add.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ options:
shorthand: i
usage: |
Explicitly specify cluster ID, when not provided random `UUID` will be generated.
- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
- name: name
shorthand: "n"
usage: |
Expand Down
9 changes: 9 additions & 0 deletions docs/source/sctool/partials/sctool_cluster_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ options:
Hostname or `IP` of the node that will be used to discover other nodes belonging to the cluster.
Note that this will be persisted and used every time Scylla Manager starts.
You can use either an IPv4 or IPv6 address.
- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
- name: name
shorthand: "n"
usage: |
Expand Down
11 changes: 10 additions & 1 deletion docs/source/sctool/partials/sctool_repair.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,18 @@ options:
Patterns are evaluated from left to right.
If a pattern starts with '!' it unselects items that were selected by previous patterns i.e. 'a?,!aa' selects *ab* but not *aa*.

- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
- name: name
usage: |
Task name that can be used insead of ID.
Task name that can be used instead of ID.
- name: num-retries
shorthand: r
default_value: "3"
Expand Down
11 changes: 10 additions & 1 deletion docs/source/sctool/partials/sctool_repair_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,18 @@ options:
Patterns are evaluated from left to right.
If a pattern starts with '!' it unselects items that were selected by previous patterns i.e. 'a?,!aa' selects *ab* but not *aa*.

- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
- name: name
usage: |
Task name that can be used insead of ID.
Task name that can be used instead of ID.
- name: num-retries
shorthand: r
default_value: "3"
Expand Down
11 changes: 10 additions & 1 deletion docs/source/sctool/partials/sctool_restore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ options:
Patterns are evaluated from left to right.
If a pattern starts with '!' it unselects items that were selected by previous patterns i.e. 'a?,!aa' selects *ab* but not *aa*.

- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
- name: location
shorthand: L
default_value: '[]'
Expand All @@ -81,7 +90,7 @@ options:
The `<bucket>` parameter is a bucket name, it must be an alphanumeric string and **may contain a dash and or a dot, but other characters are forbidden**.
- name: name
usage: |
Task name that can be used insead of ID.
Task name that can be used instead of ID.
- name: num-retries
shorthand: r
default_value: "3"
Expand Down
11 changes: 10 additions & 1 deletion docs/source/sctool/partials/sctool_restore_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ options:
Patterns are evaluated from left to right.
If a pattern starts with '!' it unselects items that were selected by previous patterns i.e. 'a?,!aa' selects *ab* but not *aa*.

- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
- name: location
shorthand: L
default_value: '[]'
Expand All @@ -79,7 +88,7 @@ options:
The `<bucket>` parameter is a bucket name, it must be an alphanumeric string and **may contain a dash and or a dot, but other characters are forbidden**.
- name: name
usage: |
Task name that can be used insead of ID.
Task name that can be used instead of ID.
- name: num-retries
shorthand: r
default_value: "3"
Expand Down
11 changes: 10 additions & 1 deletion docs/source/sctool/partials/sctool_suspend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,18 @@ options:

The task run date is aligned with '--start date' value.
For example, if you select '--interval 7d' task would run weekly at the '--start-date' time.
- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
karol-kokoszka marked this conversation as resolved.
Show resolved Hide resolved
- name: name
usage: |
Task name that can be used insead of ID.
Task name that can be used instead of ID.
- name: num-retries
shorthand: r
default_value: "3"
Expand Down
11 changes: 10 additions & 1 deletion docs/source/sctool/partials/sctool_suspend_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,18 @@ options:

The task run date is aligned with '--start date' value.
For example, if you select '--interval 7d' task would run weekly at the '--start-date' time.
- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
karol-kokoszka marked this conversation as resolved.
Show resolved Hide resolved
- name: name
usage: |
Task name that can be used insead of ID.
Task name that can be used instead of ID.
- name: num-retries
shorthand: r
default_value: "3"
Expand Down
3 changes: 3 additions & 0 deletions pkg/command/cluster/clusteradd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type command struct {

id string
name string
label flag.Label
host string
port int64
authToken string
Expand Down Expand Up @@ -57,6 +58,7 @@ func (cmd *command) init() {
w := cmd.Flags()
w.StringVarP(&cmd.id, "id", "i", "", "")
w.StringVarP(&cmd.name, "name", "n", "", "")
w.Var(&cmd.label, "label", "")
w.StringVar(&cmd.host, "host", "", "")
w.Int64Var(&cmd.port, "port", 10001, "")
w.StringVar(&cmd.authToken, "auth-token", "", "")
Expand Down Expand Up @@ -85,6 +87,7 @@ func (cmd *command) run() error {
c := &managerclient.Cluster{
ID: cmd.id,
Name: cmd.name,
Labels: cmd.label.NewLabels(),
Host: cmd.host,
AuthToken: cmd.authToken,
Username: cmd.username,
Expand Down
18 changes: 17 additions & 1 deletion pkg/command/cluster/clusteradd/cmd_integration_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"bytes"
"context"
"fmt"
"maps"
"os/exec"
"strings"
"testing"
Expand Down Expand Up @@ -65,6 +66,18 @@ func TestSctoolClusterAddIntegrationAPITest(t *testing.T) {
Port: 0,
},
},
{
name: "create cluster with label",
args: []string{"cluster", "add", "--auth-token", authToken, "--host", clusterIntroHost,
"--label", "k1=v1,with space=with-dash_underscore666",
},
expectedCluster: &models.Cluster{
Labels: map[string]string{
"k1": "v1",
"with space": "with-dash_underscore666",
},
},
},
} {
t.Run(tc.name, func(t *testing.T) {
// given
Expand All @@ -86,7 +99,7 @@ func TestSctoolClusterAddIntegrationAPITest(t *testing.T) {
clusterID := strings.Split(string(output), "\n")[0]

defer func() {
if err != client.DeleteCluster(context.Background(), clusterID) {
if err := client.DeleteCluster(context.Background(), clusterID); err != nil {
t.Logf("Failed to delete cluster, err = {%v}", err)
}
}()
Expand All @@ -111,6 +124,9 @@ func TestSctoolClusterAddIntegrationAPITest(t *testing.T) {
if c.Port != tc.expectedCluster.Port {
t.Fatalf("Port mismatch {%v} != {%v}, output={%v}", c.Port, tc.expectedCluster.Port, string(output))
}
if !maps.Equal(c.Labels, tc.expectedCluster.Labels) {
t.Fatalf("Labels mismatch {%v} != {%v}", c.Labels, tc.expectedCluster.Labels)
}
})
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/command/cluster/clusteradd/res.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ name: |
Use this parameter to identify the cluster by an alias name which is more meaningful.
This `alias` name can be used with all commands that accept --cluster parameter.

label: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, ``--label k1=v1,k2-`` will set the label 'k1' to 'v1' and will also remove label 'k2'.

host: |
Hostname or `IP` of the node that will be used to discover other nodes belonging to the cluster.
Note that this will be persisted and used every time Scylla Manager starts.
Expand Down
Loading
Loading