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

Remove unnecessary services for worker #191

Merged
merged 1 commit into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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