-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* load balance support * update load balance tracing * upgrade golangci version * update * skip cache for golangci lint * update * update * update envtest version * update envtest tool version * add cancel context * resolve comments * fix lint error * no need to update isFailoverRequest when succeed to get settings
- Loading branch information
1 parent
af334bc
commit 807bf33
Showing
9 changed files
with
165 additions
and
85 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,81 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package loader | ||
|
||
import ( | ||
acpv1 "azappconfig/provider/api/v1" | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"os" | ||
"strings" | ||
) | ||
|
||
type TracingKey string | ||
|
||
type RequestTracing struct { | ||
IsStartUp bool | ||
} | ||
|
||
const ( | ||
RequestTracingKey TracingKey = TracingKey("tracing") | ||
AzureExtensionContext string = "AZURE_EXTENSION_CONTEXT" | ||
) | ||
|
||
func createCorrelationContextHeader(ctx context.Context, provider acpv1.AzureAppConfigurationProvider, clientManager ClientManager) http.Header { | ||
header := http.Header{} | ||
output := make([]string, 0) | ||
|
||
output = append(output, "Host=Kubernetes") | ||
|
||
if tracing := ctx.Value(RequestTracingKey); tracing != nil { | ||
if tracing.(RequestTracing).IsStartUp { | ||
output = append(output, "RequestType=StartUp") | ||
} else { | ||
output = append(output, "RequestType=Watch") | ||
} | ||
} | ||
|
||
if provider.Spec.Secret != nil { | ||
output = append(output, "UsesKeyVault") | ||
|
||
if provider.Spec.Secret.Refresh != nil && | ||
provider.Spec.Secret.Refresh.Enabled { | ||
output = append(output, "RefreshesKeyVault") | ||
} | ||
} | ||
|
||
if provider.Spec.FeatureFlag != nil { | ||
output = append(output, "UsesFeatureFlag") | ||
} | ||
|
||
if provider.Spec.ReplicaDiscoveryEnabled { | ||
if manager, ok := clientManager.(*ConfigurationClientManager); ok { | ||
replicaCount := 0 | ||
if manager.DynamicClientWrappers != nil { | ||
replicaCount = len(manager.DynamicClientWrappers) | ||
} | ||
|
||
output = append(output, fmt.Sprintf("ReplicaCount=%d", replicaCount)) | ||
} | ||
} | ||
|
||
if _, ok := os.LookupEnv(AzureExtensionContext); ok { | ||
output = append(output, "InstalledBy=Extension") | ||
} else { | ||
output = append(output, "InstalledBy=Helm") | ||
} | ||
|
||
header.Add("Correlation-Context", strings.Join(output, ",")) | ||
|
||
return header | ||
} | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package loader | ||
|
||
import ( | ||
acpv1 "azappconfig/provider/api/v1" | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"os" | ||
"strings" | ||
) | ||
|
||
type TracingKey string | ||
|
||
type RequestTracing struct { | ||
IsStartUp bool | ||
} | ||
|
||
const ( | ||
RequestTracingKey TracingKey = TracingKey("tracing") | ||
AzureExtensionContext string = "AZURE_EXTENSION_CONTEXT" | ||
) | ||
|
||
func createCorrelationContextHeader(ctx context.Context, provider acpv1.AzureAppConfigurationProvider, clientManager ClientManager, isFailoverRequest bool) http.Header { | ||
header := http.Header{} | ||
output := make([]string, 0) | ||
|
||
output = append(output, "Host=Kubernetes") | ||
|
||
if tracing := ctx.Value(RequestTracingKey); tracing != nil { | ||
if tracing.(RequestTracing).IsStartUp { | ||
output = append(output, "RequestType=StartUp") | ||
} else { | ||
output = append(output, "RequestType=Watch") | ||
} | ||
} | ||
|
||
if provider.Spec.Secret != nil { | ||
output = append(output, "UsesKeyVault") | ||
|
||
if provider.Spec.Secret.Refresh != nil && | ||
provider.Spec.Secret.Refresh.Enabled { | ||
output = append(output, "RefreshesKeyVault") | ||
} | ||
} | ||
|
||
if provider.Spec.FeatureFlag != nil { | ||
output = append(output, "UsesFeatureFlag") | ||
} | ||
|
||
if provider.Spec.ReplicaDiscoveryEnabled { | ||
if manager, ok := clientManager.(*ConfigurationClientManager); ok { | ||
replicaCount := 0 | ||
if manager.DynamicClientWrappers != nil { | ||
replicaCount = len(manager.DynamicClientWrappers) | ||
} | ||
|
||
output = append(output, fmt.Sprintf("ReplicaCount=%d", replicaCount)) | ||
} | ||
|
||
if isFailoverRequest { | ||
output = append(output, "FailoverRequest") | ||
} | ||
} | ||
|
||
if provider.Spec.LoadBalancingEnabled { | ||
output = append(output, "Features=LB") | ||
} | ||
|
||
if _, ok := os.LookupEnv(AzureExtensionContext); ok { | ||
output = append(output, "InstalledBy=Extension") | ||
} else { | ||
output = append(output, "InstalledBy=Helm") | ||
} | ||
|
||
header.Add("Correlation-Context", strings.Join(output, ",")) | ||
|
||
return header | ||
} |