Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
fix replica-type upper case issue
Browse files Browse the repository at this point in the history
  • Loading branch information
zw0610 committed Nov 16, 2021
1 parent 9b16029 commit 257a2c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions pkg/controller.v1/common/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions pkg/reconciler.v1/common/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand All @@ -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) {
Expand Down

0 comments on commit 257a2c8

Please sign in to comment.