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

Commit

Permalink
Remove unnecessary services for worker (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougangliu authored and k8s-ci-robot committed Jul 30, 2019
1 parent 6c75b0c commit 4028276
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 5 additions & 3 deletions pkg/apis/pytorch/v1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ func SetDefaults_PyTorchJob(job *PyTorchJob) {
// Update the key of PyTorchReplicaSpecs to camel case.
setTypeNamesToCamelCase(job)

for _, spec := range job.Spec.PyTorchReplicaSpecs {
for rType, spec := range job.Spec.PyTorchReplicaSpecs {
// Set default replicas to 1.
setDefaultReplicas(spec)
// Set default port to pytorch container.
setDefaultPort(&spec.Template.Spec)
if rType == PyTorchReplicaTypeMaster {
// Set default port to pytorch container of Master.
setDefaultPort(&spec.Template.Spec)
}
}
}
4 changes: 4 additions & 0 deletions pkg/controller.v1/pytorch/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,10 @@ func (pc *PyTorchController) reconcilePyTorchJobs(job *pyv1.PyTorchJob) error {
return err
}

// Service is in need only for Master
if rtype != pyv1.PyTorchReplicaTypeMaster {
continue
}
err = pc.reconcileServices(job, services, rtype, spec)

if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions pkg/controller.v1/pytorch/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestNormalPath(t *testing.T) {
0, 0, 0, 0,
0, 0, 0, 0,
0, 0,
5, 0, 5,
5, 0, 1,
0, 0, 0,
0, 0, 0,
nil, "",
Expand All @@ -139,7 +139,7 @@ func TestNormalPath(t *testing.T) {
nil, true,
4, 0, 0, 0,
1, 0, 0, 0,
4, 1,
0, 1,
0, 0, 0,
0, 0, 0,
0, 0, 0,
Expand All @@ -151,7 +151,7 @@ func TestNormalPath(t *testing.T) {
nil, true,
3, 1, 0, 0,
0, 1, 0, 0,
4, 1,
0, 1,
0, 0, 0,
1, 0, 0,
1, 0, 0,
Expand All @@ -163,7 +163,7 @@ func TestNormalPath(t *testing.T) {
nil, true,
0, 4, 0, 0,
0, 1, 0, 0,
4, 1,
0, 1,
0, 0, 0,
4, 0, 0,
1, 0, 0,
Expand All @@ -175,7 +175,7 @@ func TestNormalPath(t *testing.T) {
nil, true,
0, 0, 4, 0,
0, 0, 1, 0,
4, 1,
0, 1,
0, 0, 0,
0, 4, 0,
0, 1, 0,
Expand Down

0 comments on commit 4028276

Please sign in to comment.