Skip to content

Commit

Permalink
fix: remove unneccessary ns validation
Browse files Browse the repository at this point in the history
  • Loading branch information
zhixian82 authored and zhouyan committed Dec 21, 2022
1 parent db72ce1 commit 9812d30
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 48 deletions.
3 changes: 0 additions & 3 deletions manifests/v1beta1/components/webhook/webhooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ webhooks:
name: katib-controller
namespace: kubeflow
path: /mutate-pod
namespaceSelector:
matchLabels:
katib.kubeflow.org/metrics-collector-injection: enabled
rules:
- apiGroups:
- ""
Expand Down
3 changes: 0 additions & 3 deletions operators/katib-controller/src/webhooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ webhooks:
name: katib-controller
namespace: kubeflow
path: /mutate-pod
namespaceSelector:
matchLabels:
katib.kubeflow.org/metrics-collector-injection: enabled
rules:
- apiGroups:
- ""
Expand Down
22 changes: 0 additions & 22 deletions pkg/webhook/v1beta1/common/const.go

This file was deleted.

20 changes: 0 additions & 20 deletions pkg/webhook/v1beta1/experiment/validation_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
suggestionsv1beta1 "github.com/kubeflow/katib/pkg/apis/controller/suggestions/v1beta1"
"github.com/kubeflow/katib/pkg/controller.v1beta1/experiment/manifest"
"github.com/kubeflow/katib/pkg/controller.v1beta1/util"
"github.com/kubeflow/katib/pkg/webhook/v1beta1/common"
"github.com/kubeflow/katib/pkg/webhook/v1beta1/experiment/validator"
)

Expand Down Expand Up @@ -79,25 +78,6 @@ func (v *ExperimentValidator) Handle(ctx context.Context, req admission.Request)
}
}

// After metrics collector sidecar injection in Job level done, delete validation for namespace labels
ns := &v1.Namespace{}
if err := v.client.Get(context.TODO(), types.NamespacedName{Name: req.AdmissionRequest.Namespace}, ns); err != nil {
return admission.Errored(http.StatusInternalServerError, err)
}
validNS := true
if ns.Labels == nil {
validNS = false
} else {
if v, ok := ns.Labels[common.KatibMetricsCollectorInjection]; !ok || v != common.KatibMetricsCollectorInjectionEnabled {
validNS = false
}
}
if !validNS {
err = fmt.Errorf("Cannot create the Experiment %q in namespace %q: the namespace lacks label \"%s: %s\"",
inst.Name, req.AdmissionRequest.Namespace, common.KatibMetricsCollectorInjection, common.KatibMetricsCollectorInjectionEnabled)
return admission.Errored(http.StatusBadRequest, err)
}

err = v.ValidateExperiment(inst, oldInst)
if err != nil {
return admission.Errored(http.StatusBadRequest, err)
Expand Down

0 comments on commit 9812d30

Please # to comment.