catch setup resource errors

pull/273/head
Frostebite 2021-06-26 03:00:49 +01:00
parent aa15eda155
commit 4384dbfb25
3 changed files with 43 additions and 41 deletions

78
dist/index.js vendored
View File

@ -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;

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -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;
}