Skip to content

Commit

Permalink
fix(run): interactive run module/service commands not working
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald authored and thsig committed Aug 5, 2019
1 parent c0a6673 commit 8ccc06d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions garden-service/src/commands/run/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export class RunModuleCommand extends Command<Args, Opts> {
args: args.arguments || [],
runtimeContext,
interactive: opts.interactive,
timeout: opts.interactive ? 999999 : undefined,
})

return { result }
Expand Down
1 change: 1 addition & 0 deletions garden-service/src/commands/run/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class RunServiceCommand extends Command<Args, Opts> {
service,
runtimeContext,
interactive: true,
timeout: 999999,
})

return { result }
Expand Down
15 changes: 12 additions & 3 deletions garden-service/src/plugins/kubernetes/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,19 @@ export async function runPod(
})
}

if (interactive) {
spec.containers[0].stdin = true
spec.containers[0].stdinOnce = true
spec.containers[0].tty = true
}

const runPodName = podName || `run-${module.name}-${Math.round(new Date().getTime())}`

const kubecmd = [
"run",
podName || `run-${module.name}-${Math.round(new Date().getTime())}`,
runPodName,
`--image=${image}`,
"--restart=Never",
"--quiet",
"--rm",
// Need to attach to get the log output and exit code.
"-i",
Expand All @@ -75,10 +82,12 @@ export async function runPod(

if (interactive) {
kubecmd.push("--tty")
} else {
kubecmd.push("--quiet")
}

const command = [...spec.containers[0].command || [], ...spec.containers[0].args || []]
log.verbose(`Running '${command.join(" ")}'`)
log.verbose(`Running '${command.join(" ")}' in Pod ${runPodName}`)

const startedAt = new Date()

Expand Down

0 comments on commit 8ccc06d

Please sign in to comment.