Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions pkg/azurefile/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,13 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
}

if d.enableKataCCMount && context[podNameField] != "" && context[podNamespaceField] != "" {
enableKataCCMount := d.isKataNode
confidentialContainerLabel := getValueInMap(context, confidentialContainerLabelField)
if !enableKataCCMount && confidentialContainerLabel != "" {
if !d.isKataNode && confidentialContainerLabel != "" {
klog.V(2).Infof("NodePublishVolume: checking if node %s is a kata node with confidential container label %s", d.NodeID, confidentialContainerLabel)
enableKataCCMount = isKataNode(ctx, d.NodeID, confidentialContainerLabel, d.kubeClient)
d.isKataNode = isKataNode(ctx, d.NodeID, confidentialContainerLabel, d.kubeClient)
}

if enableKataCCMount {
if d.isKataNode {
runtimeClass, err := getRuntimeClassForPodFunc(ctx, d.kubeClient, context[podNameField], context[podNamespaceField])
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get runtime class for pod %s/%s: %v", context[podNamespaceField], context[podNameField], err)
Expand Down Expand Up @@ -214,7 +213,7 @@ func (d *Driver) NodeUnpublishVolume(_ context.Context, req *csi.NodeUnpublishVo
return nil, status.Errorf(codes.Internal, "failed to unmount target %s: %v", targetPath, err)
}

if d.enableKataCCMount {
if d.enableKataCCMount && d.isKataNode {
klog.V(2).Infof("NodeUnpublishVolume: remove direct volume mount info %s from %s", volumeID, targetPath)
// Remove deletes the direct volume path including all the files inside it.
// if there is no kata-cc mountinfo present on this path, it will return nil.
Expand Down Expand Up @@ -468,9 +467,9 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
}
klog.V(2).Infof("volume(%s) mount %s on %s succeeded", volumeID, source, cifsMountPath)
}
enableKataCCMount := d.isKataNode && d.enableKataCCMount

// If runtime OS is not windows and protocol is not nfs, save mountInfo.json
if enableKataCCMount {
if d.enableKataCCMount && d.isKataNode {
if runtime.GOOS != "windows" && protocol != nfs {
// Check if mountInfo.json is already present at the targetPath
isMountInfoPresent, err := d.directVolume.VolumeMountInfo(cifsMountPath)
Expand Down Expand Up @@ -581,7 +580,7 @@ func (d *Driver) NodeUnstageVolume(_ context.Context, req *csi.NodeUnstageVolume
}
}

if d.enableKataCCMount {
if d.enableKataCCMount && d.isKataNode {
klog.V(2).Infof("NodeUnstageVolume: remove direct volume mount info %s from %s", volumeID, stagingTargetPath)
if err := d.directVolume.Remove(stagingTargetPath); err != nil {
return nil, status.Errorf(codes.Internal, "failed to remove mount info %s: %v", stagingTargetPath, err)
Expand Down
4 changes: 4 additions & 0 deletions pkg/azurefile/nodeserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
},
setup: func() {
if runtime.GOOS == "windows" {
d.isKataNode = true
mockDirectVolume.EXPECT().Remove(errorTarget).Return(nil)
}
},
Expand All @@ -355,6 +356,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
desc: "[Success] Valid request",
req: &csi.NodeUnpublishVolumeRequest{TargetPath: targetFile, VolumeId: "vol_1"},
setup: func() {
d.isKataNode = true
mockDirectVolume.EXPECT().Remove(targetFile).Return(nil)
},
expectedErr: testutil.TestError{},
Expand Down Expand Up @@ -898,6 +900,7 @@ func TestNodeUnstageVolume(t *testing.T) {
},
setup: func() {
if runtime.GOOS == "windows" {
d.isKataNode = true
mockDirectVolume.EXPECT().Remove(errorTarget).Return(nil)
}
},
Expand All @@ -906,6 +909,7 @@ func TestNodeUnstageVolume(t *testing.T) {
desc: "[Success] Valid request",
req: &csi.NodeUnstageVolumeRequest{StagingTargetPath: targetFile, VolumeId: "vol_1"},
setup: func() {
d.isKataNode = true
mockDirectVolume.EXPECT().Remove(targetFile).Return(nil)
},
expectedErr: testutil.TestError{},
Expand Down
Loading