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

fix: update logic to preserve k8s specific labels & annotations #1616

Merged
merged 5 commits into from
Dec 5, 2024

Conversation

svghadi
Copy link
Collaborator

@svghadi svghadi commented Dec 5, 2024

What type of PR is this?

/kind bug

What does this PR do / why we need it:

Operator overwrites k8s added labels or annotations. This sometimes results into unexpected behaviour. Eg. A kubectl rollout restart on deployment adds an annotation "kubectl.kubernetes.io/restartedAt" with timestamp. However operator detects this as a config drift and removes the annotations resulting into k8s terminating the rollout due to change in config. This commit fixes the issue by preserving such annotations & labels added onto live object during comparison.

Special notes to the reviewer:
This is a regression introduced by #1532

Operator overwrites k8s added labels or annotations. This sometimes
results into unexpected behaviour. Eg. A kubectl rollout restart on deployment
adds an annotation "kubectl.kubernetes.io/restartedAt" with timestamp.
However operator detects this as a config drift and removes the annotations
resulting into k8s terminating the rollout due to change in config. This commit
fixes the issue by preserving such annotations & labels added onto live object
during comparison.

Signed-off-by: Siddhesh Ghadi <[email protected]>
Copy link
Collaborator

@anandf anandf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

controllers/argocd/util.go Outdated Show resolved Hide resolved
Signed-off-by: Siddhesh Ghadi <[email protected]>
Signed-off-by: Siddhesh Ghadi <[email protected]>
Signed-off-by: Siddhesh Ghadi <[email protected]>
Copy link
Collaborator

@ishitasequeira ishitasequeira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

@svghadi svghadi merged commit 01c8ec9 into argoproj-labs:master Dec 5, 2024
7 checks passed
@svghadi svghadi deleted the annot-reg branch December 5, 2024 12:21
@svghadi
Copy link
Collaborator Author

svghadi commented Dec 5, 2024

/cherry-pick release-0.13

Copy link

Cherry-pick failed with Merge error 01c8ec9a3ec34998f2812bb6d412cbd44409c95f into temp-cherry-pick-96ce90-release-0.13

svghadi added a commit to svghadi/argocd-operator that referenced this pull request Dec 5, 2024
…proj-labs#1616)

* Fix update logic to preserve k8s specific labels & annotations

Operator overwrites k8s added labels or annotations. This sometimes
results into unexpected behaviour. Eg. A kubectl rollout restart on deployment
adds an annotation "kubectl.kubernetes.io/restartedAt" with timestamp.
However operator detects this as a config drift and removes the annotations
resulting into k8s terminating the rollout due to change in config. This commit
fixes the issue by preserving such annotations & labels added onto live object
during comparison.

Signed-off-by: Siddhesh Ghadi <[email protected]>
svghadi added a commit that referenced this pull request Dec 5, 2024
…notations (#1616) (#1617)

* fix: update logic to preserve k8s specific labels & annotations (#1616)

* Fix update logic to preserve k8s specific labels & annotations

Operator overwrites k8s added labels or annotations. This sometimes
results into unexpected behaviour. Eg. A kubectl rollout restart on deployment
adds an annotation "kubectl.kubernetes.io/restartedAt" with timestamp.
However operator detects this as a config drift and removes the annotations
resulting into k8s terminating the rollout due to change in config. This commit
fixes the issue by preserving such annotations & labels added onto live object
during comparison.

Signed-off-by: Siddhesh Ghadi <[email protected]>

* Fix lint

Signed-off-by: Siddhesh Ghadi <[email protected]>

---------

Signed-off-by: Siddhesh Ghadi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants