check pod existence and phase to determine log stream continue
parent
c7023574c8
commit
c4e0ecca64
|
|
@ -3049,6 +3049,7 @@ class Kubernetes {
|
|||
});
|
||||
}
|
||||
runTaskInWorkflow(buildGuid, image, commands, mountdir, workingdir, environment, secrets) {
|
||||
var _a, _b;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
cloud_runner_logger_1.default.log('Cloud Runner K8s workflow!');
|
||||
|
|
@ -3068,10 +3069,9 @@ class Kubernetes {
|
|||
yield kubernetes_task_runner_1.default.watchUntilPodRunning(this.kubeClient, this.podName, this.namespace);
|
||||
cloud_runner_logger_1.default.log('Pod running, streaming logs');
|
||||
output = yield kubernetes_task_runner_1.default.runTask(this.kubeConfig, this.kubeClient, this.jobName, this.podName, 'main', this.namespace);
|
||||
if (!(yield this.kubeClient.listNamespacedPod(this.namespace)).body.items
|
||||
.map((x) => { var _a; return ((_a = x.metadata) === null || _a === void 0 ? void 0 : _a.name) || undefined; })
|
||||
.filter((x) => x !== undefined)
|
||||
.includes(this.podName)) {
|
||||
const pods = (yield this.kubeClient.listNamespacedPod(this.namespace)).body.items.filter((x) => { var _a; return this.podName === ((_a = x.metadata) === null || _a === void 0 ? void 0 : _a.name); });
|
||||
const running = pods.length > 0 && ((_a = pods[0].status) === null || _a === void 0 ? void 0 : _a.phase) !== `Running` && ((_b = pods[0].status) === null || _b === void 0 ? void 0 : _b.phase) !== `Pending`;
|
||||
if (!running) {
|
||||
cloud_runner_logger_1.default.log('Pod not found, assumed ended!');
|
||||
break;
|
||||
}
|
||||
|
|
@ -3080,8 +3080,7 @@ class Kubernetes {
|
|||
}
|
||||
}
|
||||
catch (error) {
|
||||
cloud_runner_logger_1.default.log('error running k8s workflow');
|
||||
cloud_runner_logger_1.default.log(error.message);
|
||||
cloud_runner_logger_1.default.log(`error running k8s workflow ${error}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
@ -4153,6 +4152,7 @@ class RemoteClient {
|
|||
return;
|
||||
}
|
||||
if (fs_1.default.existsSync(cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute)) {
|
||||
remote_client_logger_1.RemoteClientLogger.log(`${cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute} repo exists cleaning up`);
|
||||
yield cloud_runner_system_1.CloudRunnerSystem.Run(`rm -r ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute)}`);
|
||||
}
|
||||
try {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -149,20 +149,19 @@ class Kubernetes implements ProviderInterface {
|
|||
'main',
|
||||
this.namespace,
|
||||
);
|
||||
if (
|
||||
!(await this.kubeClient.listNamespacedPod(this.namespace)).body.items
|
||||
.map((x) => x.metadata?.name || undefined)
|
||||
.filter((x) => x !== undefined)
|
||||
.includes(this.podName)
|
||||
) {
|
||||
const pods = (await this.kubeClient.listNamespacedPod(this.namespace)).body.items.filter(
|
||||
(x) => this.podName === x.metadata?.name,
|
||||
);
|
||||
const running = pods.length > 0 && pods[0].status?.phase !== `Running` && pods[0].status?.phase !== `Pending`;
|
||||
|
||||
if (!running) {
|
||||
CloudRunnerLogger.log('Pod not found, assumed ended!');
|
||||
break;
|
||||
} else {
|
||||
CloudRunnerLogger.log('Pod still running, recovering stream...');
|
||||
}
|
||||
} catch (error: any) {
|
||||
CloudRunnerLogger.log('error running k8s workflow');
|
||||
CloudRunnerLogger.log(error.message);
|
||||
CloudRunnerLogger.log(`error running k8s workflow ${error}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ export class RemoteClient {
|
|||
}
|
||||
|
||||
if (fs.existsSync(CloudRunnerFolders.repoPathAbsolute)) {
|
||||
RemoteClientLogger.log(`${CloudRunnerFolders.repoPathAbsolute} repo exists cleaning up`);
|
||||
await CloudRunnerSystem.Run(`rm -r ${CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.repoPathAbsolute)}`);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue