retained workspace for k8s
parent
605fca859f
commit
a63b155b63
|
|
@ -2882,9 +2882,7 @@ class Kubernetes {
|
||||||
defaultSecretsArray) {
|
defaultSecretsArray) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const id = buildParameters.retainWorkspace && cloud_runner_1.default.lockedWorkspace
|
const id = buildParameters.retainWorkspace ? cloud_runner_1.default.lockedWorkspace : buildParameters.buildGuid;
|
||||||
? cloud_runner_1.default.lockedWorkspace
|
|
||||||
: buildParameters.buildGuid;
|
|
||||||
this.pvcName = `unity-builder-pvc-${id}`;
|
this.pvcName = `unity-builder-pvc-${id}`;
|
||||||
this.cleanupCronJobName = `unity-builder-cronjob-${id}`;
|
this.cleanupCronJobName = `unity-builder-cronjob-${id}`;
|
||||||
this.serviceAccountName = `service-account-${buildParameters.buildGuid}`;
|
this.serviceAccountName = `service-account-${buildParameters.buildGuid}`;
|
||||||
|
|
@ -2991,16 +2989,15 @@ class Kubernetes {
|
||||||
catch (_a) { }
|
catch (_a) { }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
cleanup(
|
cleanup(buildGuid, buildParameters,
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
buildGuid,
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
buildParameters,
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
branchName,
|
branchName,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
defaultSecretsArray) {
|
defaultSecretsArray) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (buildParameters.retainWorkspace) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
cloud_runner_logger_1.default.log(`deleting PVC`);
|
cloud_runner_logger_1.default.log(`deleting PVC`);
|
||||||
try {
|
try {
|
||||||
const promise = this.kubeClient.deleteNamespacedPersistentVolumeClaim(this.pvcName, this.namespace);
|
const promise = this.kubeClient.deleteNamespacedPersistentVolumeClaim(this.pvcName, this.namespace);
|
||||||
|
|
@ -3350,8 +3347,10 @@ class KubernetesStorage {
|
||||||
pvcName = buildParameters.kubeVolume;
|
pvcName = buildParameters.kubeVolume;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const pvcList = (yield kubeClient.listNamespacedPersistentVolumeClaim(namespace)).body.items.map((x) => { var _a; return (_a = x.metadata) === null || _a === void 0 ? void 0 : _a.name; });
|
const allPvc = (yield kubeClient.listNamespacedPersistentVolumeClaim(namespace)).body.items;
|
||||||
|
const pvcList = allPvc.map((x) => { var _a; return (_a = x.metadata) === null || _a === void 0 ? void 0 : _a.name; });
|
||||||
cloud_runner_logger_1.default.log(`Current PVCs in namespace ${namespace}`);
|
cloud_runner_logger_1.default.log(`Current PVCs in namespace ${namespace}`);
|
||||||
|
cloud_runner_logger_1.default.log(JSON.stringify(allPvc, undefined, 4));
|
||||||
cloud_runner_logger_1.default.log(JSON.stringify(pvcList, undefined, 4));
|
cloud_runner_logger_1.default.log(JSON.stringify(pvcList, undefined, 4));
|
||||||
if (pvcList.includes(pvcName)) {
|
if (pvcList.includes(pvcName)) {
|
||||||
cloud_runner_logger_1.default.log(`pvc ${pvcName} already exists`);
|
cloud_runner_logger_1.default.log(`pvc ${pvcName} already exists`);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -65,10 +65,7 @@ class Kubernetes implements ProviderInterface {
|
||||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const id =
|
const id = buildParameters.retainWorkspace ? CloudRunner.lockedWorkspace : buildParameters.buildGuid;
|
||||||
buildParameters.retainWorkspace && CloudRunner.lockedWorkspace
|
|
||||||
? CloudRunner.lockedWorkspace
|
|
||||||
: buildParameters.buildGuid;
|
|
||||||
this.pvcName = `unity-builder-pvc-${id}`;
|
this.pvcName = `unity-builder-pvc-${id}`;
|
||||||
this.cleanupCronJobName = `unity-builder-cronjob-${id}`;
|
this.cleanupCronJobName = `unity-builder-cronjob-${id}`;
|
||||||
this.serviceAccountName = `service-account-${buildParameters.buildGuid}`;
|
this.serviceAccountName = `service-account-${buildParameters.buildGuid}`;
|
||||||
|
|
@ -211,15 +208,16 @@ class Kubernetes implements ProviderInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
async cleanup(
|
async cleanup(
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
buildGuid: string,
|
buildGuid: string,
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
buildParameters: BuildParameters,
|
buildParameters: BuildParameters,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
branchName: string,
|
branchName: string,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
) {
|
) {
|
||||||
|
if (buildParameters.retainWorkspace) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
CloudRunnerLogger.log(`deleting PVC`);
|
CloudRunnerLogger.log(`deleting PVC`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ class KubernetesStorage {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const pvcList = (await kubeClient.listNamespacedPersistentVolumeClaim(namespace)).body.items.map(
|
const allPvc = (await kubeClient.listNamespacedPersistentVolumeClaim(namespace)).body.items;
|
||||||
(x) => x.metadata?.name,
|
const pvcList = allPvc.map((x) => x.metadata?.name);
|
||||||
);
|
|
||||||
CloudRunnerLogger.log(`Current PVCs in namespace ${namespace}`);
|
CloudRunnerLogger.log(`Current PVCs in namespace ${namespace}`);
|
||||||
|
CloudRunnerLogger.log(JSON.stringify(allPvc, undefined, 4));
|
||||||
CloudRunnerLogger.log(JSON.stringify(pvcList, undefined, 4));
|
CloudRunnerLogger.log(JSON.stringify(pvcList, undefined, 4));
|
||||||
if (pvcList.includes(pvcName)) {
|
if (pvcList.includes(pvcName)) {
|
||||||
CloudRunnerLogger.log(`pvc ${pvcName} already exists`);
|
CloudRunnerLogger.log(`pvc ${pvcName} already exists`);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue