diff --git a/javascript/packages/orchestrator/src/providers/k8s/kubeClient.ts b/javascript/packages/orchestrator/src/providers/k8s/kubeClient.ts index dc840b9f1..e36f81017 100644 --- a/javascript/packages/orchestrator/src/providers/k8s/kubeClient.ts +++ b/javascript/packages/orchestrator/src/providers/k8s/kubeClient.ts @@ -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 @@ -584,7 +585,7 @@ export class KubeClient extends Client { async checkFileServer(): Promise { 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"); } @@ -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, + }; } } diff --git a/javascript/packages/orchestrator/static-configs/fileserver-pod.yaml b/javascript/packages/orchestrator/static-configs/fileserver-pod.yaml index b90695c6f..6ace4165a 100644 --- a/javascript/packages/orchestrator/static-configs/fileserver-pod.yaml +++ b/javascript/packages/orchestrator/static-configs/fileserver-pod.yaml @@ -19,7 +19,16 @@ { "containerPort": 80 } - ] + ], + "startupProbe": { + "httpGet": { + "path": "/", + "port": 80 + }, + "initialDelaySeconds": 5, + "periodSeconds": 3, + "failureThreshold": 15 + } } ], "restartPolicy": "OnFailure",