1. Proposed title of this feature request
remove specific labels from machinepools using the rosa cli
2. What is the nature and description of the request?
The customer is unable to remove specific labels from machinepools using the rosa cli, which is hindering their automation of ROSA cluster configurations. They can add labels with the command `rosa edit machinepool <test-pool> -c <my-cluster> --labels k8s.ovn.org/egress-assignable=""` but there is no equivalent command to remove a single label without deleting all labels. This issue impacts their automation process, causing delays in cluster management.
3. Why does the customer need this? (List the business requirements here)
I have run some tests, and it seems that labels cannot be removed using the ROSA CLI. Using the ROSA CLI, you can only add labels, and those labels replace the existing ones. For example, I have this machinePool:
$ ~/Downloads/rosa list machinepool -c 2ddb7bdd-7908-4cfc-9b09-3184d81db329 ID AUTOSCALING REPLICAS INSTANCE TYPE LABELS TAINTS AVAILABILITY ZONES SUBNETS SPOT INSTANCES DISK SIZE SG IDs worker No 2 m5.xlarge us-east-1a No 300 GiB}}
I am going to add a test label:
{{$ ~/Downloads/rosa edit machinepool -c 2ddb7bdd-7908-4cfc-9b09-3184d81db329 worker --labels=testKey=testValue
I: Updated machine pool 'worker' on cluster '2ddb7bdd-7908-4cfc-9b09-3184d81db329'
—
$ ~/Downloads/rosa list machinepool -c 2ddb7bdd-7908-4cfc-9b09-3184d81db329 ID AUTOSCALING REPLICAS INSTANCE TYPE LABELS TAINTS AVAILABILITY ZONES SUBNETS SPOT INSTANCES DISK SIZE SG IDs worker No 2 m5.xlarge testKey=testValue us-east-1a No 300 GiB}}
I cannot remove that label with any command (failed attempt):
{{$ ~/Downloads/rosa edit machinepool c 2ddb7bdd-7908-4cfc-9b09-3184d81db329 worker --labels=testKey=testValue E: Invalid label value 'testValue-': at key: 'testKey': a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')}}
A workaround option could be the following:
- Current Labels: label1=foo, label2=bar, k8s.ovn.org/egress-assignable=""
- Goal: Remove k8s.ovn.org/egress-assignable=""
un this command, omitting the label you want to remove (that is, replacing the list of labels with a new one that only contains those you want to keep):
{{rosa edit machinepool <test-pool> -c <my-cluster> --labels "label1=foo,label2=bar" }}
If k8s.ovn.org/egress-assignable="" were the only label, you would run this to remove it:
rosa edit machinepool <test-pool> -c <my-cluster> --labels ""
Warning: This rosa command only updates the machine pool template. There is a known issue (documented by Red Hat) where this sometimes fails to remove the label from existing nodes that are already running.
If this doesn't work for you, the only option is to delete the labels from the Hybrid Cloud Console.
As the customer needs to automatize his process, the workaround doesn't works in this case. So the CX requires that the oc label command support a "-" for removing existing labels , It makes sense that the ROSA CLI would do the same as works in OCP environments.
4. List any affected packages or components.