diff --git a/scripts/cleanup_deploy_disk.sh b/scripts/cleanup_deploy_disk.sh index 9c02eeb..87123da 100644 --- a/scripts/cleanup_deploy_disk.sh +++ b/scripts/cleanup_deploy_disk.sh @@ -268,23 +268,17 @@ if retention_id is None: status, _, response_headers = request("POST", "/retentions", payload) location = response_headers.get("Location") or response_headers.get("location") or "" match = re.search(r"/retentions/(\d+)", location) - if not match: - status, refreshed_project, _ = request("GET", project_path()) - refreshed_metadata = dict((refreshed_project or {}).get("metadata") or {}) if isinstance(refreshed_project, dict) else {} - refreshed_id = str(refreshed_metadata.get("retention_id") or "").strip() - if not refreshed_id.isdigit(): - raise RuntimeError(f"retention created but id was not returned: status={status} location={location!r}") - retention_id = int(refreshed_id) - else: + if match: retention_id = int(match.group(1)) - try: - request("POST", project_path("/metadatas/"), {"retention_id": str(retention_id)}) - except RuntimeError as exc: - if "409" in str(exc): - request("PUT", project_path("/metadatas/retention_id"), {"retention_id": str(retention_id)}) - else: - raise + status, refreshed_project, _ = request("GET", project_path()) + refreshed_metadata = dict((refreshed_project or {}).get("metadata") or {}) if isinstance(refreshed_project, dict) else {} + refreshed_id = str(refreshed_metadata.get("retention_id") or "").strip() + if refreshed_id.isdigit(): + retention_id = int(refreshed_id) + elif retention_id is None: + raise RuntimeError(f"retention created but id was not returned: status={status} location={location!r}") + print(f"created retention_id={retention_id}") else: status, existing_policy, _ = request("GET", f"/retentions/{retention_id}")