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

Commit 4028276

Browse files
hougangliuk8s-ci-robot
authored andcommitted
Remove unnecessary services for worker (#191)
1 parent 6c75b0c commit 4028276

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

pkg/apis/pytorch/v1/defaults.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@ func SetDefaults_PyTorchJob(job *PyTorchJob) {
9595
// Update the key of PyTorchReplicaSpecs to camel case.
9696
setTypeNamesToCamelCase(job)
9797

98-
for _, spec := range job.Spec.PyTorchReplicaSpecs {
98+
for rType, spec := range job.Spec.PyTorchReplicaSpecs {
9999
// Set default replicas to 1.
100100
setDefaultReplicas(spec)
101-
// Set default port to pytorch container.
102-
setDefaultPort(&spec.Template.Spec)
101+
if rType == PyTorchReplicaTypeMaster {
102+
// Set default port to pytorch container of Master.
103+
setDefaultPort(&spec.Template.Spec)
104+
}
103105
}
104106
}

pkg/controller.v1/pytorch/controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,10 @@ func (pc *PyTorchController) reconcilePyTorchJobs(job *pyv1.PyTorchJob) error {
455455
return err
456456
}
457457

458+
// Service is in need only for Master
459+
if rtype != pyv1.PyTorchReplicaTypeMaster {
460+
continue
461+
}
458462
err = pc.reconcileServices(job, services, rtype, spec)
459463

460464
if err != nil {

pkg/controller.v1/pytorch/controller_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func TestNormalPath(t *testing.T) {
128128
0, 0, 0, 0,
129129
0, 0, 0, 0,
130130
0, 0,
131-
5, 0, 5,
131+
5, 0, 1,
132132
0, 0, 0,
133133
0, 0, 0,
134134
nil, "",
@@ -139,7 +139,7 @@ func TestNormalPath(t *testing.T) {
139139
nil, true,
140140
4, 0, 0, 0,
141141
1, 0, 0, 0,
142-
4, 1,
142+
0, 1,
143143
0, 0, 0,
144144
0, 0, 0,
145145
0, 0, 0,
@@ -151,7 +151,7 @@ func TestNormalPath(t *testing.T) {
151151
nil, true,
152152
3, 1, 0, 0,
153153
0, 1, 0, 0,
154-
4, 1,
154+
0, 1,
155155
0, 0, 0,
156156
1, 0, 0,
157157
1, 0, 0,
@@ -163,7 +163,7 @@ func TestNormalPath(t *testing.T) {
163163
nil, true,
164164
0, 4, 0, 0,
165165
0, 1, 0, 0,
166-
4, 1,
166+
0, 1,
167167
0, 0, 0,
168168
4, 0, 0,
169169
1, 0, 0,
@@ -175,7 +175,7 @@ func TestNormalPath(t *testing.T) {
175175
nil, true,
176176
0, 0, 4, 0,
177177
0, 0, 1, 0,
178-
4, 1,
178+
0, 1,
179179
0, 0, 0,
180180
0, 4, 0,
181181
0, 1, 0,

0 commit comments

Comments
 (0)