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

Update single Cluster label via API #18098

Open
agrrh opened this issue May 7, 2024 · 0 comments
Open

Update single Cluster label via API #18098

agrrh opened this issue May 7, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@agrrh
Copy link

agrrh commented May 7, 2024

Summary

It would be great to make it possible to add, set or remove cluster labels with an atomic API request.

Motivation

I operate number of cluster with personal operator, which calls ArgoCD API.

It sometimes need to add and remove cluster labels (changing where to roll or wipe ApplicationSet out).

There's PATCH method for Apps, but for Clusters, there's only PUT.

So, now my only way is to:

  1. GET cluster, extract {labels}
  2. Modify labels
  3. PUT it back, sending modified {labels} dict using ?updatedFields=labels

Why it's not great:

It overwrites whole labels dict.
There's small but still a real chance that someone would edit labels between steps 1 and 3.
Thus, I would overwrite someone's data.

Proposal

I can think of three approaches here.

  1. Add separate endpoints:
PUT    /api/v1/clusters/{id.value}/labels

[
  {"key": "example.org/foo", "value": "42"},
  {"key": "example.org/bar", "value": "baz"}
]
DELETE /api/v1/clusters/{id.value}/labels
  1. Allow to run PATCH as in Application's PATCH, with JSON or merge patches, e.g.:
PATCH /api/v1/clusters/{id.value}

{"metadata": { "labels": { "example.org/foo": "42" } }}
  1. Make it possible to run PUT on /clusters in more precise way, e.g.:
PUT /api/v1/clusters/{id.value}?updatedFields=labels%5B%22example.org%2Ffoo%22%5D%2Clabels%5B%22example.org%2Fbar%22%5D

# This ugly value means:
#   labels["example.org/foo"],labels["example.org/bar"]
@agrrh agrrh added the enhancement New feature or request label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant