ROX-30485,ROX-30486,ROX-30470: Use go-retryablehttp in k8s client#16725
Merged
ROX-30485,ROX-30486,ROX-30470: Use go-retryablehttp in k8s client#16725
Conversation
This change adds robust retry logic to createPod and teardownPod functions to handle transient Kubernetes API failures that were causing TestPod failures in gke-nongroovy-compatibility-tests. Changes: - Replace single-attempt operations with 3-attempt retry logic - Use existing pkg/retry package for consistent retry behavior - Add 2-second backoff between retry attempts - Maintain 10-second timeout per individual attempt - Add informative logging for retry attempts The retry logic provides better fault tolerance for: - Transient network connectivity issues - Kubernetes API server temporary unavailability - Resource contention in test environments Total maximum time per operation: ~36 seconds (3×10s + 2×2s backoff) vs previous 10-second single attempt, significantly improving reliability while maintaining reasonable test execution times. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
Images are ready for the commit at 12f681f. To use with deploy scripts, first |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #16725 +/- ##
==========================================
+ Coverage 48.67% 48.80% +0.13%
==========================================
Files 2675 2679 +4
Lines 199760 200331 +571
==========================================
+ Hits 97235 97775 +540
- Misses 94918 94947 +29
- Partials 7607 7609 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
parametalol
reviewed
Sep 9, 2025
parametalol
approved these changes
Sep 9, 2025
Contributor
parametalol
left a comment
There was a problem hiding this comment.
I'm sad to see a need for such a change.
…tions" This reverts commit 31a037f.
…port Replace pod-level retry logic with HTTP client-level retries using hashicorp/go-retryablehttp. This provides better network resilience for GKE API connectivity issues while working within existing 10s context timeouts. Key changes: - Configure retryablehttp with 3 retries, 3s timeout per request - Custom retry policy for network errors and 5xx/429 responses - Use WrapTransport pattern to integrate with k8s client-go - Fast retry timing (0.5s-2s backoff) to fit multiple attempts in 10s Addresses timeout issues with GKE endpoints: - 34.133.244.129, 34.56.5.71 (ROX-30485, ROX-30486, ROX-30470) - GRPC connection resolution failures (ROX-29713, ROX-29356) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Increase HTTP client timeout from 3s to 8s per request based on test results showing GKE endpoint 34.86.46.176 needs more time to respond. This still allows for retry within 10s context window while giving individual requests sufficient time to complete. Timeline: 8s attempt + 0.5s delay + 1.5s retry = fits in 10s context 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Increase context timeout in createPod and teardownPod functions from 10s to 30s to allow more retry attempts with the 8s HTTP timeout. This provides up to 4 retry attempts within the context window: - Attempt 1: 0s → 8s - Attempt 2: 8.5s → 16.5s - Attempt 3: 17.5s → 25.5s - Attempt 4: 27.5s → 30s Better accommodates slow GKE endpoints while maintaining reasonable overall test execution time. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
/retest |
Contributor
|
Caution There are some errors in your PipelineRun template.
|
Merged
parametalol
approved these changes
Sep 11, 2025
janisz
commented
Sep 11, 2025
janisz
commented
Sep 11, 2025
Contributor
Author
|
Added a unit test for retry: |
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.
This PR replaces pod-level retry logic with HTTP client-level retries using
hashicorp/go-retryablehttpto provide better networkresilience for GKE API connectivity issues while working within existing 10-second context timeouts.
Problem
Our CI tests are experiencing frequent network timeout failures, particularly in GKE environments:
context deadline exceedederrors on GKE endpoints (34.133.244.129, 34.56.5.71)Current approach was to add retry logic at the pod creation/deletion level, but this is less efficient than handling retries at the HTTP
transport layer.
Solution
HTTP Client Retry Implementation
WrapTransportpatternKey Configuration
Timeline within 10-second context:
This allows up to 3 retry attempts within the existing 10-second context window.
Implementation Details
Custom Retry Policy
Transport Integration
Uses the established WrapTransport pattern found in:
Benefits
✅ Network Resilience: Automatic retry for transient network issues
✅ Backward Compatibility: Works with existing 10-second context timeouts
✅ Smart Retry Logic: Only retries appropriate errors, not client mistakes
✅ Comprehensive Logging: Debug visibility into retry attempts
✅ Existing Dependency: Uses hashicorp/go-retryablehttp v0.7.8 already in go.mod
✅ Proven Pattern: Follows established WrapTransport usage in codebase
Testing
Related Issues
This implementation directly addresses:
Test Plan