-
Notifications
You must be signed in to change notification settings - Fork 224
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
run worker process in launcher pod #612
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,8 @@ | |
"k8s.io/client-go/util/workqueue" | ||
"k8s.io/klog" | ||
"k8s.io/utils/clock" | ||
"k8s.io/utils/pointer" | ||
Check failure on line 56 in pkg/controller/mpi_job_controller.go
|
||
"k8s.io/utils/ptr" | ||
schedclientset "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned" | ||
volcanoclient "volcano.sh/apis/pkg/client/clientset/versioned" | ||
|
||
|
@@ -656,13 +657,14 @@ | |
return err | ||
} | ||
} | ||
if mpiJob.Spec.MPIImplementation == kubeflow.MPIImplementationIntel || | ||
// If we want to run process in launcher, we should create a service for launcher. | ||
// The Intel and MPICH implementations require workers to communicate with the | ||
// launcher through its hostname. For that, we create a Service which | ||
// has the same name as the launcher's hostname. | ||
kuizhiqing marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if ptr.Deref(mpiJob.Spec.RunLauncherAsWorker, false) || | ||
mpiJob.Spec.MPIImplementation == kubeflow.MPIImplementationIntel || | ||
mpiJob.Spec.MPIImplementation == kubeflow.MPIImplementationMPICH { | ||
// The Intel and MPICH implementations require workers to communicate with the | ||
// launcher through its hostname. For that, we create a Service which | ||
// has the same name as the launcher's hostname. | ||
_, err := c.getOrCreateService(mpiJob, newLauncherService(mpiJob)) | ||
if err != nil { | ||
if _, err = c.getOrCreateService(mpiJob, newLauncherService(mpiJob)); err != nil { | ||
return fmt.Errorf("getting or creating Service to front launcher: %w", err) | ||
} | ||
} | ||
|
@@ -1284,12 +1286,26 @@ | |
if mpiJob.Spec.SlotsPerWorker != nil { | ||
slots = int(*mpiJob.Spec.SlotsPerWorker) | ||
} | ||
// note that pod.spec.dnsConfig also affect the svc resolution | ||
// ref: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/ | ||
// launcher can be reach with hostname or service name | ||
if mpiJob.Spec.RunLauncherAsWorker != nil && *mpiJob.Spec.RunLauncherAsWorker { | ||
kuizhiqing marked this conversation as resolved.
Show resolved
Hide resolved
|
||
launcherService := mpiJob.Name + launcherSuffix | ||
switch mpiJob.Spec.MPIImplementation { | ||
case kubeflow.MPIImplementationOpenMPI: | ||
buffer.WriteString(fmt.Sprintf("%s.%s.svc slots=%d\n", launcherService, mpiJob.Namespace, slots)) | ||
case kubeflow.MPIImplementationIntel, kubeflow.MPIImplementationMPICH: | ||
buffer.WriteString(fmt.Sprintf("%s.%s.svc:%d\n", launcherService, mpiJob.Namespace, slots)) | ||
} | ||
} | ||
|
||
for i := 0; i < int(workerReplicas); i++ { | ||
name := workerName(mpiJob, i) | ||
switch mpiJob.Spec.MPIImplementation { | ||
case kubeflow.MPIImplementationOpenMPI: | ||
buffer.WriteString(fmt.Sprintf("%s%s-%d.%s.%s.svc slots=%d\n", mpiJob.Name, workerSuffix, i, workersService, mpiJob.Namespace, slots)) | ||
buffer.WriteString(fmt.Sprintf("%s.%s.%s.svc slots=%d\n", name, workersService, mpiJob.Namespace, slots)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is nice refactorings :) |
||
case kubeflow.MPIImplementationIntel, kubeflow.MPIImplementationMPICH: | ||
buffer.WriteString(fmt.Sprintf("%s%s-%d.%s.%s.svc:%d\n", mpiJob.Name, workerSuffix, i, workersService, mpiJob.Namespace, slots)) | ||
buffer.WriteString(fmt.Sprintf("%s.%s.%s.svc:%d\n", name, workersService, mpiJob.Namespace, slots)) | ||
} | ||
} | ||
|
||
|
@@ -1319,6 +1335,13 @@ | |
|
||
var buffer bytes.Buffer | ||
buffer.WriteString("#!/bin/sh\n") | ||
|
||
// We don't check if launcher is running here, launcher should always be there or the job failed | ||
if ptr.Deref(mpiJob.Spec.RunLauncherAsWorker, false) { | ||
launcherService := mpiJob.Name + launcherSuffix | ||
buffer.WriteString(fmt.Sprintf("echo %s.%s.svc\n", launcherService, mpiJob.Namespace)) | ||
} | ||
|
||
workersService := mpiJob.Name + workerSuffix | ||
for _, p := range runningPods { | ||
buffer.WriteString(fmt.Sprintf("echo %s.%s.%s.svc\n", p.Name, workersService, p.Namespace)) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't create an additional service in the case of OpenMPI. Just allowing the existing Service to match the launcher pod should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing Service created with selector
training.kubeflow.org/job-role: worker
which can't be used directly. Without creating Service for launcher, we should change the service for worker and remove the selector.Create a service is more preferable for me. WDYT @tenzen-y @alculquicondor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more efficient to just change the selector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alculquicondor Do you mean change the selector in the case of OpenMPI or in all the case ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just change it for all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Although I'm not sure if IntelMPI would work with just one Service, as it's very picky about the hostname. Worth trying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,I will try it. While we just make the service refactor in this PR or with another one, since it's already a way to run with respect to the original service design?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here should be fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alculquicondor @tenzen-y I've add a service for both launcher and workers, for IntelMPI which need to access launcher with hostname, I modify the searches part in DNSConfig.