From cea7bdaf9341b5197385d8c025642824d1bbc796 Mon Sep 17 00:00:00 2001 From: "j.dev" Date: Thu, 25 Jul 2024 08:23:06 -0700 Subject: [PATCH 1/2] chore(3242): update temporary checkbox titles --- app/components/form/TemporaryProductCheckboxAdmin.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/components/form/TemporaryProductCheckboxAdmin.tsx b/app/components/form/TemporaryProductCheckboxAdmin.tsx index 7ab1b4a4c..b6e9d1aa1 100644 --- a/app/components/form/TemporaryProductCheckboxAdmin.tsx +++ b/app/components/form/TemporaryProductCheckboxAdmin.tsx @@ -62,8 +62,8 @@ export default function TemporaryProductCheckboxAdmin({ disabled={disabled} className={{ label: 'text-lg', input: 'ml-1' }} showConfirm - confirmCheckedTitle="Are you sure you want to set this product as a permanent product set?" - confirmUncheckedTitle="Are you sure you want to set this product as a temporary product set?" + confirmCheckedTitle="Are you sure you want to set this product as a temporary product set?" + confirmUncheckedTitle="Are you sure you want to set this product as a permanent product set?" confirmCheckedMessage="You have selected a temporary product set. Please be aware that everything in the provisioned namespaces will be deleted after 30 days, including all data and deployments." confirmUncheckedMessage="You have unchecked a temporary product set. Please be aware that product set will NOT be deleted after 30 days." > From 03ab1d8242a39a57106fd64e6594e327afad9e9c Mon Sep 17 00:00:00 2001 From: "j.dev" Date: Thu, 25 Jul 2024 09:20:53 -0700 Subject: [PATCH 2/2] chore(3077): skip temporary products with an active request --- .../form/TemporaryProductCheckboxAdmin.tsx | 2 +- .../tools/dags/_temporary_products_deletion.py | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/components/form/TemporaryProductCheckboxAdmin.tsx b/app/components/form/TemporaryProductCheckboxAdmin.tsx index b6e9d1aa1..8a13f0719 100644 --- a/app/components/form/TemporaryProductCheckboxAdmin.tsx +++ b/app/components/form/TemporaryProductCheckboxAdmin.tsx @@ -52,7 +52,7 @@ export default function TemporaryProductCheckboxAdmin({ if (formState.dirtyFields.isTest) { updateFlag(isTest); } - }, [formState.dirtyFields.isTest]); + }, [updateFlag, formState.dirtyFields.isTest, isTest]); return ( diff --git a/helm/tools/dags/_temporary_products_deletion.py b/helm/tools/dags/_temporary_products_deletion.py index f6887b17d..5a53ac324 100644 --- a/helm/tools/dags/_temporary_products_deletion.py +++ b/helm/tools/dags/_temporary_products_deletion.py @@ -13,6 +13,7 @@ def send_temp_products_deletion_request( thirty_days_ago = datetime.now(timezone.utc) - timedelta(days=30) query = {"isTest": True, "status": "ACTIVE", "createdAt": {"$lt": thirty_days_ago}} + print(f"Querying {query}...") projection = {"_id": False, "licencePlate": True} projects = db.PrivateCloudProject.find(query, projection=projection) @@ -21,11 +22,20 @@ def send_temp_products_deletion_request( count = 0 for project in projects: - count += 1 licence_plate = project.get("licencePlate") print(f"Processing {licence_plate}...") - url = product_deletion_url_template.format(licence_plate) - response = requests.delete(url, headers=headers) - response.raise_for_status() + + reqQuery = {"licencePlate": licence_plate, "active": True} + reqProjection = {"_id": True} + activeReq = db.PrivateCloudRequest.find_one(reqQuery, projection=reqProjection) + + if activeReq is None: + count += 1 + url = product_deletion_url_template.format(licence_plate) + print(f"Sending a request to {url}") + response = requests.delete(url, headers=headers) + response.raise_for_status() + else: + print(f"Has an active request; skipping...") return {"status": "success", "count": count}