Provisioning: Add retry logic for nanogit client operations (#114216)
* chore(deps): update nanogit to v0.3.0 in go.mod and go.sum files
* Add retry logic for nanogit client operations
- Configure retry logic in withGitContext to ensure all Git operations have retry support
- Use nanogit's ExponentialBackoffRetrier with 8 attempts (~10s retry window)
- Retry transient network errors and HTTP-specific server errors (5xx for GET/DELETE, 429 for all)
- Rename logger function to withGitContext to better reflect its responsibilities
* fix: resolve staticcheck S1008 linting issue in retry_client.go
Simplify return statement to use errors.As directly instead of if-return pattern
* Revert "fix: resolve staticcheck S1008 linting issue in retry_client.go"
This reverts commit bd367b5629.
This commit is contained in:
@@ -2163,7 +2163,7 @@ func TestGitRepository_commitAndPush(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGitRepository_logger(t *testing.T) {
|
||||
func TestGitRepository_withGitContext(t *testing.T) {
|
||||
gitRepo := &gitRepository{
|
||||
config: &provisioning.Repository{
|
||||
Spec: provisioning.RepositorySpec{
|
||||
@@ -2179,7 +2179,7 @@ func TestGitRepository_logger(t *testing.T) {
|
||||
|
||||
t.Run("creates new logger context", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
newCtx, logger := gitRepo.logger(ctx, "feature-branch")
|
||||
newCtx, logger := gitRepo.withGitContext(ctx, "feature-branch")
|
||||
|
||||
require.NotNil(t, newCtx)
|
||||
require.NotNil(t, logger)
|
||||
@@ -2188,7 +2188,7 @@ func TestGitRepository_logger(t *testing.T) {
|
||||
|
||||
t.Run("uses default branch when ref is empty", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
newCtx, logger := gitRepo.logger(ctx, "")
|
||||
newCtx, logger := gitRepo.withGitContext(ctx, "")
|
||||
|
||||
require.NotNil(t, newCtx)
|
||||
require.NotNil(t, logger)
|
||||
@@ -2198,10 +2198,10 @@ func TestGitRepository_logger(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
// First call creates the logger context
|
||||
ctx1, logger1 := gitRepo.logger(ctx, "branch1")
|
||||
ctx1, logger1 := gitRepo.withGitContext(ctx, "branch1")
|
||||
|
||||
// Second call should return the existing logger context
|
||||
ctx2, logger2 := gitRepo.logger(ctx1, "branch2")
|
||||
ctx2, logger2 := gitRepo.withGitContext(ctx1, "branch2")
|
||||
|
||||
// When logger context already exists, it should return the same context
|
||||
require.Equal(t, ctx1, ctx2)
|
||||
|
||||
Reference in New Issue
Block a user