catch setup resource errors
parent
ebfa50648e
commit
aa15eda155
|
|
@ -1303,10 +1303,15 @@ class Kubernetes {
|
|||
// eslint-disable-next-line no-unused-vars
|
||||
defaultSecretsArray) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
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);
|
||||
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,43 +1411,48 @@ class KubernetesCleanupCronJob {
|
|||
});
|
||||
}
|
||||
static createCleanupCronJob(kubeClientBatch, name, namespace) {
|
||||
const batchJob = new client_node_1.V1beta1CronJob();
|
||||
batchJob.kind = 'CronJob';
|
||||
batchJob.metadata = {
|
||||
name,
|
||||
labels: {
|
||||
app: 'unity-builder',
|
||||
},
|
||||
};
|
||||
const cronInstance = new cron_converter_1.Cron();
|
||||
const date = Date.now() + 1000 * 60 * 60;
|
||||
const spec = {
|
||||
containers: [
|
||||
{
|
||||
name: 'main',
|
||||
image: 'bitnami/kubectl',
|
||||
imagePullPolicy: '',
|
||||
command: ['/bin/sh'],
|
||||
args: [
|
||||
'-c',
|
||||
`
|
||||
echo "delete the kubernetes resources"
|
||||
kubectl get pods
|
||||
`,
|
||||
],
|
||||
restartPolicy: '',
|
||||
try {
|
||||
const batchJob = new client_node_1.V1beta1CronJob();
|
||||
batchJob.kind = 'CronJob';
|
||||
batchJob.metadata = {
|
||||
name,
|
||||
labels: {
|
||||
app: 'unity-builder',
|
||||
},
|
||||
],
|
||||
};
|
||||
batchJob.spec = {
|
||||
schedule: cronInstance.schedule(new Date(date)).toString(),
|
||||
jobTemplate: {
|
||||
spec: {
|
||||
template: { spec },
|
||||
};
|
||||
const cronInstance = new cron_converter_1.Cron();
|
||||
const date = Date.now() + 1000 * 60 * 60;
|
||||
const spec = {
|
||||
containers: [
|
||||
{
|
||||
name: 'main',
|
||||
image: 'bitnami/kubectl',
|
||||
imagePullPolicy: '',
|
||||
command: ['/bin/sh'],
|
||||
args: [
|
||||
'-c',
|
||||
`
|
||||
echo "delete the kubernetes resources"
|
||||
kubectl get pods
|
||||
`,
|
||||
],
|
||||
restartPolicy: '',
|
||||
},
|
||||
],
|
||||
};
|
||||
batchJob.spec = {
|
||||
schedule: cronInstance.schedule(new Date(date)).toString(),
|
||||
jobTemplate: {
|
||||
spec: {
|
||||
template: { spec },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
|
||||
};
|
||||
kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
|
||||
}
|
||||
catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = KubernetesCleanupCronJob;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -46,14 +46,23 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
|||
// eslint-disable-next-line no-unused-vars
|
||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||
) {
|
||||
this.pvcName = `unity-builder-pvc-${buildUid}`;
|
||||
this.cleanupCronJobName = `unity-builder-cronjob-${buildUid}`;
|
||||
await KubernetesStorage.createPersistentVolumeClaim(buildParameters, this.pvcName, this.kubeClient, this.namespace);
|
||||
await KubernetesCleanupCronJob.createCleanupCronJob(
|
||||
this.kubeClientBatchBeta,
|
||||
this.cleanupCronJobName,
|
||||
this.namespace,
|
||||
);
|
||||
try {
|
||||
this.pvcName = `unity-builder-pvc-${buildUid}`;
|
||||
this.cleanupCronJobName = `unity-builder-cronjob-${buildUid}`;
|
||||
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(
|
||||
|
|
|
|||
|
|
@ -5,44 +5,48 @@ class KubernetesCleanupCronJob {
|
|||
await api.deleteNamespacedCronJob('name', namespace);
|
||||
}
|
||||
static createCleanupCronJob(kubeClientBatch: BatchV1beta1Api, name: string, namespace: string) {
|
||||
const batchJob = new V1beta1CronJob();
|
||||
batchJob.kind = 'CronJob';
|
||||
batchJob.metadata = {
|
||||
name,
|
||||
labels: {
|
||||
app: 'unity-builder',
|
||||
},
|
||||
};
|
||||
const cronInstance = new Cron();
|
||||
const date = Date.now() + 1000 * 60 * 60;
|
||||
const spec = {
|
||||
containers: [
|
||||
{
|
||||
name: 'main',
|
||||
image: 'bitnami/kubectl',
|
||||
imagePullPolicy: '',
|
||||
command: ['/bin/sh'],
|
||||
args: [
|
||||
'-c',
|
||||
`
|
||||
echo "delete the kubernetes resources"
|
||||
kubectl get pods
|
||||
`,
|
||||
],
|
||||
restartPolicy: '',
|
||||
try {
|
||||
const batchJob = new V1beta1CronJob();
|
||||
batchJob.kind = 'CronJob';
|
||||
batchJob.metadata = {
|
||||
name,
|
||||
labels: {
|
||||
app: 'unity-builder',
|
||||
},
|
||||
],
|
||||
};
|
||||
batchJob.spec = {
|
||||
schedule: cronInstance.schedule(new Date(date)).toString(),
|
||||
jobTemplate: {
|
||||
spec: {
|
||||
template: { spec },
|
||||
};
|
||||
const cronInstance = new Cron();
|
||||
const date = Date.now() + 1000 * 60 * 60;
|
||||
const spec = {
|
||||
containers: [
|
||||
{
|
||||
name: 'main',
|
||||
image: 'bitnami/kubectl',
|
||||
imagePullPolicy: '',
|
||||
command: ['/bin/sh'],
|
||||
args: [
|
||||
'-c',
|
||||
`
|
||||
echo "delete the kubernetes resources"
|
||||
kubectl get pods
|
||||
`,
|
||||
],
|
||||
restartPolicy: '',
|
||||
},
|
||||
],
|
||||
};
|
||||
batchJob.spec = {
|
||||
schedule: cronInstance.schedule(new Date(date)).toString(),
|
||||
jobTemplate: {
|
||||
spec: {
|
||||
template: { spec },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
|
||||
kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
export default KubernetesCleanupCronJob;
|
||||
|
|
|
|||
Loading…
Reference in New Issue