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