Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvz committed Dec 27, 2023
1 parent 354f4d7 commit 09e5b67
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/azurefile/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
context := req.GetVolumeContext()
if context != nil {
// token request
if context[serviceAccountTokenField] != "" && context[clientIDField] != "" {
if context[serviceAccountTokenField] != "" && !isClientIDEmpty(context) {
klog.V(2).Infof("NodePublishVolume: volume(%s) mount on %s with service account token, VolumeContext: %v", volumeID, target, context)
_, err := d.NodeStageVolume(ctx, &csi.NodeStageVolumeRequest{
StagingTargetPath: target,
Expand Down Expand Up @@ -169,8 +169,8 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
volumeID := req.GetVolumeId()
context := req.GetVolumeContext()

if context[serviceAccountTokenField] == "" && context[clientIDField] != "" {
klog.V(2).Infof("Skip NodeStageVolume for volume(%s) since clientID(%s) is provided", volumeID, context[clientIDField])
if !isClientIDEmpty(context) && context[serviceAccountTokenField] == "" {
klog.V(2).Infof("Skip NodeStageVolume for volume(%s) since clientID is provided but service account token is empty", volumeID)
return &csi.NodeStageVolumeResponse{}, nil
}

Expand Down Expand Up @@ -612,3 +612,10 @@ func checkGidPresentInMountFlags(mountFlags []string) bool {
}
return false
}

func isClientIDEmpty(context map[string]string) bool {
if context[clientIDField] != "" || context[strings.ToLower(clientIDField)] != "" {
return false
}
return true
}

0 comments on commit 09e5b67

Please sign in to comment.