Skip to content

Commit 5fd5dd9

Browse files
committed
Do not create the launcher job if the job starts suspended
1 parent c738a83 commit 5fd5dd9

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

pkg/controller/mpi_job_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,9 @@ func (c *MPIJobController) syncHandler(key string) error {
658658
return err
659659
}
660660
}
661-
if launcher == nil {
661+
// If the job is suspended, the list of worker pods will be incorrect. We also do
662+
// not want to start the launcher job if the MPIJob starts suspended.
663+
if launcher == nil && !isMPIJobSuspended(mpiJob) {
662664
if mpiJob.Spec.LauncherCreationPolicy == kubeflow.LauncherCreationPolicyAtStartup || c.countReadyWorkerPods(worker) == len(worker) {
663665
launcher, err = c.kubeClient.BatchV1().Jobs(namespace).Create(context.TODO(), c.newLauncherJob(mpiJob), metav1.CreateOptions{})
664666
if err != nil {

test/integration/mpi_job_controller_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,27 @@ func TestMPIJobSuccess(t *testing.T) {
173173
}
174174

175175
func TestMPIJobWaitWorkers(t *testing.T) {
176+
testcases := []struct {
177+
name string
178+
startSuspended bool
179+
}{
180+
{
181+
name: "don't start suspended",
182+
startSuspended: false,
183+
},
184+
{
185+
name: "start suspended",
186+
startSuspended: true,
187+
},
188+
}
189+
for _, tc := range testcases {
190+
t.Run(tc.name, func(t *testing.T) {
191+
testMpiJobWaitWorkers(t, tc.startSuspended)
192+
})
193+
}
194+
}
195+
196+
func testMpiJobWaitWorkers(t *testing.T, startSuspended bool) {
176197
ctx, cancel := context.WithCancel(context.Background())
177198
t.Cleanup(cancel)
178199
s := newTestSetup(ctx, t)
@@ -187,6 +208,7 @@ func TestMPIJobWaitWorkers(t *testing.T) {
187208
SlotsPerWorker: ptr.To[int32](1),
188209
LauncherCreationPolicy: "WaitForWorkersReady",
189210
RunPolicy: kubeflow.RunPolicy{
211+
Suspend: ptr.To(startSuspended),
190212
CleanPodPolicy: ptr.To(kubeflow.CleanPodPolicyRunning),
191213
},
192214
MPIReplicaSpecs: map[kubeflow.MPIReplicaType]*kubeflow.ReplicaSpec{

0 commit comments

Comments
 (0)