recursive static function to watch PVC Claiming
parent
904abebc7e
commit
3ec01bf2a4
File diff suppressed because one or more lines are too long
|
|
@ -25,9 +25,9 @@ class Kubernetes {
|
||||||
|
|
||||||
await Kubernetes.createSecret();
|
await Kubernetes.createSecret();
|
||||||
await Kubernetes.createPersistentVolumeClaim();
|
await Kubernetes.createPersistentVolumeClaim();
|
||||||
await Kubernetes.createBuildJob();
|
await Kubernetes.scheduleBuildJob();
|
||||||
await Kubernetes.watchBuildJobUntilFinished();
|
await Kubernetes.watchBuildJobUntilFinished();
|
||||||
await Kubernetes.cleanupJob();
|
await Kubernetes.cleanup();
|
||||||
|
|
||||||
core.setOutput('kubernetesPVC', pvcName);
|
core.setOutput('kubernetesPVC', pvcName);
|
||||||
}
|
}
|
||||||
|
|
@ -71,19 +71,21 @@ class Kubernetes {
|
||||||
await this.kubeClient.api.v1
|
await this.kubeClient.api.v1
|
||||||
.namespaces('default')
|
.namespaces('default')
|
||||||
.persistentvolumeclaims.post({ body: pvcManifest });
|
.persistentvolumeclaims.post({ body: pvcManifest });
|
||||||
let ready = false;
|
await Kubernetes.watchBuildJobUntilFinished();
|
||||||
while (!ready) {
|
core.info('Persistent Volume ready for claims');
|
||||||
// eslint-disable-next-line no-await-in-loop
|
|
||||||
const queryResult = await this.kubeClient.api.v1
|
|
||||||
.namespaces('default')
|
|
||||||
.persistentvolumeclaims(this.pvcName)
|
|
||||||
.get();
|
|
||||||
ready = queryResult.body.status.phase !== 'Pending';
|
|
||||||
}
|
|
||||||
core.info('PVC created');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async createBuildJob() {
|
static async watchPersistentVolumeClaimUntilReady() {
|
||||||
|
const queryResult = await this.kubeClient.api.v1
|
||||||
|
.namespaces('default')
|
||||||
|
.persistentvolumeclaims(this.pvcName)
|
||||||
|
.get();
|
||||||
|
if (queryResult.body.status.phase === 'Pending') {
|
||||||
|
await Kubernetes.watchPersistentVolumeClaimUntilReady();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async scheduleBuildJob() {
|
||||||
core.info('Creating build job');
|
core.info('Creating build job');
|
||||||
const jobManifest = {
|
const jobManifest = {
|
||||||
apiVersion: 'batch/v1',
|
apiVersion: 'batch/v1',
|
||||||
|
|
@ -265,10 +267,6 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!podname) {
|
|
||||||
core.error('no pods to stream logs from found');
|
|
||||||
}
|
|
||||||
|
|
||||||
core.info(`Watching build job ${podname}`);
|
core.info(`Watching build job ${podname}`);
|
||||||
let logQueryTime;
|
let logQueryTime;
|
||||||
let complete = false;
|
let complete = false;
|
||||||
|
|
@ -311,7 +309,7 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async cleanupJob() {
|
static async cleanup() {
|
||||||
await this.kubeClient.apis.batch.v1.namespaces('default').jobs(this.jobName).delete();
|
await this.kubeClient.apis.batch.v1.namespaces('default').jobs(this.jobName).delete();
|
||||||
await this.kubeClient.api.v1.namespaces('default').secrets(this.secretName).delete();
|
await this.kubeClient.api.v1.namespaces('default').secrets(this.secretName).delete();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue