Skip to content

Commit a775201

Browse files
authored
chore: add try/catch to execPodStep (#9)
* move try catch higher * formatting * earlier linting * screw the linter * try this * empty commit for ci * this should do it? * add bump to package.json
1 parent 338a35b commit a775201

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hooks",
3-
"version": "0.3.10",
3+
"version": "0.3.11",
44
"description": "Three projects are included - k8s: a kubernetes hook implementation that spins up pods dynamically to run a job - docker: A hook implementation of the runner's docker implementation - A hook lib, which contains shared typescript definitions and utilities that the other packages consume",
55
"main": "",
66
"directories": {

packages/k8s/src/k8s/index.ts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -222,30 +222,34 @@ export async function execPodStep(
222222
): Promise<void> {
223223
const exec = new k8s.Exec(kc)
224224
await new Promise(async function (resolve, reject) {
225-
await exec.exec(
226-
namespace(),
227-
podName,
228-
containerName,
229-
command,
230-
process.stdout,
231-
process.stderr,
232-
stdin ?? null,
233-
false /* tty */,
234-
resp => {
235-
// kube.exec returns an error if exit code is not 0, but we can't actually get the exit code
236-
if (resp.status === 'Success') {
237-
resolve(resp.code)
238-
} else {
239-
core.debug(
240-
JSON.stringify({
241-
message: resp?.message,
242-
details: resp?.details
243-
})
244-
)
245-
reject(resp?.message)
225+
try {
226+
await exec.exec(
227+
namespace(),
228+
podName,
229+
containerName,
230+
command,
231+
process.stdout,
232+
process.stderr,
233+
stdin ?? null,
234+
false /* tty */,
235+
resp => {
236+
// kube.exec returns an error if exit code is not 0, but we can't actually get the exit code
237+
if (resp.status === 'Success') {
238+
resolve(resp.code)
239+
} else {
240+
core.debug(
241+
JSON.stringify({
242+
message: resp?.message,
243+
details: resp?.details
244+
})
245+
)
246+
reject(resp?.message)
247+
}
246248
}
247-
}
248-
)
249+
)
250+
} catch (error) {
251+
core.error(`Failed to exec pod step: ${error}`)
252+
}
249253
})
250254
}
251255

0 commit comments

Comments
 (0)