Skip to content

Commit

Permalink
[Identity] We had an extra type issue that slipped through our last PR (
Browse files Browse the repository at this point in the history
#18103)

* [Identity] We had an extra type issue that slipped through our last PR

* no more async runCommand, and always logging errors

* Apply suggestions from code review

Co-authored-by: Will Temple <[email protected]>

* feedback from Will

Co-authored-by: Will Temple <[email protected]>
  • Loading branch information
sadasant and witemple-msft authored Oct 11, 2021
1 parent d6c267e commit 0d68696
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.js
*.js.map
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ const argv = yargs
.help()
.alias("help", "h").argv;

async function runCommand(command: string[], exitOnError = true): Promise<unknown> {
function runCommand(command: string[], exitOnError = true): string | null {
console.log("Running command:", command);
try {
if (argv.verbose) {
console.log(command);
Expand All @@ -61,11 +62,12 @@ async function runCommand(command: string[], exitOnError = true): Promise<unknow
}
return child;
} catch (e) {
console.log("Error: " + e);
if (exitOnError) {
console.log("Error: " + e);
process.exit(1);
}
return e;
return null;
}
}

Expand All @@ -85,18 +87,18 @@ async function main(): Promise<void> {
`image.repository=${argv.repository},image.name=${argv["image-name"]},image.tag=${argv["image-tag"]}`
];

await runCommand(helm_install);
runCommand(helm_install);

// get the name of the test pod
let podName = await runCommand([
let podName = runCommand([
"kubectl",
"get",
"pods",
"--selector=job-name=" + JOB_NAME,
"--output=jsonpath='{.items[*].metadata.name}'"
]);
]) as string;

if (typeof podName === "string" && podName[0] == "'") {
if (podName[0] == "'") {
podName = podName.slice(1, -1);
}

Expand All @@ -113,7 +115,11 @@ async function main(): Promise<void> {
for (let x = 0; x < 10; ++x) {
// kubectl will return '' when there are no active pods
let active_pods = runCommand(count_active_pods);
logs = await runCommand(["kubectl", "logs", "-f", podName as string], false);
const result = runCommand(["kubectl", "logs", "-f", podName], false);
if (result === null) {
break;
}
logs = result;
if (!active_pods) break;
await sleep(30);
}
Expand Down

0 comments on commit 0d68696

Please sign in to comment.