@@ -114,14 +114,13 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
114
114
}
115
115
116
116
if d .enableKataCCMount && context [podNameField ] != "" && context [podNamespaceField ] != "" {
117
- enableKataCCMount := d .isKataNode
118
117
confidentialContainerLabel := getValueInMap (context , confidentialContainerLabelField )
119
- if ! enableKataCCMount && confidentialContainerLabel != "" {
118
+ if ! d . isKataNode && confidentialContainerLabel != "" {
120
119
klog .V (2 ).Infof ("NodePublishVolume: checking if node %s is a kata node with confidential container label %s" , d .NodeID , confidentialContainerLabel )
121
- enableKataCCMount = isKataNode (ctx , d .NodeID , confidentialContainerLabel , d .kubeClient )
120
+ d . isKataNode = isKataNode (ctx , d .NodeID , confidentialContainerLabel , d .kubeClient )
122
121
}
123
122
124
- if enableKataCCMount {
123
+ if d . isKataNode {
125
124
runtimeClass , err := getRuntimeClassForPodFunc (ctx , d .kubeClient , context [podNameField ], context [podNamespaceField ])
126
125
if err != nil {
127
126
return nil , status .Errorf (codes .Internal , "failed to get runtime class for pod %s/%s: %v" , context [podNamespaceField ], context [podNameField ], err )
@@ -214,7 +213,7 @@ func (d *Driver) NodeUnpublishVolume(_ context.Context, req *csi.NodeUnpublishVo
214
213
return nil , status .Errorf (codes .Internal , "failed to unmount target %s: %v" , targetPath , err )
215
214
}
216
215
217
- if d .enableKataCCMount {
216
+ if d .enableKataCCMount && d . isKataNode {
218
217
klog .V (2 ).Infof ("NodeUnpublishVolume: remove direct volume mount info %s from %s" , volumeID , targetPath )
219
218
// Remove deletes the direct volume path including all the files inside it.
220
219
// if there is no kata-cc mountinfo present on this path, it will return nil.
@@ -472,9 +471,9 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
472
471
}
473
472
klog .V (2 ).Infof ("volume(%s) mount %s on %s succeeded" , volumeID , source , cifsMountPath )
474
473
}
475
- enableKataCCMount := d . isKataNode && d . enableKataCCMount
474
+
476
475
// If runtime OS is not windows and protocol is not nfs, save mountInfo.json
477
- if enableKataCCMount {
476
+ if d . enableKataCCMount && d . isKataNode {
478
477
if runtime .GOOS != "windows" && protocol != nfs {
479
478
// Check if mountInfo.json is already present at the targetPath
480
479
isMountInfoPresent , err := d .directVolume .VolumeMountInfo (cifsMountPath )
@@ -585,7 +584,7 @@ func (d *Driver) NodeUnstageVolume(_ context.Context, req *csi.NodeUnstageVolume
585
584
}
586
585
}
587
586
588
- if d .enableKataCCMount {
587
+ if d .enableKataCCMount && d . isKataNode {
589
588
klog .V (2 ).Infof ("NodeUnstageVolume: remove direct volume mount info %s from %s" , volumeID , stagingTargetPath )
590
589
if err := d .directVolume .Remove (stagingTargetPath ); err != nil {
591
590
return nil , status .Errorf (codes .Internal , "failed to remove mount info %s: %v" , stagingTargetPath , err )
0 commit comments