From 167778803b39826c29509042bd0129a6dce82d1c Mon Sep 17 00:00:00 2001 From: Omar Kassem Date: Mon, 2 Dec 2024 10:47:11 +0200 Subject: [PATCH] Refactor(deploymentList/Caprover): enhance deleting caprover deployment (#3675) * Refactor(deploymentList/Caprover): enhance deleting caprover deployment * Docs(Caprover/delete): add comment to explain why we ignore caproverDeployment in delete_machine and go for machines.delete --- packages/playground/src/utils/delete_deployment.ts | 5 +++-- packages/playground/src/weblets/tf_deployment_list.vue | 6 +----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/playground/src/utils/delete_deployment.ts b/packages/playground/src/utils/delete_deployment.ts index 44e37d1654..11ef548762 100644 --- a/packages/playground/src/utils/delete_deployment.ts +++ b/packages/playground/src/utils/delete_deployment.ts @@ -12,6 +12,7 @@ export interface DeleteDeploymentOptions { projectName: ProjectName; ip?: string[]; k8s?: boolean; + isCaprover?: boolean; } export async function deleteDeployment(grid: GridClient, options: DeleteDeploymentOptions) { @@ -49,8 +50,8 @@ export async function deleteDeployment(grid: GridClient, options: DeleteDeployme } return grid.k8s.delete({ name: options.name }); } - - if (options.deploymentName) { + // if Caprover deployment should handled by machines.delete + if (options.deploymentName && !options.isCaprover) { return grid.machines.delete_machine({ deployment_name: options.deploymentName, name: options.name }); } diff --git a/packages/playground/src/weblets/tf_deployment_list.vue b/packages/playground/src/weblets/tf_deployment_list.vue index 4d443536a8..6898d34d7b 100644 --- a/packages/playground/src/weblets/tf_deployment_list.vue +++ b/packages/playground/src/weblets/tf_deployment_list.vue @@ -510,11 +510,6 @@ async function onDelete(k8s = false) { try { const projectNameLower = props.projectName?.toLowerCase(); const allSelectedItems = [...selectedItems.value]; - selectedItems.value.forEach(item => { - if (item.projectName?.toLowerCase().includes(ProjectName.Caprover.toLowerCase()) && item.workers) { - allSelectedItems.push(...item.workers); - } - }); await allSelectedItems.reduce(async (acc, item) => { await acc; @@ -531,6 +526,7 @@ async function onDelete(k8s = false) { projectName: item.projectName, ip: getDeploymentIps(item), k8s, + isCaprover: item.projectName?.toLowerCase().includes(ProjectName.Caprover.toLowerCase()), }); } } catch (e: any) {