Skip to content

Commit 50018eb

Browse files
Fix exported function and variable
1 parent 00854c2 commit 50018eb

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

controllers/secretproviderclasspodstatus_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ func (r *SecretProviderClassPodStatusReconciler) createOrUpdateK8sSecret(ctx con
419419
klog.InfoS("Kubernetes secret is already created", "secret", klog.ObjectRef{Namespace: namespace, Name: name})
420420
err := r.writer.Update(ctx, secret)
421421
if err != nil {
422-
klog.Errorf("Unable to update kubernetes secret", "secret", klog.ObjectRef{Namespace: namespace, Name: name})
422+
klog.ErrorS(err, "Unable to update kubernetes secret", "secret", klog.ObjectRef{Namespace: namespace, Name: name})
423423
return err
424424
}
425425
klog.InfoS("successfully updated Kubernetes secret", "secret", klog.ObjectRef{Namespace: namespace, Name: name})

pkg/secrets-store/nodeserver.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type nodeServer struct {
4444
// This should be used sparingly and only when the client does not fit the use case.
4545
reader client.Reader
4646
providerClients *PluginClientBuilder
47-
rotationConfig *RotationConfig
47+
rotationConfig *rotationConfig
4848
}
4949

5050
const (
@@ -122,7 +122,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
122122
if ns.rotationConfig.enabled {
123123
lastModificationTime, err := ns.getLastUpdateTime(targetPath)
124124
if err != nil {
125-
klog.Infof("could not find last modification time for %s, error: %v\n", targetPath, err)
125+
klog.InfoS("could not find last modification time for targetpath", targetPath, "error", err)
126126
} else if startTime.Before(lastModificationTime.Add(ns.rotationConfig.rotationPollInterval)) {
127127
// if next rotation is not yet due, then skip the mount operation
128128
return &csi.NodePublishVolumeResponse{}, nil
@@ -153,9 +153,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
153153
if isMockProvider(providerName) {
154154
// mock provider is used only for running sanity tests against the driver
155155

156-
// TODO: until requiresRemount (#585) is supported, "mounted" will always be false
157-
// and this code will always be called
158-
if !mounted {
156+
if !rotationEnabled && !mounted {
159157
err := ns.mounter.Mount("tmpfs", targetPath, "tmpfs", []string{})
160158

161159
if err != nil {
@@ -198,7 +196,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
198196
// and send it to the provider in the parameters.
199197
if parameters[CSIPodServiceAccountTokens] == "" {
200198
// Inject pod service account token into volume attributes
201-
klog.Error("csi.storage.k8s.io/serviceAccount.tokens is not populated, set RequiresRepublish")
199+
klog.ErrorS(err, "csi.storage.k8s.io/serviceAccount.tokens is not populated, set RequiresRepublish")
202200
}
203201

204202
// ensure it's read-only

pkg/secrets-store/nodeserver_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
"sigs.k8s.io/controller-runtime/pkg/client/fake"
3939
)
4040

41-
func testNodeServer(t *testing.T, client client.Client, reporter StatsReporter, rotationConfig *RotationConfig) (*nodeServer, error) {
41+
func testNodeServer(t *testing.T, client client.Client, reporter StatsReporter, rotationConfig *rotationConfig) (*nodeServer, error) {
4242
t.Helper()
4343

4444
// Create a mock provider named "provider1".
@@ -228,7 +228,7 @@ func TestNodePublishVolume_Errors(t *testing.T) {
228228
t.Run(test.name, func(t *testing.T) {
229229
r := mocks.NewFakeReporter()
230230

231-
ns, err := testNodeServer(t, fake.NewClientBuilder().WithScheme(s).WithObjects(test.initObjects...).Build(), r, &RotationConfig{})
231+
ns, err := testNodeServer(t, fake.NewClientBuilder().WithScheme(s).WithObjects(test.initObjects...).Build(), r, &rotationConfig{})
232232
if err != nil {
233233
t.Fatalf("expected error to be nil, got: %+v", err)
234234
}
@@ -268,7 +268,7 @@ func TestNodePublishVolume(t *testing.T) {
268268
name string
269269
nodePublishVolReq *csi.NodePublishVolumeRequest
270270
initObjects []client.Object
271-
rotationConfig *RotationConfig
271+
rotationConfig *rotationConfig
272272
}{
273273
{
274274
name: "volume mount",
@@ -296,7 +296,7 @@ func TestNodePublishVolume(t *testing.T) {
296296
},
297297
},
298298
},
299-
rotationConfig: &RotationConfig{
299+
rotationConfig: &rotationConfig{
300300
enabled: false,
301301
rotationPollInterval: time.Minute,
302302
},
@@ -330,7 +330,7 @@ func TestNodePublishVolume(t *testing.T) {
330330
},
331331
},
332332
},
333-
rotationConfig: &RotationConfig{
333+
rotationConfig: &rotationConfig{
334334
enabled: true,
335335
rotationPollInterval: -1 * time.Minute, // Using negative interval to pass the rotation interval check in unit tests
336336
},
@@ -361,7 +361,7 @@ func TestNodePublishVolume(t *testing.T) {
361361
},
362362
},
363363
},
364-
rotationConfig: &RotationConfig{
364+
rotationConfig: &rotationConfig{
365365
enabled: true,
366366
rotationPollInterval: time.Minute,
367367
},
@@ -427,7 +427,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
427427
)
428428

429429
r := mocks.NewFakeReporter()
430-
ns, err := testNodeServer(t, fake.NewClientBuilder().WithScheme(s).Build(), r, &RotationConfig{})
430+
ns, err := testNodeServer(t, fake.NewClientBuilder().WithScheme(s).Build(), r, &rotationConfig{})
431431
if err != nil {
432432
t.Fatalf("expected error to be nil, got: %+v", err)
433433
}
@@ -506,7 +506,7 @@ func TestNodeUnpublishVolume_Error(t *testing.T) {
506506
for _, test := range tests {
507507
t.Run(test.name, func(t *testing.T) {
508508
r := mocks.NewFakeReporter()
509-
ns, err := testNodeServer(t, fake.NewClientBuilder().WithScheme(s).Build(), r, &RotationConfig{})
509+
ns, err := testNodeServer(t, fake.NewClientBuilder().WithScheme(s).Build(), r, &rotationConfig{})
510510
if err != nil {
511511
t.Fatalf("expected error to be nil, got: %+v", err)
512512
}

pkg/secrets-store/secrets-store.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ type SecretsStore struct {
3838
ids *identityServer
3939
}
4040

41-
// RotationConfig stores the information required to rotate the secrets.
42-
type RotationConfig struct {
41+
// rotationConfig stores the information required to rotate the secrets.
42+
type rotationConfig struct {
4343
enabled bool
4444
rotationPollInterval time.Duration
4545
}
@@ -56,7 +56,7 @@ func NewSecretsStoreDriver(driverName, nodeID, endpoint string,
5656
os.Exit(1)
5757
}
5858

59-
rc := NewRotationConfig(rotationEnabled, rotationPollInterval)
59+
rc := newRotationConfig(rotationEnabled, rotationPollInterval)
6060
ns, err := newNodeServer(nodeID, mount.New(""), providerClients, client, reader, sr, rc)
6161
if err != nil {
6262
klog.ErrorS(err, "failed to initialize node server")
@@ -77,7 +77,7 @@ func newNodeServer(nodeID string,
7777
client client.Client,
7878
reader client.Reader,
7979
statsReporter StatsReporter,
80-
rotationConfig *RotationConfig) (*nodeServer, error) {
80+
rotationConfig *rotationConfig) (*nodeServer, error) {
8181
return &nodeServer{
8282
mounter: mounter,
8383
reporter: statsReporter,
@@ -89,8 +89,8 @@ func newNodeServer(nodeID string,
8989
}, nil
9090
}
9191

92-
func NewRotationConfig(enabled bool, interval time.Duration) *RotationConfig {
93-
return &RotationConfig{
92+
func newRotationConfig(enabled bool, interval time.Duration) *rotationConfig {
93+
return &rotationConfig{
9494
enabled: enabled,
9595
rotationPollInterval: interval,
9696
}

0 commit comments

Comments
 (0)