Fix kubernetes cleanup to retry delete

pull/310/head
Frostebite 2022-01-30 15:41:45 +00:00
parent 85068a482d
commit ad0dfc7b72
3 changed files with 29 additions and 22 deletions

26
dist/index.js vendored
View File

@ -1997,17 +1997,21 @@ class Kubernetes {
return __awaiter(this, void 0, void 0, function* () {
cloud_runner_logger_1.default.log('cleaning up');
try {
yield this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
yield this.kubeClient.deleteNamespacedSecret(this.secretName, this.namespace);
}
catch (error) {
cloud_runner_logger_1.default.log('Failed to cleanup, error:');
core.error(JSON.stringify(error, undefined, 4));
cloud_runner_logger_1.default.log('Abandoning cleanup, build error:');
throw error;
}
try {
yield async_wait_until_1.default(() => __awaiter(this, void 0, void 0, function* () { return (yield this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body === null; }), {
yield async_wait_until_1.default(() => __awaiter(this, void 0, void 0, function* () {
var _b;
try {
yield this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
yield this.kubeClient.deleteNamespacedSecret(this.secretName, this.namespace);
}
catch (error) {
cloud_runner_logger_1.default.log('Failed to cleanup, error:');
core.error(JSON.stringify(error, undefined, 4));
cloud_runner_logger_1.default.log('Abandoning cleanup, build error:');
throw error;
}
const jobBody = (yield this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body;
return jobBody === null || ((_b = jobBody.status) === null || _b === void 0 ? void 0 : _b.active) === 0;
}), {
timeout: 500000,
intervalBetweenAttempts: 15000,
});

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -142,18 +142,21 @@ class Kubernetes implements CloudRunnerProviderInterface {
async cleanupTaskResources() {
CloudRunnerLogger.log('cleaning up');
try {
await this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
await this.kubeClient.deleteNamespacedSecret(this.secretName, this.namespace);
} catch (error) {
CloudRunnerLogger.log('Failed to cleanup, error:');
core.error(JSON.stringify(error, undefined, 4));
CloudRunnerLogger.log('Abandoning cleanup, build error:');
throw error;
}
try {
await waitUntil(
async () => (await this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body === null,
async () => {
try {
await this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
await this.kubeClient.deleteNamespacedSecret(this.secretName, this.namespace);
} catch (error) {
CloudRunnerLogger.log('Failed to cleanup, error:');
core.error(JSON.stringify(error, undefined, 4));
CloudRunnerLogger.log('Abandoning cleanup, build error:');
throw error;
}
const jobBody = (await this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body;
return jobBody === null || jobBody.status?.active === 0;
},
{
timeout: 500000,
intervalBetweenAttempts: 15000,