From c5aad9e4886912ec350d78943a4cf730b79a4159 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Mon, 28 Aug 2023 11:08:22 -0400 Subject: [PATCH] Remove legacy label version check, to be added back when version is known Signed-off-by: Tiger Kaovilai --- pkg/discovery/helper.go | 8 -------- pkg/restore/job_action.go | 30 ++---------------------------- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/pkg/discovery/helper.go b/pkg/discovery/helper.go index f52fc7225f..fa84de1f96 100644 --- a/pkg/discovery/helper.go +++ b/pkg/discovery/helper.go @@ -312,11 +312,3 @@ func (h *helper) ServerVersion() *version.Info { defer h.lock.RUnlock() return h.serverVersion } - -func ServerVersion(logger logrus.FieldLogger) (*version.Info, error) { - discoveryHelper, err := NewHelper(&discovery.DiscoveryClient{}, logger) - if err != nil { - return nil, err - } - return discoveryHelper.ServerVersion(), nil -} diff --git a/pkg/restore/job_action.go b/pkg/restore/job_action.go index 66af7a7a80..364ec79ad7 100644 --- a/pkg/restore/job_action.go +++ b/pkg/restore/job_action.go @@ -17,15 +17,12 @@ limitations under the License. package restore import ( - "strconv" - "github.com/pkg/errors" "github.com/sirupsen/logrus" batchv1api "k8s.io/api/batch/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" - "github.com/vmware-tanzu/velero/pkg/discovery" "github.com/vmware-tanzu/velero/pkg/plugin/velero" ) @@ -54,35 +51,12 @@ func (a *JobAction) Execute(input *velero.RestoreItemActionExecuteInput) (*veler return nil, errors.WithStack(err) } - // get kube version - serverVersion, err := discovery.ServerVersion(a.logger) - if err != nil { - return nil, errors.WithStack(err) - } - // if kube version < 1.27, use legacy controller-uid label - majorVersion, err := strconv.Atoi(serverVersion.Major) - if err != nil { - return nil, errors.WithStack(err) - } - minorVersion, err := strconv.Atoi(serverVersion.Minor) - if err != nil { - return nil, errors.WithStack(err) - } - deleteLegacyControllerUIDLabel := false - if majorVersion < 1 || (majorVersion == 1 && minorVersion <= 27) { - deleteLegacyControllerUIDLabel = true - } - if job.Spec.Selector != nil { delete(job.Spec.Selector.MatchLabels, controllerUIDLabel) - if deleteLegacyControllerUIDLabel { - delete(job.Spec.Selector.MatchLabels, legacyControllerUIDLabel) - } + delete(job.Spec.Selector.MatchLabels, legacyControllerUIDLabel) } delete(job.Spec.Template.ObjectMeta.Labels, controllerUIDLabel) - if deleteLegacyControllerUIDLabel { - delete(job.Spec.Template.ObjectMeta.Labels, legacyControllerUIDLabel) - } + delete(job.Spec.Template.ObjectMeta.Labels, legacyControllerUIDLabel) res, err := runtime.DefaultUnstructuredConverter.ToUnstructured(job) if err != nil {