Skip to content

Commit

Permalink
waiting ready condition (#1899)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepoviola authored Oct 7, 2024
1 parent af1eedc commit 4ecabc4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions javascript/packages/orchestrator/src/providers/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export abstract class Client {
keystore?: string,
chainSpecId?: string,
dbSnapshot?: string, //delay?: DelayNetworkSettings,
longRunning?: boolean,
): Promise<void>;
abstract copyFileFromPod(
identifier: string,
Expand Down
13 changes: 11 additions & 2 deletions javascript/packages/orchestrator/src/providers/k8s/kubeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export class KubeClient extends Client {
keystore?: string,
chainSpecId?: string,
dbSnapshot?: string,
longRunning?: boolean,
): Promise<void> {
const name = podDef.metadata.name;
writeLocalJsonFile(this.tmpDir, `${name}.json`, podDef);
Expand Down Expand Up @@ -230,6 +231,9 @@ export class KubeClient extends Client {
await this.putLocalMagicFile(name);
await this.waitPodReady(name);

if (longRunning)
await this.runCommand(["wait", "--for=condition=Ready", `Pod/${name}`]);

logTable = new CreateLogTable({
colWidths: [20, 100],
});
Expand Down Expand Up @@ -566,13 +570,18 @@ export class KubeClient extends Client {
});
debug("waiting for pod: fileserver, to be ready");
await this.waitPodReady("fileserver");
await this.runCommand(["wait", "--for=condition=Ready", "Pod/fileserver"]);
debug("pod: fileserver, ready");
let fileServerOk = false;
let attempts = 0;
// try 5 times at most
for (attempts; attempts < 5; attempts++) {
if (await this.checkFileServer()) fileServerOk = true;
else sleep(1 * 1000);
if (await this.checkFileServer()) {
fileServerOk = true;
break; // ready to go!
} else {
sleep(1 * 1000);
}
}

if (!fileServerOk)
Expand Down
1 change: 1 addition & 0 deletions javascript/packages/orchestrator/src/spawner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export const spawnNode = async (
keystoreLocalDir,
parachainSpecId || network.chainId,
node.dbSnapshot,
true, // long running
);

const [nodeIp, nodePort] = await client.getNodeInfo(podDef.metadata.name);
Expand Down

0 comments on commit 4ecabc4

Please sign in to comment.