Skip to content

Commit

Permalink
fix: update err variable in defer to prevent err shadowing
Browse files Browse the repository at this point in the history
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
  • Loading branch information
aramase committed Feb 17, 2022
1 parent c452ac4 commit 830d184
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/secrets-store/nodeserver.go
Expand Up @@ -79,8 +79,8 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
// again for mount, entire node publish volume is retried
if targetPath != "" && mounted {
klog.InfoS("unmounting target path as node publish volume failed", "targetPath", targetPath, "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
if err = ns.mounter.Unmount(targetPath); err != nil {
klog.ErrorS(err, "failed to unmounting target path")
if unmountErr := ns.mounter.Unmount(targetPath); unmountErr != nil {
klog.ErrorS(unmountErr, "failed to unmounting target path")
}
}
ns.reporter.ReportNodePublishErrorCtMetric(providerName, errorReason)
Expand Down Expand Up @@ -232,6 +232,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
mounted = true
var objectVersions map[string]string
if objectVersions, errorReason, err = ns.mountSecretsStoreObjectContent(ctx, providerName, string(parametersStr), string(secretStr), targetPath, string(permissionStr), podName); err != nil {
klog.ErrorS(err, "failed to mount secrets store object content", "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
return nil, fmt.Errorf("failed to mount secrets store objects for pod %s/%s, err: %w", podNamespace, podName, err)
}

Expand Down

0 comments on commit 830d184

Please sign in to comment.