Skip to content

Commit 8aaca43

Browse files
committed
Address review feedback
Signed-off-by: James Munnelly <[email protected]>
1 parent 10aa8bf commit 8aaca43

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

driver/nodeserver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ type nodeServer struct {
4747
func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
4848
meta := metadata.FromNodePublishVolumeRequest(req)
4949
log := loggerForMetadata(ns.log, meta)
50-
ctx, _ = context.WithTimeout(ctx, time.Second*60)
51-
50+
ctx, cancel := context.WithTimeout(ctx, time.Second*60)
51+
defer cancel()
5252
// clean up after ourselves if provisioning fails.
5353
// this is required because if publishing never succeeds, unpublish is not
5454
// called which leaves files around (and we may continue to renew if so).

manager/manager.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ type Options struct {
8383
WriteKeypair WriteKeypairFunc
8484
ReadyToRequest ReadyToRequestFunc
8585

86-
// BackoffConfig configures the exponential backoff applied to certificate renewal failures.
87-
BackoffConfig *wait.Backoff
86+
// RenewalBackoffConfig configures the exponential backoff applied to certificate renewal failures.
87+
RenewalBackoffConfig *wait.Backoff
8888
}
8989

9090
// NewManager constructs a new manager used to manage volumes containing
@@ -103,8 +103,8 @@ func NewManager(opts Options) (*Manager, error) {
103103
if opts.Clock == nil {
104104
opts.Clock = clock.RealClock{}
105105
}
106-
if opts.BackoffConfig == nil {
107-
opts.BackoffConfig = &wait.Backoff{
106+
if opts.RenewalBackoffConfig == nil {
107+
opts.RenewalBackoffConfig = &wait.Backoff{
108108
// the 'base' amount of time for the backoff
109109
Duration: time.Second * 30,
110110
// We multiply the 'duration' by 2.0 if the attempt fails/errors
@@ -186,7 +186,7 @@ func NewManager(opts Options) (*Manager, error) {
186186

187187
maxRequestsPerVolume: opts.MaxRequestsPerVolume,
188188
nodeNameHash: nodeNameHash,
189-
backoffConfig: *opts.BackoffConfig,
189+
backoffConfig: *opts.RenewalBackoffConfig,
190190
}
191191

192192
vols, err := opts.MetadataReader.ListVolumes()
@@ -522,7 +522,8 @@ func (m *Manager) submitRequest(ctx context.Context, meta metadata.Metadata, csr
522522
}
523523

524524
// ManageVolumeImmediate will register a volume for management and immediately attempt a single issuance.
525-
// This
525+
// If issuing the initial certificate succeeds, the background renewal routine will be started similar to Manage().
526+
// Upon failure, it is the caller's responsibility to explicitly call `UnmanageVolume`.
526527
func (m *Manager) ManageVolumeImmediate(ctx context.Context, volumeID string) (managed bool, err error) {
527528
if !m.manageVolumeIfNotManaged(volumeID) {
528529
return false, nil
@@ -633,7 +634,10 @@ func (m *Manager) startRenewalRoutine(volumeID string) (started bool) {
633634
return true
634635
}
635636

636-
// ManageVolume will initiate management of data for the given volumeID.
637+
// ManageVolume will initiate management of data for the given volumeID. It will not wait for an initial certificate
638+
// to be issued and instead rely on the renewal handling loop to issue the initial certificate.
639+
// Callers can use `IsVolumeReady` to determine if a certificate has been successfully issued or not.
640+
// Upon failure, it is the callers responsibility to call `UnmanageVolume`.
637641
func (m *Manager) ManageVolume(volumeID string) (managed bool) {
638642
log := m.log.WithValues("volume_id", volumeID)
639643
if managed := m.manageVolumeIfNotManaged(volumeID); !managed {

test/util/testutil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func RunTestDriver(t *testing.T, opts DriverOptions) (DriverOptions, csi.NodeCli
121121
SignRequest: opts.SignRequest,
122122
WriteKeypair: opts.WriteKeypair,
123123
ReadyToRequest: opts.ReadyToRequest,
124-
BackoffConfig: &wait.Backoff{Steps: math.MaxInt32}, // don't actually wait (i.e. set all backoff times to 0)
124+
RenewalBackoffConfig: &wait.Backoff{Steps: math.MaxInt32}, // don't actually wait (i.e. set all backoff times to 0)
125125
})
126126

127127
d := driver.NewWithListener(lis, *opts.Log, driver.Options{

0 commit comments

Comments
 (0)