Skip to content

Conversation

@linglingye001
Copy link
Member

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements startup retry functionality for the Azure App Configuration Go provider, adding resilience during initial configuration loading. The implementation includes exponential backoff with timeout support and comprehensive error handling.

  • Adds StartupOptions configuration with timeout support for initial data loading
  • Implements retry logic with exponential backoff for startup operations
  • Refactors backoff calculation to be reusable across different retry scenarios

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
azureappconfiguration/options.go Adds StartupOptions struct with timeout configuration
azureappconfiguration/constants.go Defines default startup timeout constant (100 seconds)
azureappconfiguration/azureappconfiguration.go Implements startupWithRetry method with timeout and backoff logic
azureappconfiguration/client_manager.go Refactors backoff calculation and adds fixed backoff duration logic
azureappconfiguration/failover_test.go Adds comprehensive test coverage for startup retry scenarios

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +160 to +170
// StartupOptions is used when initially loading data into the configuration provider.
type StartupOptions struct {
// Timeout specifies the amount of time allowed to load data from Azure App Configuration on startup.
Timeout time.Duration
}
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The StartupOptions struct needs an import statement for the time package to be valid.

Copilot uses AI. Check for mistakes.
Comment on lines +714 to +720
timeElapsed := time.Since(startTime)
backoffDuration := getFixedBackoffDuration(timeElapsed)
if backoffDuration == 0 {
backoffDuration = calculateBackoffDuration(attempt)
}
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for choosing between fixed and calculated backoff duration is unclear. Consider adding a comment explaining when and why fixed backoff is preferred over exponential backoff.

Copilot uses AI. Check for mistakes.
Comment on lines 720 to 726
// Check if we have enough time left to wait and retry
timeRemaining := timeout - timeElapsed
if timeRemaining <= backoffDuration {
return fmt.Errorf("startup failed after %d attempts within timeout %v: %w", attempt, timeout, err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing something, since we have the line 730, does it mean we don't need to have this logic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check at line 722 prevents unnecessary waiting when we know there isn't enough time left for a meaningful retry attempt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, then let's keep it to avoid unnecessary waiting. But essentially, the error returns in line718 and 724 are the same error, are they? How about unifying the error information? Becuase I think the error message in line 724 is not so friendly to the end user, the startup context is a concept created by us in the code, I think we just need to say load key-values from app config timeout, how do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds reasonable, updated

@linglingye001 linglingye001 force-pushed the linglingye/startup/retry branch from 5d6ee48 to 025fff8 Compare September 23, 2025 07:38
@linglingye001 linglingye001 merged commit 41b6064 into release/v1.3.0 Sep 23, 2025
12 checks passed
@linglingye001 linglingye001 deleted the linglingye/startup/retry branch September 23, 2025 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants