@@ -101,14 +101,13 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
101101 }
102102
103103 if d .enableKataCCMount && context [podNameField ] != "" && context [podNamespaceField ] != "" {
104- enableKataCCMount := d .isKataNode
105104 confidentialContainerLabel := getValueInMap (context , confidentialContainerLabelField )
106- if ! enableKataCCMount && confidentialContainerLabel != "" {
105+ if ! d . isKataNode && confidentialContainerLabel != "" {
107106 klog .V (2 ).Infof ("NodePublishVolume: checking if node %s is a kata node with confidential container label %s" , d .NodeID , confidentialContainerLabel )
108- enableKataCCMount = isKataNode (ctx , d .NodeID , confidentialContainerLabel , d .kubeClient )
107+ d . isKataNode = isKataNode (ctx , d .NodeID , confidentialContainerLabel , d .kubeClient )
109108 }
110109
111- if enableKataCCMount {
110+ if d . isKataNode {
112111 runtimeClass , err := getRuntimeClassForPodFunc (ctx , d .kubeClient , context [podNameField ], context [podNamespaceField ])
113112 if err != nil {
114113 return nil , status .Errorf (codes .Internal , "failed to get runtime class for pod %s/%s: %v" , context [podNamespaceField ], context [podNameField ], err )
@@ -201,7 +200,7 @@ func (d *Driver) NodeUnpublishVolume(_ context.Context, req *csi.NodeUnpublishVo
201200 return nil , status .Errorf (codes .Internal , "failed to unmount target %s: %v" , targetPath , err )
202201 }
203202
204- if d .enableKataCCMount {
203+ if d .enableKataCCMount && d . isKataNode {
205204 klog .V (2 ).Infof ("NodeUnpublishVolume: remove direct volume mount info %s from %s" , volumeID , targetPath )
206205 // Remove deletes the direct volume path including all the files inside it.
207206 // if there is no kata-cc mountinfo present on this path, it will return nil.
@@ -432,9 +431,9 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
432431 }
433432 klog .V (2 ).Infof ("volume(%s) mount %s on %s succeeded" , volumeID , source , cifsMountPath )
434433 }
435- enableKataCCMount := d . isKataNode && d . enableKataCCMount
434+
436435 // If runtime OS is not windows and protocol is not nfs, save mountInfo.json
437- if enableKataCCMount {
436+ if d . enableKataCCMount && d . isKataNode {
438437 if runtime .GOOS != "windows" && protocol != nfs {
439438 // Check if mountInfo.json is already present at the targetPath
440439 isMountInfoPresent , err := d .directVolume .VolumeMountInfo (cifsMountPath )
@@ -545,7 +544,7 @@ func (d *Driver) NodeUnstageVolume(_ context.Context, req *csi.NodeUnstageVolume
545544 }
546545 }
547546
548- if d .enableKataCCMount {
547+ if d .enableKataCCMount && d . isKataNode {
549548 klog .V (2 ).Infof ("NodeUnstageVolume: remove direct volume mount info %s from %s" , volumeID , stagingTargetPath )
550549 if err := d .directVolume .Remove (stagingTargetPath ); err != nil {
551550 return nil , status .Errorf (codes .Internal , "failed to remove mount info %s: %v" , stagingTargetPath , err )
0 commit comments