fix: k8s stability

pull/437/head
Frostebite 2022-11-02 00:20:03 +00:00
parent ceedd5808a
commit 2dae588749
3 changed files with 3 additions and 9 deletions

5
dist/index.js vendored
View File

@ -3057,8 +3057,6 @@ class Kubernetes {
this.secretName = `build-credentials-${this.buildGuid}`; this.secretName = `build-credentials-${this.buildGuid}`;
this.jobName = `unity-builder-job-${this.buildGuid}`; this.jobName = `unity-builder-job-${this.buildGuid}`;
this.containerName = `main`; this.containerName = `main`;
const namespaceListTest = yield this.kubeClient.listNamespace();
cloud_runner_logger_1.default.log(`Init test ${namespaceListTest.body.items.length}`);
yield kubernetes_secret_1.default.createSecret(secrets, this.secretName, this.namespace, this.kubeClient); yield kubernetes_secret_1.default.createSecret(secrets, this.secretName, this.namespace, this.kubeClient);
yield this.createNamespacedJob(commands, image, mountdir, workingdir, environment, secrets); yield this.createNamespacedJob(commands, image, mountdir, workingdir, environment, secrets);
this.setPodNameAndContainerName(yield Kubernetes.findPodFromJob(this.kubeClient, this.jobName, this.namespace)); this.setPodNameAndContainerName(yield Kubernetes.findPodFromJob(this.kubeClient, this.jobName, this.namespace));
@ -3102,9 +3100,7 @@ class Kubernetes {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
for (let index = 0; index < 3; index++) { for (let index = 0; index < 3; index++) {
try { try {
cloud_runner_logger_1.default.log(`Job spec creating`);
const jobSpec = kubernetes_job_spec_factory_1.default.getJobSpec(commands, image, mountdir, workingdir, environment, secrets, this.buildGuid, this.buildParameters, this.secretName, this.pvcName, this.jobName, k8s); const jobSpec = kubernetes_job_spec_factory_1.default.getJobSpec(commands, image, mountdir, workingdir, environment, secrets, this.buildGuid, this.buildParameters, this.secretName, this.pvcName, this.jobName, k8s);
cloud_runner_logger_1.default.log(`Job spec created`);
yield new Promise((promise) => setTimeout(promise, 15000)); yield new Promise((promise) => setTimeout(promise, 15000));
yield this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec); yield this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
cloud_runner_logger_1.default.log(`Build job created`); cloud_runner_logger_1.default.log(`Build job created`);
@ -3114,6 +3110,7 @@ class Kubernetes {
} }
catch (error) { catch (error) {
cloud_runner_logger_1.default.log(`Error occured creating job: ${error}`); cloud_runner_logger_1.default.log(`Error occured creating job: ${error}`);
throw error;
} }
} }
}); });

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -131,8 +131,6 @@ class Kubernetes implements ProviderInterface {
this.secretName = `build-credentials-${this.buildGuid}`; this.secretName = `build-credentials-${this.buildGuid}`;
this.jobName = `unity-builder-job-${this.buildGuid}`; this.jobName = `unity-builder-job-${this.buildGuid}`;
this.containerName = `main`; this.containerName = `main`;
const namespaceListTest = await this.kubeClient.listNamespace();
CloudRunnerLogger.log(`Init test ${namespaceListTest.body.items.length}`);
await KubernetesSecret.createSecret(secrets, this.secretName, this.namespace, this.kubeClient); await KubernetesSecret.createSecret(secrets, this.secretName, this.namespace, this.kubeClient);
await this.createNamespacedJob(commands, image, mountdir, workingdir, environment, secrets); await this.createNamespacedJob(commands, image, mountdir, workingdir, environment, secrets);
this.setPodNameAndContainerName(await Kubernetes.findPodFromJob(this.kubeClient, this.jobName, this.namespace)); this.setPodNameAndContainerName(await Kubernetes.findPodFromJob(this.kubeClient, this.jobName, this.namespace));
@ -189,7 +187,6 @@ class Kubernetes implements ProviderInterface {
) { ) {
for (let index = 0; index < 3; index++) { for (let index = 0; index < 3; index++) {
try { try {
CloudRunnerLogger.log(`Job spec creating`);
const jobSpec = KubernetesJobSpecFactory.getJobSpec( const jobSpec = KubernetesJobSpecFactory.getJobSpec(
commands, commands,
image, image,
@ -204,7 +201,6 @@ class Kubernetes implements ProviderInterface {
this.jobName, this.jobName,
k8s, k8s,
); );
CloudRunnerLogger.log(`Job spec created`);
await new Promise((promise) => setTimeout(promise, 15000)); await new Promise((promise) => setTimeout(promise, 15000));
await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec); await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
CloudRunnerLogger.log(`Build job created`); CloudRunnerLogger.log(`Build job created`);
@ -214,6 +210,7 @@ class Kubernetes implements ProviderInterface {
return; return;
} catch (error) { } catch (error) {
CloudRunnerLogger.log(`Error occured creating job: ${error}`); CloudRunnerLogger.log(`Error occured creating job: ${error}`);
throw error;
} }
} }
} }