Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not create the launcher job if the job starts suspended #670

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion pkg/controller/mpi_job_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,9 @@ func (c *MPIJobController) syncHandler(key string) error {
return err
}
}
if launcher == nil {
// If the job is suspended, the list of worker pods will be incorrect. We also do
// not want to start the launcher job if the MPIJob starts suspended.
if launcher == nil && !isMPIJobSuspended(mpiJob) {
Comment on lines +661 to +663
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This opens the question on what should be done when unsuspending the launcher job in case kueue has decided to change the NodeSelector? Should we instead recreate the job since NodeSelector is immutable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this question does not have a straigtforward answer, I can see at least two approaches possible:

  1. as in JobSet- update the NodeSelector field in pod template when resuming the Job
  2. Recreate the launcher/worker Jobs , this can be probably achieved easily by deleting the jobs on suspending the MPIJob

I'm ok with any of those that is simpler to implement. Any optinion @tenzen-y ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case I think it is safe to decouple the fixes.

if mpiJob.Spec.LauncherCreationPolicy == kubeflow.LauncherCreationPolicyAtStartup || c.countReadyWorkerPods(worker) == len(worker) {
launcher, err = c.kubeClient.BatchV1().Jobs(namespace).Create(context.TODO(), c.newLauncherJob(mpiJob), metav1.CreateOptions{})
if err != nil {
Expand Down
54 changes: 52 additions & 2 deletions test/integration/mpi_job_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,27 @@ func TestMPIJobSuccess(t *testing.T) {
}

func TestMPIJobWaitWorkers(t *testing.T) {
testcases := []struct {
name string
startSuspended bool
}{
{
name: "don't start suspended",
startSuspended: false,
},
{
name: "start suspended",
startSuspended: true,
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
testMpiJobWaitWorkers(t, tc.startSuspended)
})
}
}

func testMpiJobWaitWorkers(t *testing.T, startSuspended bool) {
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)
s := newTestSetup(ctx, t)
Expand All @@ -187,6 +208,7 @@ func TestMPIJobWaitWorkers(t *testing.T) {
SlotsPerWorker: ptr.To[int32](1),
LauncherCreationPolicy: "WaitForWorkersReady",
RunPolicy: kubeflow.RunPolicy{
Suspend: ptr.To(startSuspended),
CleanPodPolicy: ptr.To(kubeflow.CleanPodPolicyRunning),
},
MPIReplicaSpecs: map[kubeflow.MPIReplicaType]*kubeflow.ReplicaSpec{
Expand Down Expand Up @@ -237,9 +259,37 @@ func TestMPIJobWaitWorkers(t *testing.T) {
}
s.events.verify(t)

workerPods, err := getPodsForJob(ctx, s.kClient, mpiJob)
// The launcher job should not be created until all workers are ready even when we start in suspended mode.
job, err := getLauncherJobForMPIJob(ctx, s.kClient, mpiJob)
if err != nil {
t.Fatalf("Cannot get worker pods from job: %v", err)
t.Fatalf("Cannot get launcher job from job: %v", err)
}
if job != nil {
t.Fatalf("Launcher is created before workers")
}

if startSuspended {
// Resume the MPIJob so that the test can follow the normal path.
mpiJob.Spec.RunPolicy.Suspend = ptr.To(false)
mpiJob, err = s.mpiClient.KubeflowV2beta1().MPIJobs(mpiJob.Namespace).Update(ctx, mpiJob, metav1.UpdateOptions{})
if err != nil {
t.Fatalf("Error Updating MPIJob: %v", err)
}
}

var workerPods []corev1.Pod
if err = wait.PollUntilContextTimeout(ctx, util.WaitInterval, wait.ForeverTestTimeout, false, func(ctx context.Context) (bool, error) {
var err error
workerPods, err = getPodsForJob(ctx, s.kClient, mpiJob)
if err != nil {
return false, err
}
if len(workerPods) != 2 {
return false, nil
}
return true, nil
}); err != nil {
t.Errorf("Failed updating scheduler-plugins PodGroup: %v", err)
}

err = updatePodsToPhase(ctx, s.kClient, workerPods, corev1.PodRunning)
Expand Down
Loading