aws/k8s smoke test

pull/496/head
Frostebite 2023-02-16 01:26:35 +00:00
parent 2f91bba5c6
commit 2d67dc48fe
4 changed files with 43 additions and 5 deletions

16
dist/index.js generated vendored
View File

@ -3346,17 +3346,28 @@ class Kubernetes {
} }
cloud_runner_logger_1.default.log('Pod running, streaming logs'); cloud_runner_logger_1.default.log('Pod running, streaming logs');
const running = yield kubernetes_pods_1.default.IsPodRunning(this.podName, this.namespace, this.kubeClient); const running = yield kubernetes_pods_1.default.IsPodRunning(this.podName, this.namespace, this.kubeClient);
output += yield kubernetes_task_runner_1.default.runTask(this.kubeConfig, this.kubeClient, this.jobName, this.podName, 'main', this.namespace, running); output += yield kubernetes_task_runner_1.default.runTask(this.kubeConfig, this.kubeClient, this.jobName, this.podName, kubernetes_job_spec_factory_1.default.MainContainerName, this.namespace, running);
status = yield kubernetes_pods_1.default.GetPodStatus(this.podName, this.namespace, this.kubeClient); status = yield kubernetes_pods_1.default.GetPodStatus(this.podName, this.namespace, this.kubeClient);
if (!running) { if (!running) {
if (!follow_log_stream_service_1.FollowLogStreamService.DidReceiveEndOfTransmission && status === `Succeeded`) { if (!follow_log_stream_service_1.FollowLogStreamService.DidReceiveEndOfTransmission && status === `Succeeded`) {
output += yield kubernetes_task_runner_1.default.runTask(this.kubeConfig, this.kubeClient, this.jobName, this.podName, 'main', this.namespace, true); output += yield kubernetes_task_runner_1.default.runTask(this.kubeConfig, this.kubeClient, this.jobName, this.podName, 'main', this.namespace, true);
output += yield kubernetes_task_runner_1.default.runTask(this.kubeConfig, this.kubeClient, this.jobName, this.podName, ``, this.namespace, true);
cloud_runner_logger_1.default.log(JSON.stringify((yield this.kubeClient.listNamespacedEvent(this.namespace)).body.items
.map((x) => {
return {
message: x.message || ``,
name: x.metadata.name || ``,
reason: x.reason || ``,
};
})
.filter((x) => x.name.includes(this.podName)), undefined, 4));
break; break;
} }
if (follow_log_stream_service_1.FollowLogStreamService.DidReceiveEndOfTransmission) { if (follow_log_stream_service_1.FollowLogStreamService.DidReceiveEndOfTransmission) {
break; break;
} }
} }
status = yield kubernetes_pods_1.default.GetPodStatus(this.podName, this.namespace, this.kubeClient);
cloud_runner_logger_1.default.log(`Pod status ${status}, retrying log stream...`); cloud_runner_logger_1.default.log(`Pod status ${status}, retrying log stream...`);
} }
catch (error) { catch (error) {
@ -3596,7 +3607,7 @@ class KubernetesJobSpecFactory {
], ],
containers: [ containers: [
{ {
name: 'main', name: KubernetesJobSpecFactory.MainContainerName,
image, image,
command: ['/bin/sh'], command: ['/bin/sh'],
args: ['-c', cloud_runner_custom_hooks_1.CloudRunnerCustomHooks.ApplyHooksToCommands(command, cloud_runner_1.default.buildParameters)], args: ['-c', cloud_runner_custom_hooks_1.CloudRunnerCustomHooks.ApplyHooksToCommands(command, cloud_runner_1.default.buildParameters)],
@ -3654,6 +3665,7 @@ class KubernetesJobSpecFactory {
return job; return job;
} }
} }
KubernetesJobSpecFactory.MainContainerName = 'main';
exports["default"] = KubernetesJobSpecFactory; exports["default"] = KubernetesJobSpecFactory;

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -156,7 +156,7 @@ class Kubernetes implements ProviderInterface {
this.kubeClient, this.kubeClient,
this.jobName, this.jobName,
this.podName, this.podName,
'main', KubernetesJobSpecFactory.MainContainerName,
this.namespace, this.namespace,
running, running,
); );
@ -173,6 +173,30 @@ class Kubernetes implements ProviderInterface {
this.namespace, this.namespace,
true, true,
); );
output += await KubernetesTaskRunner.runTask(
this.kubeConfig,
this.kubeClient,
this.jobName,
this.podName,
``,
this.namespace,
true,
);
CloudRunnerLogger.log(
JSON.stringify(
(await this.kubeClient.listNamespacedEvent(this.namespace)).body.items
.map((x) => {
return {
message: x.message || ``,
name: x.metadata.name || ``,
reason: x.reason || ``,
};
})
.filter((x) => x.name.includes(this.podName)),
undefined,
4,
),
);
break; break;
} }
@ -180,6 +204,7 @@ class Kubernetes implements ProviderInterface {
break; break;
} }
} }
status = await KubernetesPods.GetPodStatus(this.podName, this.namespace, this.kubeClient);
CloudRunnerLogger.log(`Pod status ${status}, retrying log stream...`); CloudRunnerLogger.log(`Pod status ${status}, retrying log stream...`);
} catch (error: any) { } catch (error: any) {
let errorParsed; let errorParsed;

View File

@ -6,6 +6,7 @@ import CloudRunnerSecret from '../../services/cloud-runner-secret';
import CloudRunner from '../../cloud-runner'; import CloudRunner from '../../cloud-runner';
class KubernetesJobSpecFactory { class KubernetesJobSpecFactory {
public static readonly MainContainerName = 'main';
static getJobSpec( static getJobSpec(
command: string, command: string,
image: string, image: string,
@ -101,7 +102,7 @@ class KubernetesJobSpecFactory {
], ],
containers: [ containers: [
{ {
name: 'main', name: KubernetesJobSpecFactory.MainContainerName,
image, image,
command: ['/bin/sh'], command: ['/bin/sh'],
args: ['-c', CloudRunnerCustomHooks.ApplyHooksToCommands(command, CloudRunner.buildParameters)], args: ['-c', CloudRunnerCustomHooks.ApplyHooksToCommands(command, CloudRunner.buildParameters)],