diff --git a/pkg/controller.v1/common/service.go b/pkg/controller.v1/common/service.go index 97d62e5a..04b51f65 100644 --- a/pkg/controller.v1/common/service.go +++ b/pkg/controller.v1/common/service.go @@ -16,6 +16,7 @@ package common import ( "fmt" "strconv" + "strings" apiv1 "github.com/kubeflow/common/pkg/apis/common/v1" "github.com/kubeflow/common/pkg/controller.v1/control" @@ -212,9 +213,10 @@ func (jc *JobController) CreateNewService(job metav1.Object, rtype string, return err } + rt := strings.ToLower(rtype) // Append ReplicaTypeLabelDeprecated and ReplicaIndexLabelDeprecated labels. labels := jc.GenLabels(job.GetName()) - utillabels.SetReplicaType(labels, rtype) + utillabels.SetReplicaType(labels, rt) utillabels.SetReplicaIndexStr(labels, index) ports, err := jc.GetPortsFromJob(spec) @@ -236,13 +238,13 @@ func (jc *JobController) CreateNewService(job metav1.Object, rtype string, service.Spec.Ports = append(service.Spec.Ports, svcPort) } - service.Name = GenGeneralName(job.GetName(), rtype, index) + service.Name = GenGeneralName(job.GetName(), rt, index) service.Labels = labels // Create OwnerReference. controllerRef := jc.GenOwnerReference(job) // Creation is expected when there is no error returned - expectationServicesKey := expectation.GenExpectationServicesKey(jobKey, rtype) + expectationServicesKey := expectation.GenExpectationServicesKey(jobKey, rt) jc.Expectations.RaiseExpectations(expectationServicesKey, 1, 0) err = jc.ServiceControl.CreateServicesWithControllerRef(job.GetNamespace(), service, job.(runtime.Object), controllerRef) diff --git a/pkg/reconciler.v1/common/service.go b/pkg/reconciler.v1/common/service.go index 7e71d37d..5bd3799d 100644 --- a/pkg/reconciler.v1/common/service.go +++ b/pkg/reconciler.v1/common/service.go @@ -17,6 +17,7 @@ package common import ( "context" "strconv" + "strings" commonv1 "github.com/kubeflow/common/pkg/apis/common/v1" "github.com/kubeflow/common/pkg/core" @@ -155,9 +156,10 @@ func (r *KubeflowServiceReconciler) ReconcileServices( func (r *KubeflowServiceReconciler) CreateNewService(job client.Object, rtype string, spec *commonv1.ReplicaSpec, index string) error { + rt := strings.ToLower(rtype) // Append ReplicaTypeLabel and ReplicaIndexLabel labels. labels := r.GenLabels(job.GetName()) - labels[commonv1.ReplicaTypeLabel] = rtype + labels[commonv1.ReplicaTypeLabel] = rt labels[commonv1.ReplicaIndexLabel] = index ports, err := r.GetPortsFromJob(spec) @@ -179,7 +181,7 @@ func (r *KubeflowServiceReconciler) CreateNewService(job client.Object, rtype st service.Spec.Ports = append(service.Spec.Ports, svcPort) } - service.Name = core.GenGeneralName(job.GetName(), rtype, index) + service.Name = core.GenGeneralName(job.GetName(), rt, index) service.Namespace = job.GetNamespace() service.Labels = labels // Create OwnerReference. @@ -188,7 +190,7 @@ func (r *KubeflowServiceReconciler) CreateNewService(job client.Object, rtype st return err } - r.DecorateService(rtype, service, job) + r.DecorateService(rt, service, job) err = r.Create(context.Background(), service) if err != nil && errors.IsTimeout(err) {