rancher / fleet

Deploy workloads from Git to large fleets of Kubernetes clusters
https://fleet.rancher.io/
Apache License 2.0
1.51k stars 226 forks source link

Alignment of the sync behaviour of labels and annotations #1584

Open drasang opened 1 year ago

drasang commented 1 year ago

Is there an existing issue for this?

Current Behavior

Currently it seems that only labels from the v3/clusters are synced to the corresponding fleet.cattle.io.clusters object. Changes to the annotations are not synced.

This also causes changes to annotations via editing the cluster resource in the Rancher UI under /dashboard/c/local/fleet/fleet.cattle.io.cluster to only be reflected in v3/cluster.

Since this behaviour differs from the known behaviour of the labels, this leads to mistakes like those seen in Issue #1516. Contrary to the assumption and changes made in the UI, no annotation has been configured on the fleet cluster object that could be referred to in the template.

Expected Behavior

As with labels, the user-defined annotations are synchronised from the v3/clusters object to the corresponding Fleet object.

Steps To Reproduce

Environment

* Architecture: amd64
* Fleet Version: 0.6.0
* Rancher Version: 2.7.4
* Management Cluster: 
  * Provider: EKS
  * Version: 1.24
* Downstream Cluster: 
  * Provider: EKS (Imported)
  * Kubernetes Version: 1.23/1.24

Logs

No response

Anything else?

Workaround: The cluster resource can be edited via "Edit Yaml". In this case, the PUT request is only sent to v1/fleet.cattle.io.clusters/fleet-default/clusterid and this time also contains the labels and annotations.

weyfonk commented 1 week ago

Problem

Updating annotations on a cluster through the Rancher UI would not be reflected in the corresponding Fleet cluster resource, although propagation of updates did work for labels.

Solution

Added annotations to fields taken into account when creating a Fleet cluster object.

Testing

See repro steps above

Engineering Testing

Manual Testing

Tested reproduction steps before and after the change, noticing that in the latter case.

Automated Testing

Added unit tests to Rancher covering cluster creation (which seems to be also run upon updating a cluster in the UI) and validating actual vs expected labels and annotations.

QA Testing Considerations

Verify that update and deletion of labels through the UI works as expected, propagating changes to the corresponding Fleet cluster resource.

Regressions Considerations

N/A

sbulage commented 3 days ago

QA Observations

I have created a video which covers the detailed steps which I performed. In order to check the label/annotations on propagation from Fleet cluster to Management cluster.

Also tried the API way and similar behavior observed

Videos

Video showing detailed steps https://github.com/user-attachments/assets/770f0149-2a9a-4de8-98c4-33502f631112
weyfonk commented 19 hours ago

Apologies. I'd merged a fix into rancher/rancher's main, ie targetting Rancher v2.10.0 instead of v2.9.3 which was the original target milestone for this issue. Please validate this against v2.10.0.

This issue and the PR linked there target Rancher v2.9.3.