Skip to content

Commit

Permalink
Resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyvelich committed Sep 3, 2020
1 parent a7d80a3 commit 7952bd2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
5 changes: 1 addition & 4 deletions pkg/webhook/v1beta1/pod/inject_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
24 changes: 0 additions & 24 deletions pkg/webhook/v1beta1/pod/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,13 @@ 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"
jobv1beta1 "github.com/kubeflow/katib/pkg/job/v1beta1"
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 {
Expand Down

0 comments on commit 7952bd2

Please sign in to comment.