Skip to content

Commit

Permalink
update klog.InfoS to klog.V(5).InfoS (#730)
Browse files Browse the repository at this point in the history
update image taregt

change log level to 0

use default level

remove V(0)

Co-authored-by: Anish Ramasekar <[email protected]>
  • Loading branch information
helayoty and aramase authored Dec 9, 2021
1 parent 5003b56 commit 6308750
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ install-helm:
.PHONY: e2e-local-bootstrap
e2e-local-bootstrap: build
kind create cluster --image kindest/node:${KIND_K8S_VERSION} --config test/kind-config.yaml
make image
$(MAKE) container-all push-manifest
kind load docker-image --name kind $(IMAGE_TAG)

.PHONY: e2e-kind-cleanup
Expand Down
10 changes: 5 additions & 5 deletions pkg/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (c Config) GetServicePrincipalToken(podName, podNamespace, resource, aadEnd
// The NMI server identifies the pod based on the `podns` and `podname` in the request header and then queries k8s (through MIC) for a matching azure identity.
// Then nmi makes an adal request to get a token for the resource in the request, returns the `token` and the `clientid` as a response to the CSI request.
if c.UsePodIdentity {
klog.InfoS("using pod identity to retrieve token", "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
klog.V(5).InfoS("using pod identity to retrieve token", "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
// pod name and namespace are required for the Key Vault provider to request a token
// on behalf of the application pod
if len(podName) == 0 || len(podNamespace) == 0 {
Expand Down Expand Up @@ -108,7 +108,7 @@ func (c Config) GetServicePrincipalToken(podName, podNamespace, resource, aadEnd
if err != nil {
return nil, err
}
klog.InfoS("successfully acquired access token", "accessToken", utils.RedactClientID(nmiResp.Token.AccessToken), "clientID", utils.RedactClientID(nmiResp.ClientID), "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
klog.V(5).InfoS("successfully acquired access token", "accessToken", utils.RedactClientID(nmiResp.Token.AccessToken), "clientID", utils.RedactClientID(nmiResp.ClientID), "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})

token, clientID := nmiResp.Token, nmiResp.ClientID
if token.AccessToken == "" || clientID == "" {
Expand All @@ -128,22 +128,22 @@ func (c Config) GetServicePrincipalToken(podName, podNamespace, resource, aadEnd
return nil, errors.Wrap(err, "failed to get managed identity (MSI) endpoint")
}
if c.UserAssignedIdentityID != "" {
klog.InfoS("using user-assigned managed identity to retrieve access token", "clientID", utils.RedactClientID(c.UserAssignedIdentityID), "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
klog.V(5).InfoS("using user-assigned managed identity to retrieve access token", "clientID", utils.RedactClientID(c.UserAssignedIdentityID), "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
return adal.NewServicePrincipalTokenFromMSIWithUserAssignedID(
msiEndpoint,
resource,
c.UserAssignedIdentityID)
}

klog.InfoS("using system-assigned managed identity to retrieve access token", "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
klog.V(5).InfoS("using system-assigned managed identity to retrieve access token", "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
return adal.NewServicePrincipalTokenFromMSI(
msiEndpoint,
resource)
}

// for Service Principal access mode, clientID + client secret are used to retrieve token for resource
if len(c.AADClientSecret) > 0 && len(c.AADClientID) > 0 {
klog.InfoS("using service principal to retrieve access token", "clientID", utils.RedactClientID(c.AADClientID), "secret", utils.RedactClientID(c.AADClientSecret), "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
klog.V(5).InfoS("using service principal to retrieve access token", "clientID", utils.RedactClientID(c.AADClientID), "secret", utils.RedactClientID(c.AADClientSecret), "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
return adal.NewServicePrincipalToken(
*oauthConfig,
c.AADClientID,
Expand Down
8 changes: 4 additions & 4 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (p *Provider) MountSecretsStoreObjectContent(ctx context.Context, attrib ma
keyVaultObjects = append(keyVaultObjects, keyVaultObject)
}

klog.InfoS("unmarshaled key vault objects", "keyVaultObjects", keyVaultObjects, "count", len(keyVaultObjects), "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
klog.V(5).InfoS("unmarshaled key vault objects", "keyVaultObjects", keyVaultObjects, "count", len(keyVaultObjects), "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})

if len(keyVaultObjects) == 0 {
return make(map[string][]byte), make(map[string]string), nil
Expand All @@ -275,7 +275,7 @@ func (p *Provider) MountSecretsStoreObjectContent(ctx context.Context, attrib ma
objectVersionMap := make(map[string]string)
files := make(map[string][]byte)
for _, keyVaultObject := range keyVaultObjects {
klog.InfoS("fetching object from key vault", "objectName", keyVaultObject.ObjectName, "objectType", keyVaultObject.ObjectType, "keyvault", mc.keyvaultName, "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
klog.V(5).InfoS("fetching object from key vault", "objectName", keyVaultObject.ObjectName, "objectType", keyVaultObject.ObjectType, "keyvault", mc.keyvaultName, "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
if err := validateObjectFormat(keyVaultObject.ObjectFormat, keyVaultObject.ObjectType); err != nil {
return nil, nil, wrapObjectTypeError(err, keyVaultObject.ObjectType, keyVaultObject.ObjectName, keyVaultObject.ObjectVersion)
}
Expand Down Expand Up @@ -308,7 +308,7 @@ func (p *Provider) MountSecretsStoreObjectContent(ctx context.Context, attrib ma

// these files will be returned to the CSI driver as part of gRPC response
files[fileName] = objectContent
klog.InfoS("added file to the gRPC response", "file", fileName, "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
klog.V(5).InfoS("added file to the gRPC response", "file", fileName, "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
}

return files, objectVersionMap, nil
Expand Down Expand Up @@ -571,7 +571,7 @@ func setAzureEnvironmentFilePath(envFileName string) error {
if envFileName == "" {
return nil
}
klog.InfoS("setting AZURE_ENVIRONMENT_FILEPATH for custom cloud", "fileName", envFileName)
klog.V(5).InfoS("setting AZURE_ENVIRONMENT_FILEPATH for custom cloud", "fileName", envFileName)
return os.Setenv(azure.EnvironmentFilepathName, envFileName)
}

Expand Down

0 comments on commit 6308750

Please sign in to comment.