Skip to content

Commit

Permalink
Merge pull request #6713 from kaovilai/jobs-label-k8s1.27-velero1.12
Browse files Browse the repository at this point in the history
release-1.12: On restore, delete Kubernetes 1.27 job controller uid label
  • Loading branch information
shubham-pampattiwar authored Sep 29, 2023
2 parents 9d5dd8e + aba64ba commit 554403d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/6713-kaovilai
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Kubernetes 1.27 new job label batch.kubernetes.io/controller-uid are deleted during restore per https://github.com/kubernetes/kubernetes/pull/114930
11 changes: 9 additions & 2 deletions pkg/restore/job_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ import (
"github.com/vmware-tanzu/velero/pkg/plugin/velero"
)

const (
legacyControllerUIDLabel = "controller-uid" // <=1.27 This still exists in 1.27 for backward compatibility, maybe remove in 1.28?
controllerUIDLabel = "batch.kubernetes.io/controller-uid" // >=1.27 https://github.com/kubernetes/kubernetes/pull/114930#issuecomment-1384667494
)

type JobAction struct {
logger logrus.FieldLogger
}
Expand All @@ -47,9 +52,11 @@ func (a *JobAction) Execute(input *velero.RestoreItemActionExecuteInput) (*veler
}

if job.Spec.Selector != nil {
delete(job.Spec.Selector.MatchLabels, "controller-uid")
delete(job.Spec.Selector.MatchLabels, controllerUIDLabel)
delete(job.Spec.Selector.MatchLabels, legacyControllerUIDLabel)
}
delete(job.Spec.Template.ObjectMeta.Labels, "controller-uid")
delete(job.Spec.Template.ObjectMeta.Labels, controllerUIDLabel)
delete(job.Spec.Template.ObjectMeta.Labels, legacyControllerUIDLabel)

res, err := runtime.DefaultUnstructuredConverter.ToUnstructured(job)
if err != nil {
Expand Down

0 comments on commit 554403d

Please sign in to comment.