Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
linglingye001 committed Aug 23, 2024
1 parent 2e096d8 commit 730b2ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
1 change: 0 additions & 1 deletion internal/loader/configuration_client_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
type ConfigurationClientManager struct {
ReplicaDiscoveryEnabled bool
LoadBalancingEnabled bool
IsFailoverRequest bool
StaticClientWrappers []*ConfigurationClientWrapper
DynamicClientWrappers []*ConfigurationClientWrapper
validDomain string
Expand Down
12 changes: 5 additions & 7 deletions internal/loader/configuration_setting_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,13 @@ func (csl *ConfigurationSettingLoader) ExecuteFailoverPolicy(ctx context.Context
}

errors := make([]error, 0)
var tracingEnabled bool
var tracingEnabled, isFailoverRequest bool
if value, ok := os.LookupEnv(RequestTracingEnabled); ok {
tracingEnabled, _ = strconv.ParseBool(value)
}
for _, clientWrapper := range clients {
if tracingEnabled {
ctx = policy.WithHTTPHeader(ctx, createCorrelationContextHeader(ctx, csl.AzureAppConfigurationProvider, csl.ClientManager))
ctx = policy.WithHTTPHeader(ctx, createCorrelationContextHeader(ctx, csl.AzureAppConfigurationProvider, csl.ClientManager, isFailoverRequest))
}
settingsResponse, err := settingsClient.GetSettings(ctx, clientWrapper.Client)
successful := true
Expand All @@ -535,16 +535,14 @@ func (csl *ConfigurationSettingLoader) ExecuteFailoverPolicy(ctx context.Context
if IsFailoverable(err) {
klog.Warningf("current client of '%s' failed to get settings: %s", clientWrapper.Endpoint, err.Error())
errors = append(errors, err)
if ok {
manager.IsFailoverRequest = true
}
isFailoverRequest = true
continue
}
return nil, err
}

if ok {
manager.IsFailoverRequest = false
isFailoverRequest = false

Check failure on line 544 in internal/loader/configuration_setting_loader.go

View workflow job for this annotation

GitHub Actions / lint

ineffectual assignment to isFailoverRequest (ineffassign)
if manager, ok := csl.ClientManager.(*ConfigurationClientManager); ok {
manager.lastSuccessfulEndpoint = clientWrapper.Endpoint
}
updateClientBackoffStatus(clientWrapper, successful)
Expand Down
8 changes: 4 additions & 4 deletions internal/loader/request_tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
AzureExtensionContext string = "AZURE_EXTENSION_CONTEXT"
)

func createCorrelationContextHeader(ctx context.Context, provider acpv1.AzureAppConfigurationProvider, clientManager ClientManager) http.Header {
func createCorrelationContextHeader(ctx context.Context, provider acpv1.AzureAppConfigurationProvider, clientManager ClientManager, isFailoverRequest bool) http.Header {
header := http.Header{}
output := make([]string, 0)

Expand Down Expand Up @@ -58,10 +58,10 @@ func createCorrelationContextHeader(ctx context.Context, provider acpv1.AzureApp
}

output = append(output, fmt.Sprintf("ReplicaCount=%d", replicaCount))
}

if manager.IsFailoverRequest {
output = append(output, "FailoverRequest")
}
if isFailoverRequest {
output = append(output, "FailoverRequest")
}
}

Expand Down

0 comments on commit 730b2ee

Please sign in to comment.