Skip to content

Commit

Permalink
add probe to manifest and remove sleep in code
Browse files Browse the repository at this point in the history
  • Loading branch information
pepoviola committed Nov 29, 2023
1 parent ed6aa60 commit 9e8a0a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
19 changes: 14 additions & 5 deletions javascript/packages/orchestrator/src/providers/k8s/kubeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,13 +553,14 @@ export class KubeClient extends Client {
}
}

// wait until fileserver is ready, fix race condition #700.
const xinfra = process.env.X_INFRA_INSTANCE || "ondemand";
debug("creating fileserver");
await this.createStaticResource("fileserver-pod.yaml", this.namespace, {
xinfra,
});
debug("waiting for pod: fileserver, to be ready");
await this.waitPodReady("fileserver");
sleep(3 * 1000);
debug("pod: fileserver, ready");
let fileServerOk = false;
let attempts = 0;
// try 5 times at most
Expand All @@ -584,7 +585,7 @@ export class KubeClient extends Client {
async checkFileServer(): Promise<boolean> {
const args = ["exec", "Pod/fileserver", "--", "curl", `http://localhost/`];
debug("checking fileserver", args);
const result = await this.runCommand(args);
const result = await this.runCommand(args, { allowFail: true } );
debug("result", result);
return result.stdout.includes("Welcome to nginx");
}
Expand Down Expand Up @@ -765,9 +766,17 @@ export class KubeClient extends Client {
exitCode: result.exitCode,
stdout: result.stdout,
};
} catch (error) {
} catch (error: any) {
debug(error);
throw error;
if (!opts?.allowFail) throw error;

const { exitCode, stdout, message: errorMsg } = error;

return {
exitCode,
stdout,
errorMsg,
};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@
{
"containerPort": 80
}
]
],
"startupProbe": {
"httpGet": {
"path": "/",
"port": 80
},
"initialDelaySeconds": 5,
"periodSeconds": 3,
"failureThreshold": 15
}
}
],
"restartPolicy": "OnFailure",
Expand Down

0 comments on commit 9e8a0a6

Please sign in to comment.