Skip to content

Commit

Permalink
refactor(CSI-250): do not maintain redundant active mounts from node …
Browse files Browse the repository at this point in the history
…server after publishing volume
  • Loading branch information
sergeyberezansky committed Sep 5, 2024
1 parent 6d41434 commit 91b2275
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/wekafs/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,11 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis

err, unmount := volume.MountUnderlyingFS(ctx)
if err != nil {
unmount()
logger.Error().Err(err).Msg("Failed to mount underlying filesystem")
return NodePublishVolumeError(ctx, codes.Internal, "Failed to mount a parent filesystem, check Authentication: "+err.Error())
}
defer unmount() // unmount the parent mount since there is a bind mount anyway

fullPath := volume.GetFullPath(ctx)

targetPathDir := filepath.Dir(targetPath)
Expand Down Expand Up @@ -294,10 +296,8 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis

// if we run in K8s isolated environment, 2nd mount must be done using mapped volume path
if err := mounter.Mount(fullPath, targetPath, "", innerMountOpts); err != nil {
var errList strings.Builder
errList.WriteString(err.Error())
unmount() // unmount only if mount bind failed
return NodePublishVolumeError(ctx, codes.Internal, fmt.Sprintf("failed to Mount device: %s at %s: %s", fullPath, targetPath, errList.String()))
logger.Error().Err(err).Str("full_path", fullPath).Str("target_path", targetPath).Msg("Failed to perform mount")
return NodePublishVolumeError(ctx, codes.Internal, fmt.Sprintf("failed to Mount device: %s at %s: %s", fullPath, targetPath, err.Error()))
}
result = "SUCCESS"
// Not doing unmount, NodePublish should do unmount but only when it unmounts bind successfully
Expand Down

0 comments on commit 91b2275

Please sign in to comment.