feat: retry with exponential backoff when Octopus Deploy is unavailable#186
Merged
Conversation
…ilable When the Octopus Deploy server is unavailable (connection refused, 502/503/504, DNS failure, timeouts), the TeamCity plugin now retries CLI execution with exponential backoff instead of failing the build immediately. - OctopusErrorClassifier: distinguishes transient errors (retry) from permanent errors (fail fast) by parsing CLI stdout/stderr patterns for both .NET and Go CLIs - OctopusCliRetryExecutor: retry loop with exponential backoff (5s initial, 2m max per attempt, 15m total timeout), configurable via env vars (OCTOPUS_RETRY_ENABLED, OCTOPUS_RETRY_TIMEOUT, OCTOPUS_RETRY_INITIAL_DELAY, OCTOPUS_RETRY_MAX_DELAY) - CaptureWriter: Output.Writer decorator for capturing CLI output for error classification in the legacy build process path - Both legacy (OctopusBuildProcess) and new CLI (CLIBuildProcess) paths use the shared retry executor Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The extractTarGzResource() Zip Slip security check compared destDir.resolve(entry).normalize() against destDir.toRealPath(). On macOS, /var is a symlink to /private/var, so toRealPath() resolved to /private/var/folders/... while the entry path kept /var/folders/..., causing startsWith() to fail and throw a false-positive Zip Slip error. Fix: resolve destDir to its real path once upfront, then use the resolved path consistently for both entry resolution and the security check. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds Javadoc and inline comments to the retry infrastructure classes (OctopusCliRetryExecutor, OctopusErrorClassifier, CaptureWriter) and both build process integration points (OctopusBuildProcess, CLIBuildProcess) to help engineers unfamiliar with the codebase understand the retry flow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
matt-richardson
added a commit
that referenced
this pull request
May 19, 2026
The retry executor added in #186 was not retrying when Octopus Cloud was in its maintenance window: octo.dll v9.1.7 surfaces the maintenance HTML page wrapped in OctopusServerException, with an outer message of "Unable to connect to the Octopus Deploy server" (not "remote server"), and the underlying HTTP 503 is never plain-text in the CLI output. OctopusErrorClassifier saw none of its TRANSIENT_PATTERNS match and fell through to PERMANENT, so retry was skipped and the build failed on the first attempt. - broaden the connect pattern to "Unable to connect to .*server" so it matches octo.dll's own wrapper wording as well as the System.Net one - add a "undergoing maintenance" pattern that catches the maintenance HTML body (title and copy both contain this phrase) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
EmbeddedResourceExtractorDesign
Output.Writerdecorator for capturing CLI output for error classification in the legacy build process pathOctopusBuildProcess) and new CLI (CLIBuildProcess) paths use the shared retry executorOCTOPUS_RETRY_ENABLED(default:true)OCTOPUS_RETRY_TIMEOUT(default:900000/ 15 min)OCTOPUS_RETRY_INITIAL_DELAY(default:5000/ 5s)OCTOPUS_RETRY_MAX_DELAY(default:120000/ 2 min)Local Testing Results
Tested locally with Docker (TeamCity 2023.11.3 + agent) against an unreachable IP (
10.255.255.1:8065) to simulate Octopus Deploy being unavailable.Legacy .NET CLI (
OCTOPUS_NEW_CLInot set, 5min timeout)The .NET CLI (
octo.dllv9.1.7) fails immediately on each connection attempt (~76s TCP timeout), then our plugin retry executor relaunches the CLI process with exponential backoff.Total duration: ~6m38s (with 5min timeout override). Error classifier correctly identified
Connection refusedas transient. Build log showed retry warning messages between attempts.Go CLI (
OCTOPUS_NEW_CLI=true, default 15min timeout)The Go CLI (
octopusbinary) has its own built-in exponential backoff retry within thelogincommand. A single CLI process invocation retried login 10 times internally before exiting.Total duration: ~15m39s. The Go CLI consumed the full 15-minute retry window in a single process invocation. After exit, the plugin retry executor classified
i/o timeoutas transient but the timeout had elapsed, so the build failed.Key observations
connection refusedvs slowi/o timeout)Test plan
./gradlew test— 84 tests, all green)