catch setup resource errors

pull/273/head
Frostebite 2021-06-26 02:54:37 +01:00
parent ebfa50648e
commit aa15eda155
4 changed files with 106 additions and 83 deletions

10
dist/index.js vendored
View File

@ -1303,10 +1303,15 @@ class Kubernetes {
// eslint-disable-next-line no-unused-vars
defaultSecretsArray) {
return __awaiter(this, void 0, void 0, function* () {
try {
this.pvcName = `unity-builder-pvc-${buildUid}`;
this.cleanupCronJobName = `unity-builder-cronjob-${buildUid}`;
yield kubernetes_storage_1.default.createPersistentVolumeClaim(buildParameters, this.pvcName, this.kubeClient, this.namespace);
yield kubernetes_cleanup_cronjob_1.default.createCleanupCronJob(this.kubeClientBatchBeta, this.cleanupCronJobName, this.namespace);
}
catch (error) {
throw error;
}
});
}
runBuildTask(buildId, image, commands, mountdir, workingdir, environment, secrets) {
@ -1406,6 +1411,7 @@ class KubernetesCleanupCronJob {
});
}
static createCleanupCronJob(kubeClientBatch, name, namespace) {
try {
const batchJob = new client_node_1.V1beta1CronJob();
batchJob.kind = 'CronJob';
batchJob.metadata = {
@ -1444,6 +1450,10 @@ class KubernetesCleanupCronJob {
};
kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
}
catch (error) {
throw error;
}
}
}
exports.default = KubernetesCleanupCronJob;

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -46,14 +46,23 @@ class Kubernetes implements RemoteBuilderProviderInterface {
// eslint-disable-next-line no-unused-vars
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
) {
try {
this.pvcName = `unity-builder-pvc-${buildUid}`;
this.cleanupCronJobName = `unity-builder-cronjob-${buildUid}`;
await KubernetesStorage.createPersistentVolumeClaim(buildParameters, this.pvcName, this.kubeClient, this.namespace);
await KubernetesStorage.createPersistentVolumeClaim(
buildParameters,
this.pvcName,
this.kubeClient,
this.namespace,
);
await KubernetesCleanupCronJob.createCleanupCronJob(
this.kubeClientBatchBeta,
this.cleanupCronJobName,
this.namespace,
);
} catch (error) {
throw error;
}
}
async runBuildTask(

View File

@ -5,6 +5,7 @@ class KubernetesCleanupCronJob {
await api.deleteNamespacedCronJob('name', namespace);
}
static createCleanupCronJob(kubeClientBatch: BatchV1beta1Api, name: string, namespace: string) {
try {
const batchJob = new V1beta1CronJob();
batchJob.kind = 'CronJob';
batchJob.metadata = {
@ -43,6 +44,9 @@ class KubernetesCleanupCronJob {
};
kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
} catch (error) {
throw error;
}
}
}
export default KubernetesCleanupCronJob;