@@ -26,13 +26,10 @@ import (
26
26
"time"
27
27
28
28
internalerrors "sigs.k8s.io/secrets-store-csi-driver/pkg/errors"
29
- "sigs.k8s.io/secrets-store-csi-driver/pkg/k8s"
30
- "sigs.k8s.io/secrets-store-csi-driver/pkg/util/fileutil"
31
29
32
30
"github.com/container-storage-interface/spec/lib/go/csi"
33
31
"google.golang.org/grpc/codes"
34
32
"google.golang.org/grpc/status"
35
- "k8s.io/apimachinery/pkg/types"
36
33
"k8s.io/klog/v2"
37
34
mount "k8s.io/mount-utils"
38
35
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -47,7 +44,6 @@ type nodeServer struct {
47
44
// This should be used sparingly and only when the client does not fit the use case.
48
45
reader client.Reader
49
46
providerClients * PluginClientBuilder
50
- tokenClient * k8s.TokenClient
51
47
}
52
48
53
49
const (
@@ -73,7 +69,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
73
69
startTime := time .Now ()
74
70
var parameters map [string ]string
75
71
var providerName string
76
- var podName , podNamespace , podUID , serviceAccountName string
72
+ var podName , podNamespace , podUID string
77
73
var targetPath string
78
74
var mounted bool
79
75
errorReason := internalerrors .FailedToMount
@@ -120,7 +116,6 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
120
116
podName = attrib [CSIPodName ]
121
117
podNamespace = attrib [CSIPodNamespace ]
122
118
podUID = attrib [CSIPodUID ]
123
- serviceAccountName = attrib [CSIPodServiceAccountName ]
124
119
125
120
mounted , err = ns .ensureMountPoint (targetPath )
126
121
if err != nil {
@@ -135,10 +130,10 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
135
130
return nil , status .Errorf (codes .Internal , "failed to check if target path %s is mount point, err: %v" , targetPath , err )
136
131
}
137
132
}
138
- if mounted {
139
- klog .InfoS ("target path is already mounted" , "targetPath" , targetPath , "pod" , klog.ObjectRef {Namespace : podNamespace , Name : podName })
140
- return & csi.NodePublishVolumeResponse {}, nil
141
- }
133
+ // if mounted {
134
+ // klog.InfoS("target path is already mounted", "targetPath", targetPath, "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
135
+ // return &csi.NodePublishVolumeResponse{}, nil
136
+ // }
142
137
143
138
klog .V (2 ).InfoS ("node publish volume" , "target" , targetPath , "volumeId" , volumeID , "mount flags" , mountFlags )
144
139
@@ -190,14 +185,8 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
190
185
// and send it to the provider in the parameters.
191
186
if parameters [CSIPodServiceAccountTokens ] == "" {
192
187
// Inject pod service account token into volume attributes
193
- serviceAccountTokenAttrs , err := ns .tokenClient .PodServiceAccountTokenAttrs (podNamespace , podName , serviceAccountName , types .UID (podUID ))
194
- if err != nil {
195
- klog .ErrorS (err , "failed to get service account token attrs" , "pod" , klog.ObjectRef {Namespace : podNamespace , Name : podName })
196
- return nil , err
197
- }
198
- for k , v := range serviceAccountTokenAttrs {
199
- parameters [k ] = v
200
- }
188
+ klog .Error ("csi.storage.k8s.io/serviceAccount.tokens is not populated, set RequiresRepublish" )
189
+
201
190
}
202
191
203
192
// ensure it's read-only
@@ -296,13 +285,6 @@ func (ns *nodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
296
285
return nil , status .Error (codes .Internal , err .Error ())
297
286
}
298
287
299
- podUID := fileutil .GetPodUIDFromTargetPath (targetPath )
300
- if podUID != "" {
301
- // delete service account token from cache as the pod is deleted
302
- // to ensure the cache isn't growing indefinitely
303
- ns .tokenClient .DeleteServiceAccountToken (types .UID (podUID ))
304
- }
305
-
306
288
klog .InfoS ("node unpublish volume complete" , "targetPath" , targetPath , "time" , time .Since (startTime ))
307
289
return & csi.NodeUnpublishVolumeResponse {}, nil
308
290
}
0 commit comments