Skip to content

Commit 992b55a

Browse files
Remove nextRotationTime field
1 parent 7bcc9fa commit 992b55a

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

pkg/secrets-store/nodeserver.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,10 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
124124
if ns.rotationConfig.enabled {
125125
lastModificationTime, err := ns.getLastUpdateTime(targetPath)
126126
if err != nil {
127-
klog.Infof("could not find last modification time for %f\n", targetPath)
128-
} else {
129-
klog.Infof("Last modification time %s", lastModificationTime.Format("2006-01-02 15:04:05"))
130-
klog.Infof("start time %s", startTime.Format("2006-01-02 15:04:05"))
131-
klog.Infof("next rotation time %s", lastModificationTime.Add(ns.rotationConfig.interval).Format("2006-01-02 15:04:05"))
132-
if startTime.Before(lastModificationTime.Add(ns.rotationConfig.interval)) {
133-
klog.Infof("Returning empty response")
134-
return &csi.NodePublishVolumeResponse{}, nil
135-
}
127+
klog.Infof("could not find last modification time for %s, error: %v\n", targetPath, err)
128+
} else if startTime.Before(lastModificationTime.Add(ns.rotationConfig.interval)) {
129+
// if next rotation is not yet, then skip the mount operation
130+
return &csi.NodePublishVolumeResponse{}, nil
136131
}
137132
}
138133

pkg/secrets-store/nodeserver_test.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,8 @@ func TestNodePublishVolume(t *testing.T) {
297297
},
298298
},
299299
rotationConfig: &RotationConfig{
300-
enabled: false,
301-
nextRotationTime: time.Now(),
302-
interval: time.Minute,
300+
enabled: false,
301+
interval: time.Minute,
303302
},
304303
},
305304
{
@@ -332,9 +331,8 @@ func TestNodePublishVolume(t *testing.T) {
332331
},
333332
},
334333
rotationConfig: &RotationConfig{
335-
enabled: true,
336-
nextRotationTime: time.Now().Add(-3 * time.Minute), // so that rotation period is passed and secret will be mounted.
337-
interval: time.Minute,
334+
enabled: true,
335+
interval: time.Minute,
338336
},
339337
},
340338
{
@@ -364,9 +362,8 @@ func TestNodePublishVolume(t *testing.T) {
364362
},
365363
},
366364
rotationConfig: &RotationConfig{
367-
enabled: true,
368-
nextRotationTime: time.Now().Add(2 * time.Minute),
369-
interval: time.Minute,
365+
enabled: true,
366+
interval: time.Minute,
370367
},
371368
},
372369
}

pkg/secrets-store/secrets-store.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ type SecretsStore struct {
4040

4141
// RotationConfig stores the informarmation required to rotate the secrets.
4242
type RotationConfig struct {
43-
enabled bool
44-
interval time.Duration
45-
nextRotationTime time.Time
43+
enabled bool
44+
interval time.Duration
4645
}
4746

4847
func NewSecretsStoreDriver(driverName, nodeID, endpoint string,
@@ -92,9 +91,8 @@ func newNodeServer(nodeID string,
9291

9392
func NewRotationConfig(enabled bool, interval time.Duration) *RotationConfig {
9493
return &RotationConfig{
95-
enabled: enabled,
96-
interval: interval,
97-
nextRotationTime: time.Now(),
94+
enabled: enabled,
95+
interval: interval,
9896
}
9997
}
10098

0 commit comments

Comments
 (0)