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

Use bash to run dm commands #111

Merged
merged 1 commit into from
May 31, 2023
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
2 changes: 1 addition & 1 deletion controllers/datamovement_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (r *DataMovementReconciler) Reconcile(ctx context.Context, req ctrl.Request
log.Info("MPI Hostfile preview", "first line", peekMpiHostfile(mpiHostfile))
}

cmd := exec.CommandContext(ctxCancel, cmdArgs[0], cmdArgs[1:]...)
cmd := exec.CommandContext(ctxCancel, "/bin/bash", "-c", strings.Join(cmdArgs, " "))
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, how are arguments combined via strings.Join here? Space-separated I would guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, spaces

Copy link
Contributor

Choose a reason for hiding this comment

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

The result of strings.Join() then needs to be sandwiched between single or double quotes; maybe single quotes so people can't dip into environment variables.


// Record the start of the data movement operation
now := metav1.NowMicro()
Expand Down
10 changes: 6 additions & 4 deletions controllers/datamovement_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ var _ = Describe("Data Movement Test", func() {
const testLabelKey = "dm-test"
var testLabel string

cmdBashPrefix := "/bin/bash -c "

createFakeProgressScript := func() string {
f, err := os.CreateTemp(tmpDir, "fakeProgressOutput-*.sh")
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -228,7 +230,7 @@ var _ = Describe("Data Movement Test", func() {

Context("when the dm configmap has specified an overrideCmd", func() {
BeforeEach(func() {
dmCfgProfile.Command = "/bin/ls -l"
dmCfgProfile.Command = "ls -l"
})
It("should use that command instead of the default mpirun", func() {
Eventually(func(g Gomega) string {
Expand All @@ -238,13 +240,13 @@ var _ = Describe("Data Movement Test", func() {
cmd = dm.Status.CommandStatus.Command
}
return cmd
}).Should(Equal(dmCfgProfile.Command))
}).Should(Equal(cmdBashPrefix + dmCfgProfile.Command))
})
})

Context("when the dm configmap does not have $HOSTFILE in the command", func() {
BeforeEach(func() {
dmCfgProfile.Command = "/bin/ls -l"
dmCfgProfile.Command = "ls -l"
})
It("should use that command instead of the default mpirun", func() {
Eventually(func(g Gomega) string {
Expand All @@ -254,7 +256,7 @@ var _ = Describe("Data Movement Test", func() {
cmd = dm.Status.CommandStatus.Command
}
return cmd
}).Should(Equal(dmCfgProfile.Command))
}).Should(Equal(cmdBashPrefix + dmCfgProfile.Command))
})
})

Expand Down