feat(zebra): gate resilient git checkout behind git_clone_slow_retry feature flag#1046
Merged
Conversation
…feature Injects SEMAPHORE_GIT_CLONE_SLOW_RETRY=true into the job environment when the :git_clone_slow_retry feature is enabled for the organization. This is the producer side of the toolbox checkout-resiliency work (semaphoreci/toolbox#538, semaphoreci/toolbox#539): the toolbox `checkout` reads this env var to opt into slow-clone detection and resilient retry, and is a no-op when the var is absent. Mirrors the existing TestResults / :test_results_no_trim pattern: a small feature-gated module appended to the job env var list in JobRequestFactory, rather than threading org_id through Repository.* (which would churn the exact-match repository tests). Only the on/off switch is injected; the toolbox keeps sensible defaults for the tuning knobs. The feature still needs registering in the feature management backend before it can be toggled per-org in production. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dexyk
reviewed
May 29, 2026
…etry feature_provider_invalidator_worker_test asserts the length of the full StubbedProvider feature list; adding :git_clone_slow_retry took it from 8 to 9. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Per review: the resilient checkout (GeoDNS alternative-endpoint fallback, DoH lookups) targets GitHub.com reachability from Semaphore's cloud egress. On self-hosted agents the network is the customer's own and the DoH endpoint may be blocked, so gate the injection on cloud agents (not Job.self_hosted?/1) in addition to the feature flag. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dexyk
approved these changes
May 29, 2026
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.
What
Adds a per-organization feature flag,
git_clone_slow_retry, that — when enabled — injectsSEMAPHORE_GIT_CLONE_SLOW_RETRY=trueinto the job environment built byJobRequestFactory.This is the producer side of the toolbox checkout-resiliency work (semaphoreci/toolbox#538 + follow-up semaphoreci/toolbox#539). The toolbox
checkoutreadsSEMAPHORE_GIT_CLONE_SLOW_RETRYto opt into slow-clone detection + resilient retry (speed monitoring, retries, alternative-endpoint fallback), and is a no-op when the var is absent. So the rollout is: flip the flag for an org → zebra injects the var → toolbox enables the behavior. Default off = unchanged behavior.How
Mirrors the existing
TestResults/:test_results_no_trimpattern exactly:Zebra.Workers.JobRequestFactory.GitCheckoutmodule withenv_vars/1, gated onFeatureProvider.feature_enabled?(:git_clone_slow_retry, param: org_id).JobRequestFactoryalongsideTestResults.env_vars(org_id).StubbedProvider(hidden by default, enabled for a dedicated test org id).Deliberately not threading
org_idthroughRepository.*— that would churn the exact-match repository tests for no benefit. Only the on/off switch is injected; the toolbox owns the tuning defaults (threshold / timeout / grace / retries).Tests
zebra/test/zebra/workers/job_request_factory/git_checkout_test.exs— feature disabled →[]; enabled →SEMAPHORE_GIT_CLONE_SLOW_RETRY=true.Follow-up (not in this PR)
The
git_clone_slow_retryfeature must be registered in the feature management backend before it can be toggled per-org in production.🤖 Generated with Claude Code