diff --git a/pkg/webhook/v1beta1/pod/inject_webhook.go b/pkg/webhook/v1beta1/pod/inject_webhook.go index 5ded72b9738..67b2303b9d2 100644 --- a/pkg/webhook/v1beta1/pod/inject_webhook.go +++ b/pkg/webhook/v1beta1/pod/inject_webhook.go @@ -23,11 +23,8 @@ import ( "github.com/spf13/viper" v1 "k8s.io/api/core/v1" -<<<<<<< HEAD -======= "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" ->>>>>>> Refactor get Katib job apitypes "k8s.io/apimachinery/pkg/types" "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" @@ -137,7 +134,7 @@ func (s *sidecarInjector) MutationRequired(pod *v1.Pod, ns string) (bool, error) if !isMasterRole(pod, jobKind) { return false, nil } - + } if trial.Spec.MetricsCollector.Collector.Kind == common.NoneCollector { return false, nil diff --git a/pkg/webhook/v1beta1/pod/utils.go b/pkg/webhook/v1beta1/pod/utils.go index e6a2028da4b..063eb3fba74 100644 --- a/pkg/webhook/v1beta1/pod/utils.go +++ b/pkg/webhook/v1beta1/pod/utils.go @@ -28,7 +28,6 @@ import ( crv1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/remote" v1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/runtime/schema" common "github.com/kubeflow/katib/pkg/apis/controller/common/v1beta1" katibmanagerv1beta1 "github.com/kubeflow/katib/pkg/common/v1beta1" @@ -36,29 +35,6 @@ import ( mccommon "github.com/kubeflow/katib/pkg/metricscollector/v1beta1/common" ) -func getKatibJob(pod *v1.Pod) (string, string, error) { - for _, gvk := range jobv1beta1.SupportedJobList { - owners := pod.GetOwnerReferences() - for _, owner := range owners { - if isMatchGVK(owner, gvk) { - return owner.Kind, owner.Name, nil - } - } - } - return "", "", errors.New("The Pod doesn't belong to Katib Job") -} - -func isMatchGVK(owner metav1.OwnerReference, gvk schema.GroupVersionKind) bool { - if owner.Kind != gvk.Kind { - return false - } - gv := gvk.Group + "/" + gvk.Version - if gv != owner.APIVersion { - return false - } - return true -} - func isPrimaryPod(podLabels, primaryLabels map[string]string) bool { for primaryKey, primaryValue := range primaryLabels {