Skip to content

fix(servicebus): bound TCP connect by the readiness deadline - #604

Merged
hectorvent merged 3 commits into
floci-io:mainfrom
thomhurst:fix/servicebus-connect-deadline
Oct 31, 2026
Merged

hectorvent merged 3 commits into
floci-io:mainfrom
thomhurst:fix/servicebus-connect-deadline

Conversation

@thomhurst

@thomhurst thomhurst commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Service Bus namespace startup can remain blocked in TCP connect after a short-lived sidecar exits. The kernel's retransmission deadline outlives the existing 60-second readiness budget, keeping startup diagnostics and cleanup unreachable.

Cap each connect at one second and the remaining readiness budget. Cap the retry delay by that same budget and measure it with System.nanoTime(). Keep the existing 60-second production deadline, failure message and interrupted-wait behavior. Resolve a null host through InetAddress.getByName so the existing loopback behavior survives when Docker inspection happens after the sidecar loses its IP.

Closes #603

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: or fix!:)
  • Docs / chore

Azure Compatibility

A terminated managed broker must reach the existing readiness failure so its diagnostics and cleanup can run. This changes local sidecar readiness, with no Azure wire contract change.

Checklist

  • ./mvnw test passes locally (the recorded ./mvnw.cmd package runs the full test suite; conditional skips listed below)
  • New or updated integration test added (new automated unit regressions cover explicit-IP and null-host endpoints; the real sidecar reproduction is documented in Service Bus TCP connect can exceed its readiness deadline after sidecar exit #603)
  • Commit messages follow Conventional Commits
  • I have no more than 2 open, non-draft pull requests and no more than 4 open pull requests in total (drafts included) in this repository.

Validation:

  • Failing-first regression: before bounded connect, the unresponsive-endpoint test fails because readiness incorrectly returns through the mocked unbounded constructor. After the correction, both explicit-IP and null-host cases reach the readiness failure. The controlled real-sidecar reproduction in Service Bus TCP connect can exceed its readiness deadline after sidecar exit #603 separately establishes the blocked TCP mechanism.
  • ./mvnw.cmd package: 3,214 tests reported, zero failures/errors, 30 conditional skips; build succeeds. The Docker-gated registry, k3s, PostgreSQL and VM tests and existing certificate cases retain their environment-dependent skips. This does not claim those skipped integrations ran.
  • Full diff reviewed; git diff --check passes.

The commit was re-signed after the hygiene check identified an unsigned commit. The signed commit has the identical source tree as f1ffc46, so the existing test evidence remains applicable; tests were not rerun for the signature-only rewrite.

Review regression coverage

Head 54d867ab72749bd40e602bf5388128cb41af6a48 strengthens the readiness tests without changing runtime code. It asserts the one-second connect cap, checks elapsed deadlines with 300 ms of scheduling slack, covers a two-second overall deadline, and exercises the remaining retry-sleep budget after an immediate connection failure. A deliberate 60,000 ms connect/fixed 500 ms sleep mutation fails before restoration; the final four readiness cases pass.

Fresh ./mvnw.cmd package: 3,216 tests reported, zero failures/errors, 30 existing conditional skips, build succeeds in 17m03s on Windows. Skipped Docker-gated and certificate cases remain unclaimed. Full logs were swept; all error mechanisms match the existing explicit failure controls. Full diff self-reviewed, simplified, and git diff --check passes. Both commits are signed. Hosted validation for the new head remains pending.

Retry mock correction

Commit 65a60f0 bounds the retry mock delay by the connect timeout supplied by production. At the end of the readiness budget, another connect can begin with only 1 ms available; the previous unconditional 400 ms delay modeled a socket that ignored its timeout and could falsely fail the elapsed-time assertion. Runtime code, timeout assertions, retry requirement, and the 300 ms scheduling allowance are unchanged.

The existing four readiness cases passed before this correction. A deterministic failing-first reproduction of the scheduling-dependent mock defect was not established, so no such reproduction is claimed. With the corrected mock, deliberately restoring the fixed 500 ms production retry delay fails the existing 1,300 ms assertion by 150 ms. The production mutation was restored before final validation.

The first full package attempt reported four readiness failures because restoring the mutation backup preserved an older source timestamp. Maven reused the mutated class; javap confirmed a fixed 500 ms sleep in bytecode while source was restored. That failed output is retained. Final validation uses clean package to compile restored production code from scratch.

./mvnw.cmd clean package succeeds in 9m13s: 3,216 tests reported, zero failures/errors, 30 existing conditional skips. All four readiness cases run and pass. Docker-gated and certificate skips are not claimed as executed. The final log sweep finds 45 error lines across 29 existing failure-control mechanisms, with no new error mechanism or browser error. Full diff self-reviewed, code-simplifier applied, and git diff --check passes.

@thomhurst
thomhurst force-pushed the fix/servicebus-connect-deadline branch from f1ffc46 to 09cbf43 Compare October 31, 2026 03:14
@thomhurst
thomhurst marked this pull request as ready for review October 31, 2026 12:40
@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the previous test failure addressed and no new actionable issues found.

Summary

Bounds Service Bus readiness connects by one second and the remaining deadline.

  • Service Bus startup reaches its readiness result when a sidecar stops replying.

Reviews (3) · Last reviewed commit: "test(servicebus): respect timeout in rea..." · Reviewed by Greptile

@hectorvent

Copy link
Copy Markdown
Member

Thanks, this is a careful fix, and the elapsed-time assertions make the deadline concrete rather than implied. Capping each connect by one second and the remaining budget keeps the 60 second contract and lets the diagnostics and cleanup actually run.

  1. (follow-up, separate PR) EventHubNamespaceManager.waitForPort (src/main/java/io/floci/az/services/eventhub/EventHubNamespaceManager.java:300) still has the unbounded new Socket(host, port) loop against the same Artemis image, so Event Hubs can hang the same way after its sidecar exits. Moving the new bounded waitForPort somewhere both managers can call would close it there too.

No blockers from my side.

@hectorvent
hectorvent merged commit b06f481 into floci-io:main Oct 31, 2026
16 checks passed
@hectorvent

Copy link
Copy Markdown
Member

🎉 This PR is included in version 0.17.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

McFizh pushed a commit to McFizh/floci-az that referenced this pull request Nov 16, 2026
# [0.17.0](floci-io/floci-az@0.16.0...0.17.0) (2026-11-15)

### Bug Fixes

* **aci:** report a failed container group action on the POST ([floci-io#623](floci-io#623)) ([b9ab61c](floci-io@b9ab61c))
* **apim:** keep child resources in the storage layer, keyed case-insensitively ([floci-io#651](floci-io#651)) ([d70496f](floci-io@d70496f))
* **blob:** answer Append Block with Last-Modified and x-ms-request-server-encrypted ([floci-io#631](floci-io#631)) ([f440fce](floci-io@f440fce)), closes [floci-io#587](floci-io#587)
* **blob:** apply SAS response-header overrides on read ([floci-io#629](floci-io#629)) ([04ec99e](floci-io@04ec99e))
* **containerapps:** drop an empty keyVaultUrl from a plain secret ([floci-io#649](floci-io#649)) ([68a9e13](floci-io@68a9e13)), closes [floci-io#576](floci-io#576)
* **containerapps:** report a managed environment's customDomainVerificationId ([floci-io#630](floci-io#630)) ([6b2b76f](floci-io@6b2b76f)), closes [floci-io#573](floci-io#573)
* **deployments:** list a nested deployment's resources in its parent ([floci-io#636](floci-io#636)) ([87c08bd](floci-io@87c08bd))
* **deployments:** read a parameter with a null reference as a plain value ([floci-io#635](floci-io#635)) ([e29d909](floci-io@e29d909))
* **eventgrid:** refuse a destination type floci-az cannot deliver to ([floci-io#622](floci-io#622)) ([aec34bd](floci-io@aec34bd))
* **eventhub:** skip discarded journal disk tuning ([floci-io#614](floci-io#614)) ([284f3fc](floci-io@284f3fc)), closes [floci-io#606](floci-io#606)
* **keyvault:** serve deleted vaults so terraform destroy can purge ([floci-io#634](floci-io#634)) ([f90d590](floci-io@f90d590)), closes [floci-io#624](floci-io#624)
* **keyvault:** store a vault's properties and support PATCH ([floci-io#624](floci-io#624)) ([9b8b44f](floci-io@9b8b44f))
* **monitor:** answer the deleted workspaces list ([floci-io#625](floci-io#625)) ([b60d698](floci-io@b60d698))
* **monitor:** keep the tags of workspaces and data collection endpoints and rules ([floci-io#660](floci-io#660)) ([df23147](floci-io@df23147)), closes [floci-io#659](floci-io#659)
* **queue:** accept Update Message without a body (visibility-only update) ([floci-io#621](floci-io#621)) ([c3215c8](floci-io@c3215c8)), closes [floci-io#620](floci-io#620)
* **queue:** return messages in the order they were sent ([floci-io#647](floci-io#647)) ([37b0f46](floci-io@37b0f46))
* **servicebus,eventhub:** wait for Artemis to answer AMQP before reporting a namespace ready ([floci-io#615](floci-io#615)) ([6fa9511](floci-io@6fa9511))
* **servicebus:** balance source accounting after explicit dead-letter ([floci-io#648](floci-io#648)) ([16f5f74](floci-io@16f5f74))
* **servicebus:** bound TCP connect by the readiness deadline ([floci-io#604](floci-io#604)) ([b06f481](floci-io@b06f481)), closes [floci-io#603](floci-io#603)
* **servicebus:** count deliveries after session lock expiry ([floci-io#645](floci-io#645)) ([ff31e3d](floci-io@ff31e3d))
* **servicebus:** restore stored entities when a broker starts ([floci-io#643](floci-io#643)) ([0d8dbab](floci-io@0d8dbab)), closes [floci-io#642](floci-io#642)
* **servicebus:** skip discarded journal disk tuning ([floci-io#606](floci-io#606)) ([db31031](floci-io@db31031)), closes [floci-io#605](floci-io#605)
* **storage:** answer an ARM container GET with the container's stored ETag and Last-Modified ([floci-io#617](floci-io#617)) ([f58abb4](floci-io@f58abb4))
* **storage:** answer an ARM container PUT with the container's stored ETag and Last-Modified ([floci-io#602](floci-io#602)) ([c5bbac8](floci-io@c5bbac8))
* **storage:** return the sku, kind and properties a PUT set ([floci-io#646](floci-io#646)) ([afc79e6](floci-io@afc79e6)), closes [floci-io#571](floci-io#571)
* **vm:** preserve request origin in polling URLs ([floci-io#628](floci-io#628)) ([9560864](floci-io@9560864)), closes [floci-io#626](floci-io#626)
* **vm:** report each power action's real outcome on its operation status ([floci-io#655](floci-io#655)) ([183f63d](floci-io@183f63d)), closes [floci-io#626](floci-io#626) [floci-io#626](floci-io#626)

### Features

* **arm:** refuse a token from another tenant under strict-tokens ([floci-io#619](floci-io#619)) ([fb76ca4](floci-io@fb76ca4))
* **arm:** refuse invalid Bearer tokens under strict-tokens ([floci-io#616](floci-io#616)) ([d6af59c](floci-io@d6af59c))
* **arm:** report each public region's physicalLocation ([floci-io#653](floci-io#653)) ([874b552](floci-io@874b552))
* **authorization:** serve role definitions and store role assignments ([floci-io#656](floci-io#656)) ([003a53c](floci-io@003a53c)), closes [floci-io#567](floci-io#567)
* **blob:** serve Set Blob Properties ([floci-io#654](floci-io#654)) ([d09366d](floci-io@d09366d))
* **deployments:** resolve Key Vault parameter references ([floci-io#641](floci-io#641)) ([3bcb475](floci-io@3bcb475)), closes [floci-io#635](floci-io#635) [floci-io#635](floci-io#635)
* **deployments:** serve deployments at management-group scope ([floci-io#640](floci-io#640)) ([0fe757d](floci-io@0fe757d))
* **deployments:** serve symbolic resource names (languageVersion 2.0) ([floci-io#637](floci-io#637)) ([17f00a3](floci-io@17f00a3))
* **deployments:** serve the CIDR functions and deployer ([floci-io#639](floci-io#639)) ([7fd4ade](floci-io@7fd4ade))
* **deployments:** serve the lambda functions and flatten ([floci-io#638](floci-io#638)) ([cddc4e0](floci-io@cddc4e0))
* **entra:** validate directory passwords and issue ROPC refresh tokens ([floci-io#633](floci-io#633)) ([9b2a464](floci-io@9b2a464)), closes [floci-io#632](floci-io#632)
* **tls:** answer for Azure's public hosts behind an opt-in setting ([floci-io#650](floci-io#650)) ([457de34](floci-io@457de34))
* **tls:** keep a trusted CA, accept your own, and warn when a client rejects the certificate ([floci-io#662](floci-io#662)) ([bac63e9](floci-io@bac63e9))
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.

Service Bus TCP connect can exceed its readiness deadline after sidecar exit

2 participants