Skip to content

fix: prevent cleanup from deleting shared org - #1295

Merged
bonzofenix merged 3 commits into
mainfrom
worktree-protect-shared-org
Jun 25, 2026
Merged

fix: prevent cleanup from deleting shared org#1295
bonzofenix merged 3 commits into
mainfrom
worktree-protect-shared-org

Conversation

@bonzofenix

Copy link
Copy Markdown
Contributor

Problem

Multiple PRs deploy into the shared org SAP_autoscaler_tests_OSS. The cleanup step in scripts/common.sh unconditionally deletes whatever org AUTOSCALER_ORG points to — if one PR's cleanup runs, it destroys the shared org and all other running PR deployments lose their space and service broker registrations.

Root Cause

Traced via CI logs: the main branch run's Cleanup step (run 28087413541, June 24 09:40–09:46) deleted the previous org. Then split/ci-workflows PR #1268's Deploy step (run 28091226510, 10:15:58) recreated it via find_or_create_org(). Any subsequent PR cleanup would delete it again.

Fix

Guard org deletion with a name check: only delete the org when AUTOSCALER_ORG == DEPLOYMENT_NAME (meaning the org was purpose-built for this deployment). When using a shared org, the names differ (SAP_autoscaler_tests_OSS vs autoscaler-mta-{PR}) and cleanup skips the deletion.

Verification

Scenario DEPLOYMENT_NAME AUTOSCALER_ORG Match? Result
main push autoscaler-mta-main autoscaler-mta-main Deletes (correct)
PR with shared org autoscaler-mta-1149 SAP_autoscaler_tests_OSS Skips (correct)
PR without shared org (old) autoscaler-mta-1266 autoscaler-mta-1266 Deletes (correct)

Multiple PRs deploy into SAP_autoscaler_tests_OSS. Previously, any
PR's cleanup step would unconditionally delete the org if it existed,
destroying all other running PR deployments.

Guard org deletion with a name check: only delete the org when
AUTOSCALER_ORG == DEPLOYMENT_NAME (meaning the org was purpose-built
for this deployment). When using a shared org, the names differ and
cleanup skips the deletion.

@asalan316 asalan316 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving but there are some sonar qube finding

@bonzofenix
bonzofenix enabled auto-merge (squash) June 25, 2026 18:12
@bonzofenix
bonzofenix disabled auto-merge June 25, 2026 18:18
@bonzofenix
bonzofenix merged commit bb59ccf into main Jun 25, 2026
9 checks passed
@bonzofenix
bonzofenix deleted the worktree-protect-shared-org branch June 25, 2026 18:18
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants