Skip to content

Commit 7952bd2

Browse files
committed
Resolve
1 parent a7d80a3 commit 7952bd2

File tree

2 files changed

+1
-28
lines changed

2 files changed

+1
-28
lines changed

pkg/webhook/v1beta1/pod/inject_webhook.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ import (
2323

2424
"github.com/spf13/viper"
2525
v1 "k8s.io/api/core/v1"
26-
<<<<<<< HEAD
27-
=======
2826
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2927
"k8s.io/apimachinery/pkg/runtime/schema"
30-
>>>>>>> Refactor get Katib job
3128
apitypes "k8s.io/apimachinery/pkg/types"
3229
"k8s.io/utils/pointer"
3330
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -137,7 +134,7 @@ func (s *sidecarInjector) MutationRequired(pod *v1.Pod, ns string) (bool, error)
137134
if !isMasterRole(pod, jobKind) {
138135
return false, nil
139136
}
140-
137+
}
141138

142139
if trial.Spec.MetricsCollector.Collector.Kind == common.NoneCollector {
143140
return false, nil

pkg/webhook/v1beta1/pod/utils.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,13 @@ import (
2828
crv1 "github.com/google/go-containerregistry/pkg/v1"
2929
"github.com/google/go-containerregistry/pkg/v1/remote"
3030
v1 "k8s.io/api/core/v1"
31-
"k8s.io/apimachinery/pkg/runtime/schema"
3231

3332
common "github.com/kubeflow/katib/pkg/apis/controller/common/v1beta1"
3433
katibmanagerv1beta1 "github.com/kubeflow/katib/pkg/common/v1beta1"
3534
jobv1beta1 "github.com/kubeflow/katib/pkg/job/v1beta1"
3635
mccommon "github.com/kubeflow/katib/pkg/metricscollector/v1beta1/common"
3736
)
3837

39-
func getKatibJob(pod *v1.Pod) (string, string, error) {
40-
for _, gvk := range jobv1beta1.SupportedJobList {
41-
owners := pod.GetOwnerReferences()
42-
for _, owner := range owners {
43-
if isMatchGVK(owner, gvk) {
44-
return owner.Kind, owner.Name, nil
45-
}
46-
}
47-
}
48-
return "", "", errors.New("The Pod doesn't belong to Katib Job")
49-
}
50-
51-
func isMatchGVK(owner metav1.OwnerReference, gvk schema.GroupVersionKind) bool {
52-
if owner.Kind != gvk.Kind {
53-
return false
54-
}
55-
gv := gvk.Group + "/" + gvk.Version
56-
if gv != owner.APIVersion {
57-
return false
58-
}
59-
return true
60-
}
61-
6238
func isPrimaryPod(podLabels, primaryLabels map[string]string) bool {
6339

6440
for primaryKey, primaryValue := range primaryLabels {

0 commit comments

Comments
 (0)