Skip to content

Set kubectl.kubernetes.io/restartedAt annotation on workload redeploy - #18496

Merged
marcelofukumoto merged 1 commit into
rancher:masterfrom
marcelofukumoto:issue-16445
Jul 29, 2026
Merged

Set kubectl.kubernetes.io/restartedAt annotation on workload redeploy#18496
marcelofukumoto merged 1 commit into
rancher:masterfrom
marcelofukumoto:issue-16445

Conversation

@marcelofukumoto

@marcelofukumoto marcelofukumoto commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #16445

Occurred changes and/or fixed issues

When redeploying a Prometheus-managed StatefulSet, only some pods were restarted.
The dashboard set only the cattle.io/timestamp annotation to trigger a rolling
update, but the Prometheus operator does not recognize this annotation and reverts
it before the rollout completes.

This PR additionally sets the standard kubectl.kubernetes.io/restartedAt annotation
on the pod template during redeploy. The Prometheus operator recognizes and preserves
this annotation, so the rolling update completes successfully for all pods.

Technical notes summary

  • Added KUBECTL_RESTARTED_AT constant (kubectl.kubernetes.io/restartedAt) to
    shell/config/labels-annotations.js.
  • Updated RedeployWorkloadDialog.vue to set both cattle.io/timestamp and
    kubectl.kubernetes.io/restartedAt in the pod template annotations when
    redeploying. See
    shell/dialog/RedeployWorkloadDialog.vue.
  • Added unit tests covering the dual-annotation behavior, timestamp format, missing
    metadata initialization, multi-workload redeploy, and error handling.

Areas or cases that should be tested

  • Redeploy a Prometheus-managed StatefulSet and verify all pods restart.
  • Redeploy a standard Deployment and verify it still works as before.
  • Redeploy multiple workloads at once from the list view.

Areas which could experience regressions

  • Workload redeploy for any resource type (Deployment, DaemonSet, StatefulSet).
  • Controllers or operators that watch pod template annotations for changes.

Screenshot/Video

Before (Ready 1/2, only one pod restarted):

before

After (Ready 2/2, both pods restarted successfully):

after

Checklist

  • The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • The PR has a Milestone
  • The PR template has been filled out
  • The PR has been self reviewed
  • The PR has a reviewer assigned
  • The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
  • The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes
  • The PR has been reviewed in terms of Accessibility
  • The PR has considered, and if applicable tested with, the three Global Roles Admin, Standard User and User Base

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Auto-Retry Failed Run

The Tests workflow run 30123230857 failed and has been automatically retried.

Follow up on the retried run here if needed: https://github.com/rancher/dashboard/actions/runs/30123230857

@marcelofukumoto
marcelofukumoto marked this pull request as ready for review July 28, 2026 21:46

@codyrancher codyrancher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified that this change adds the appropriate annotation
This applies for all resources, not just prometheus which I think it fine since it's a well known annotation. https://kubernetes.io/docs/reference/labels-annotations-taints/#kubectl-k8s-io-restart-at

@marcelofukumoto
marcelofukumoto merged commit a011c5e into rancher:master Jul 29, 2026
133 of 138 checks passed
mantis-toboggan-md pushed a commit that referenced this pull request Jul 30, 2026
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.

Change how we trigger workload re-deployments to be compatible with prometheus

2 participants