Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[oadp-1.2] Use resource timeout with deleteVolumeSnapshots #267

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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