Skip to content

Commit fcf8439

Browse files
committed
Properly resume management of volumes on startup when continueOnNotReady is enabled
Signed-off-by: James Munnelly <[email protected]>
1 parent e80da6f commit fcf8439

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

driver/nodeserver.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
6868
return nil, status.Error(codes.InvalidArgument, "pod.spec.volumes[].csi.readOnly must be set to 'true'")
6969
}
7070

71+
// If continueOnNotReady is enabled, set the NextIssuanceTime in the metadata file to epoch.
72+
// This allows the manager to start management for the volume again on restart if the first
73+
// issuance did not successfully complete.
74+
if meta.NextIssuanceTime == nil && ns.continueOnNotReady {
75+
epoch := time.Time{}
76+
meta.NextIssuanceTime = &epoch
77+
}
78+
7179
if registered, err := ns.store.RegisterMetadata(meta); err != nil {
7280
return nil, err
7381
} else {

manager/manager.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ func NewManager(opts Options) (*Manager, error) {
189189
// not able to clean up the state store before an unexpected exit.
190190
// Whatever is calling the CSI plugin should call NodePublishVolume again relatively soon
191191
// after we start up, which will trigger management to resume.
192+
// Note: if continueOnNotReady is set to 'true', the metadata file will persist the nextIssuanceTime
193+
// as the 'now' time of the NodePublishVolume call. We will therefore resume management of
194+
// these volumes despite there not having been a successful initial issuance.
195+
// For users upgrading from an older version of the csi-lib, this field will not be set.
196+
// These pods will only have management begun again upon the next NodePublishVolume call, which
197+
// may not happen at all unless `requireRepublish: true` is set on the CSIDriver object.
192198
// TODO: we should probably consider deleting the volume from the state store in these instances
193199
// to avoid having leftover metadata files for pods that don't actually exist anymore.
194200
log.Info("Skipping management of volume that has never successfully completed")

0 commit comments

Comments
 (0)