diff --git a/internal/loader/configuration_client_manager.go b/internal/loader/configuration_client_manager.go index e86ee99..08bba42 100644 --- a/internal/loader/configuration_client_manager.go +++ b/internal/loader/configuration_client_manager.go @@ -38,7 +38,6 @@ import ( type ConfigurationClientManager struct { ReplicaDiscoveryEnabled bool LoadBalancingEnabled bool - IsFailoverRequest bool StaticClientWrappers []*ConfigurationClientWrapper DynamicClientWrappers []*ConfigurationClientWrapper validDomain string diff --git a/internal/loader/configuration_setting_loader.go b/internal/loader/configuration_setting_loader.go index 2134d1c..3fe2c40 100644 --- a/internal/loader/configuration_setting_loader.go +++ b/internal/loader/configuration_setting_loader.go @@ -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 @@ -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 + if manager, ok := csl.ClientManager.(*ConfigurationClientManager); ok { manager.lastSuccessfulEndpoint = clientWrapper.Endpoint } updateClientBackoffStatus(clientWrapper, successful) diff --git a/internal/loader/request_tracing.go b/internal/loader/request_tracing.go index 385cc43..f4196b6 100644 --- a/internal/loader/request_tracing.go +++ b/internal/loader/request_tracing.go @@ -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) @@ -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") } }