catch setup resource errors
parent
aa15eda155
commit
4384dbfb25
|
|
@ -1411,48 +1411,50 @@ class KubernetesCleanupCronJob {
|
|||
});
|
||||
}
|
||||
static createCleanupCronJob(kubeClientBatch, name, namespace) {
|
||||
try {
|
||||
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',
|
||||
`
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
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: '',
|
||||
],
|
||||
restartPolicy: '',
|
||||
},
|
||||
],
|
||||
};
|
||||
batchJob.spec = {
|
||||
schedule: cronInstance.schedule(new Date(date)).toString(),
|
||||
jobTemplate: {
|
||||
spec: {
|
||||
template: { spec },
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
batchJob.spec = {
|
||||
schedule: cronInstance.schedule(new Date(date)).toString(),
|
||||
jobTemplate: {
|
||||
spec: {
|
||||
template: { spec },
|
||||
},
|
||||
},
|
||||
};
|
||||
kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
|
||||
}
|
||||
catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
yield kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
|
||||
}
|
||||
catch (error) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = KubernetesCleanupCronJob;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -4,7 +4,7 @@ class KubernetesCleanupCronJob {
|
|||
static async cleanup(api: BatchV1beta1Api, name: string, namespace: string) {
|
||||
await api.deleteNamespacedCronJob('name', namespace);
|
||||
}
|
||||
static createCleanupCronJob(kubeClientBatch: BatchV1beta1Api, name: string, namespace: string) {
|
||||
static async createCleanupCronJob(kubeClientBatch: BatchV1beta1Api, name: string, namespace: string) {
|
||||
try {
|
||||
const batchJob = new V1beta1CronJob();
|
||||
batchJob.kind = 'CronJob';
|
||||
|
|
@ -43,7 +43,7 @@ class KubernetesCleanupCronJob {
|
|||
},
|
||||
};
|
||||
|
||||
kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
|
||||
await kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue