cleanup
parent
7c4df887c4
commit
bc8208b484
|
|
@ -2888,13 +2888,8 @@ class Kubernetes {
|
||||||
this.secretName = `build-credentials-${buildGuid}`;
|
this.secretName = `build-credentials-${buildGuid}`;
|
||||||
this.jobName = `unity-builder-job-${buildGuid}`;
|
this.jobName = `unity-builder-job-${buildGuid}`;
|
||||||
this.containerName = `main`;
|
this.containerName = `main`;
|
||||||
yield kubernetes_secret_1.default.createSecret(secrets, this.secretName, this.namespace, this.kubeClient);
|
yield this.createSecret(secrets);
|
||||||
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);
|
yield this.createNamespacedJob(commands, image, mountdir, workingdir, environment, secrets);
|
||||||
cloud_runner_logger_1.default.log(`Build job secret created ${JSON.stringify(this.secretName, undefined, 4)}`);
|
|
||||||
const jobResult = yield this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
|
||||||
cloud_runner_logger_1.default.log(`Build job created ${JSON.stringify(jobResult.body.metadata, undefined, 4)}`);
|
|
||||||
yield new Promise((promise) => setTimeout(promise, 5000));
|
|
||||||
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));
|
||||||
cloud_runner_logger_1.default.log('Watching pod until running');
|
cloud_runner_logger_1.default.log('Watching pod until running');
|
||||||
let output = '';
|
let output = '';
|
||||||
|
|
@ -2926,6 +2921,21 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
createSecret(secrets) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
yield kubernetes_secret_1.default.createSecret(secrets, this.secretName, this.namespace, this.kubeClient);
|
||||||
|
cloud_runner_logger_1.default.log(`Secret created`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
createNamespacedJob(commands, image, mountdir, workingdir, environment, secrets) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
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);
|
||||||
|
yield this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
||||||
|
cloud_runner_logger_1.default.log(`Build job created`);
|
||||||
|
yield new Promise((promise) => setTimeout(promise, 5000));
|
||||||
|
cloud_runner_logger_1.default.log('Job created');
|
||||||
|
});
|
||||||
|
}
|
||||||
setPodNameAndContainerName(pod) {
|
setPodNameAndContainerName(pod) {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
this.podName = ((_a = pod.metadata) === null || _a === void 0 ? void 0 : _a.name) || '';
|
this.podName = ((_a = pod.metadata) === null || _a === void 0 ? void 0 : _a.name) || '';
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -99,28 +99,8 @@ class Kubernetes implements ProviderInterface {
|
||||||
this.secretName = `build-credentials-${buildGuid}`;
|
this.secretName = `build-credentials-${buildGuid}`;
|
||||||
this.jobName = `unity-builder-job-${buildGuid}`;
|
this.jobName = `unity-builder-job-${buildGuid}`;
|
||||||
this.containerName = `main`;
|
this.containerName = `main`;
|
||||||
await KubernetesSecret.createSecret(secrets, this.secretName, this.namespace, this.kubeClient);
|
await this.createSecret(secrets);
|
||||||
const jobSpec = KubernetesJobSpecFactory.getJobSpec(
|
await this.createNamespacedJob(commands, image, mountdir, workingdir, environment, secrets);
|
||||||
commands,
|
|
||||||
image,
|
|
||||||
mountdir,
|
|
||||||
workingdir,
|
|
||||||
environment,
|
|
||||||
secrets,
|
|
||||||
this.buildGuid,
|
|
||||||
this.buildParameters,
|
|
||||||
this.secretName,
|
|
||||||
this.pvcName,
|
|
||||||
this.jobName,
|
|
||||||
k8s,
|
|
||||||
);
|
|
||||||
CloudRunnerLogger.log(`Build job secret created ${JSON.stringify(this.secretName, undefined, 4)}`);
|
|
||||||
|
|
||||||
const jobResult = await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
|
||||||
CloudRunnerLogger.log(`Build job created ${JSON.stringify(jobResult.body.metadata, undefined, 4)}`);
|
|
||||||
|
|
||||||
await new Promise((promise) => setTimeout(promise, 5000));
|
|
||||||
CloudRunnerLogger.log('Job created');
|
|
||||||
this.setPodNameAndContainerName(await Kubernetes.findPodFromJob(this.kubeClient, this.jobName, this.namespace));
|
this.setPodNameAndContainerName(await Kubernetes.findPodFromJob(this.kubeClient, this.jobName, this.namespace));
|
||||||
CloudRunnerLogger.log('Watching pod until running');
|
CloudRunnerLogger.log('Watching pod until running');
|
||||||
let output = '';
|
let output = '';
|
||||||
|
|
@ -157,6 +137,39 @@ class Kubernetes implements ProviderInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async createSecret(secrets: CloudRunnerSecret[]) {
|
||||||
|
await KubernetesSecret.createSecret(secrets, this.secretName, this.namespace, this.kubeClient);
|
||||||
|
CloudRunnerLogger.log(`Secret created`);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async createNamespacedJob(
|
||||||
|
commands: string,
|
||||||
|
image: string,
|
||||||
|
mountdir: string,
|
||||||
|
workingdir: string,
|
||||||
|
environment: CloudRunnerEnvironmentVariable[],
|
||||||
|
secrets: CloudRunnerSecret[],
|
||||||
|
) {
|
||||||
|
const jobSpec = KubernetesJobSpecFactory.getJobSpec(
|
||||||
|
commands,
|
||||||
|
image,
|
||||||
|
mountdir,
|
||||||
|
workingdir,
|
||||||
|
environment,
|
||||||
|
secrets,
|
||||||
|
this.buildGuid,
|
||||||
|
this.buildParameters,
|
||||||
|
this.secretName,
|
||||||
|
this.pvcName,
|
||||||
|
this.jobName,
|
||||||
|
k8s,
|
||||||
|
);
|
||||||
|
await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
||||||
|
CloudRunnerLogger.log(`Build job created`);
|
||||||
|
await new Promise((promise) => setTimeout(promise, 5000));
|
||||||
|
CloudRunnerLogger.log('Job created');
|
||||||
|
}
|
||||||
|
|
||||||
setPodNameAndContainerName(pod: k8s.V1Pod) {
|
setPodNameAndContainerName(pod: k8s.V1Pod) {
|
||||||
this.podName = pod.metadata?.name || '';
|
this.podName = pod.metadata?.name || '';
|
||||||
this.containerName = pod.status?.containerStatuses?.[0].name || '';
|
this.containerName = pod.status?.containerStatuses?.[0].name || '';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue