Delete k8s pod explicitly to free up pvc
parent
3f4d4bf331
commit
60a7570943
|
|
@ -1943,7 +1943,6 @@ class Kubernetes {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
runTask(buildGuid, image, commands, mountdir, workingdir, environment, secrets) {
|
runTask(buildGuid, image, commands, mountdir, workingdir, environment, secrets) {
|
||||||
var _a;
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
// setup
|
// setup
|
||||||
|
|
@ -1954,9 +1953,8 @@ class Kubernetes {
|
||||||
yield kubernetes_secret_1.default.createSecret(secrets, this.secretName, this.namespace, this.kubeClient);
|
yield kubernetes_secret_1.default.createSecret(secrets, this.secretName, this.namespace, this.kubeClient);
|
||||||
const jobSpec = kubernetes_job_spec_factory_1.default.getJobSpec(commands, image, mountdir, workingdir, environment, secrets, this.buildGuid, this.buildParameters, this.secretName, this.pvcName, this.jobName, k8s);
|
const jobSpec = kubernetes_job_spec_factory_1.default.getJobSpec(commands, image, mountdir, workingdir, environment, secrets, this.buildGuid, this.buildParameters, this.secretName, this.pvcName, this.jobName, k8s);
|
||||||
//run
|
//run
|
||||||
cloud_runner_logger_1.default.log('Creating build job');
|
const jobResult = yield this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
||||||
this.jobName =
|
cloud_runner_logger_1.default.log(`Creating build job ${JSON.stringify(jobResult, undefined, 4)}`);
|
||||||
((_a = (yield this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec)).body.metadata) === null || _a === void 0 ? void 0 : _a.name) || this.jobName;
|
|
||||||
yield new Promise((promise) => setTimeout(promise, 5000));
|
yield new Promise((promise) => setTimeout(promise, 5000));
|
||||||
cloud_runner_logger_1.default.log('Job created');
|
cloud_runner_logger_1.default.log('Job created');
|
||||||
this.setPodNameAndContainerName(yield Kubernetes.findPodFromJob(this.kubeClient, this.jobName, this.namespace));
|
this.setPodNameAndContainerName(yield Kubernetes.findPodFromJob(this.kubeClient, this.jobName, this.namespace));
|
||||||
|
|
@ -1998,11 +1996,9 @@ class Kubernetes {
|
||||||
cleanupTaskResources() {
|
cleanupTaskResources() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
cloud_runner_logger_1.default.log('cleaning up');
|
cloud_runner_logger_1.default.log('cleaning up');
|
||||||
try {
|
|
||||||
yield async_wait_until_1.default(() => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
var _b;
|
|
||||||
try {
|
try {
|
||||||
yield this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
|
yield this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
|
||||||
|
yield this.kubeClient.deleteNamespacedPod(this.podName, this.namespace);
|
||||||
yield this.kubeClient.deleteNamespacedSecret(this.secretName, this.namespace);
|
yield this.kubeClient.deleteNamespacedSecret(this.secretName, this.namespace);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
@ -2011,8 +2007,12 @@ class Kubernetes {
|
||||||
cloud_runner_logger_1.default.log('Abandoning cleanup, build error:');
|
cloud_runner_logger_1.default.log('Abandoning cleanup, build error:');
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
yield async_wait_until_1.default(() => __awaiter(this, void 0, void 0, function* () {
|
||||||
|
var _b;
|
||||||
const jobBody = (yield this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body;
|
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;
|
const podname = (yield this.kubeClient.readNamespacedPod(this.podName, this.namespace)).body;
|
||||||
|
return (jobBody === null || ((_b = jobBody.status) === null || _b === void 0 ? void 0 : _b.active) === 0) && podname === null;
|
||||||
}), {
|
}), {
|
||||||
timeout: 500000,
|
timeout: 500000,
|
||||||
intervalBetweenAttempts: 15000,
|
intervalBetweenAttempts: 15000,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -95,9 +95,8 @@ class Kubernetes implements CloudRunnerProviderInterface {
|
||||||
);
|
);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
CloudRunnerLogger.log('Creating build job');
|
const jobResult = await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
||||||
this.jobName =
|
CloudRunnerLogger.log(`Creating build job ${JSON.stringify(jobResult, undefined, 4)}`);
|
||||||
(await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec)).body.metadata?.name || this.jobName;
|
|
||||||
|
|
||||||
await new Promise((promise) => setTimeout(promise, 5000));
|
await new Promise((promise) => setTimeout(promise, 5000));
|
||||||
CloudRunnerLogger.log('Job created');
|
CloudRunnerLogger.log('Job created');
|
||||||
|
|
@ -144,11 +143,9 @@ class Kubernetes implements CloudRunnerProviderInterface {
|
||||||
|
|
||||||
async cleanupTaskResources() {
|
async cleanupTaskResources() {
|
||||||
CloudRunnerLogger.log('cleaning up');
|
CloudRunnerLogger.log('cleaning up');
|
||||||
try {
|
|
||||||
await waitUntil(
|
|
||||||
async () => {
|
|
||||||
try {
|
try {
|
||||||
await this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
|
await this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
|
||||||
|
await this.kubeClient.deleteNamespacedPod(this.podName, this.namespace);
|
||||||
await this.kubeClient.deleteNamespacedSecret(this.secretName, this.namespace);
|
await this.kubeClient.deleteNamespacedSecret(this.secretName, this.namespace);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
CloudRunnerLogger.log('Failed to cleanup, error:');
|
CloudRunnerLogger.log('Failed to cleanup, error:');
|
||||||
|
|
@ -156,8 +153,12 @@ class Kubernetes implements CloudRunnerProviderInterface {
|
||||||
CloudRunnerLogger.log('Abandoning cleanup, build error:');
|
CloudRunnerLogger.log('Abandoning cleanup, build error:');
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
await waitUntil(
|
||||||
|
async () => {
|
||||||
const jobBody = (await this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body;
|
const jobBody = (await this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body;
|
||||||
return jobBody === null || jobBody.status?.active === 0;
|
const podname = (await this.kubeClient.readNamespacedPod(this.podName, this.namespace)).body;
|
||||||
|
return (jobBody === null || jobBody.status?.active === 0) && podname === null;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
timeout: 500000,
|
timeout: 500000,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue