Skip to content

Commit

Permalink
Merge pull request vmware-tanzu#266 from sseago/vsc-deletion2
Browse files Browse the repository at this point in the history
Use resource timeout with deleteVolumeSnapshots
  • Loading branch information
sseago authored May 9, 2023
2 parents 53a2aa9 + 7223c39 commit 31f3427
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ func (s *server) runControllers(defaultVolumeSnapshotLocations map[string]string
s.metrics,
s.csiSnapshotLister,
s.csiSnapshotClient,
s.config.resourceTimeout,
)
if err := r.SetupWithManager(s.mgr); err != nil {
s.logger.Fatal(err, "unable to create controller", "controller", controller.BackupFinalizer)
Expand Down
6 changes: 5 additions & 1 deletion pkg/controller/backup_finalizer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"context"
"os"
"time"

snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
snapshotterClientSet "github.com/kubernetes-csi/external-snapshotter/client/v4/clientset/versioned"
Expand Down Expand Up @@ -57,6 +58,7 @@ type backupFinalizerReconciler struct {
log logrus.FieldLogger
volumeSnapshotLister snapshotv1listers.VolumeSnapshotLister
volumeSnapshotClient snapshotterClientSet.Interface
resourceTimeout time.Duration
}

// NewBackupFinalizerReconciler initializes and returns backupFinalizerReconciler struct.
Expand All @@ -72,6 +74,7 @@ func NewBackupFinalizerReconciler(
metrics *metrics.ServerMetrics,
volumeSnapshotLister snapshotv1listers.VolumeSnapshotLister,
volumeSnapshotClient snapshotterClientSet.Interface,
resourceTimeout time.Duration,
) *backupFinalizerReconciler {
return &backupFinalizerReconciler{
ctx: ctx,
Expand All @@ -85,6 +88,7 @@ func NewBackupFinalizerReconciler(
metrics: metrics,
volumeSnapshotLister: volumeSnapshotLister,
volumeSnapshotClient: volumeSnapshotClient,
resourceTimeout: resourceTimeout,
}
}

Expand Down Expand Up @@ -241,7 +245,7 @@ func (r *backupFinalizerReconciler) Reconcile(ctx context.Context, req ctrl.Requ

// Delete the VolumeSnapshots created in the backup, when CSI feature is enabled.
if len(volumeSnapshots) > 0 && len(volumeSnapshotContents) > 0 {
deleteVolumeSnapshots(volumeSnapshots, volumeSnapshotContents, log, 30, r.client, r.volumeSnapshotClient, 10)
deleteVolumeSnapshots(volumeSnapshots, volumeSnapshotContents, log, 30, r.client, r.volumeSnapshotClient, r.resourceTimeout)
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/controller/backup_finalizer_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func mockBackupFinalizerReconciler(fakectx context.Context, fakeClient kbclient.
metrics.NewServerMetrics(),
fakevolumeSnapshotLister,
fakevolumeSnapshotClient,
10*time.Minute,
), backupper
}
func TestBackupFinalizerReconcile(t *testing.T) {
Expand Down

0 comments on commit 31f3427

Please sign in to comment.