Repository navigation
fix: don't abort suspending a tenant's remaining instances when one is already suspended - #158
Merged
Merged
Conversation
…s already suspended Wrap suspendInstanceForTenant in its own try/catch inside the remove-exceeding-tenant-instances loop so a single failure (e.g. a 409 Instance is already suspended from a prior run) no longer aborts processing of the remaining instances for that tenant. Only the outer per-tenant catch (for getInstancesToRemove failures) is preserved. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Member
Author
PR Research ReviewVerified
Adjacent Stubs Detected
Orphaned Files Detected
Escape Hatch Coverage
Impact Analysis
CI Status
Risks Not Tested
Reviewed by PR Research Validator. This review checks whether code is based on verified sources rather than assumptions. |
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
In
packages/cli/src/admin/cmd.ts, theremove-exceeding-tenant-instancescommand handler loops overinstancesToRemoveand callssuspendInstanceForTenantfor each, but only the outer per-tenanttry/catch(which also wrapsgetInstancesToRemove) existed. IfsuspendInstanceForTenantthrows for one instance — e.g. a legitimate409 Instance is already suspendedfrom a prior run — the exception propagates out of theforloop and aborts processing of every remaining instance for that tenant.Confirmed live impact: tenant
maxlaxhas 17 active services, but the daily job only ever attempts the first (go-gitea-gitea), gets a 409, and the other 16 (including the actual token-drainingencoreinstance) are never even attempted — every single day.Context: https://github.com/Eyevinn/osaas-app/issues/5661
This PR does NOT close that issue and does NOT fix maxlax's current suspended state — it only prevents this class of failure from recurring going forward. A separate remediation is needed to actually suspend maxlax's remaining instances.
Fix
Moved
await suspendInstanceForTenant(...)inside its owntry/catchwithin theforloop. On failure it now logsFailed to suspend ${serviceId}: ${instance} for tenant ${tenantId}: <message>andcontinues to the next instance, instead of throwing out of the loop. The outer per-tenant catch (still needed forgetInstancesToRemovefailures) is unchanged.Testing
Ran
npx tsc --noEmitandnpx eslint src/admin/cmd.ts/npx prettier --check src/admin/cmd.tson the changed file — all pass. No existing test file coversremove-exceeding-tenant-instancesoradmin/cmd.ts(onlysrc/web/cmd.test.tsexists for a different command), so no new test scaffolding was built for this fix per scope guidance.Lessons
The bug was a granularity mismatch: a per-tenant try/catch was assumed to be sufficient error isolation, but any operation that loops over sub-resources (instances) inside a per-tenant block needs its own per-item try/catch, or one failed sub-resource silently starves all the others in the same iteration.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com