mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-03 11:45:20 +00:00
Merge pull request #9046 from blackpiglet/9032_fix
Some checks failed
Run the E2E test on kind / build (push) Failing after 7m37s
Run the E2E test on kind / setup-test-matrix (push) Successful in 4s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / Build (push) Failing after 1m1s
Close stale issues and PRs / stale (push) Successful in 18s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 1m40s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 1m35s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 1m21s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 1m26s
Some checks failed
Run the E2E test on kind / build (push) Failing after 7m37s
Run the E2E test on kind / setup-test-matrix (push) Successful in 4s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / Build (push) Failing after 1m1s
Close stale issues and PRs / stale (push) Successful in 18s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 1m40s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 1m35s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 1m21s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 1m26s
Make the backup repository controller doesn't invalidate the BSL on restart
This commit is contained in:
1
changelogs/unreleased/9046-blackpiglet
Normal file
1
changelogs/unreleased/9046-blackpiglet
Normal file
@@ -0,0 +1 @@
|
||||
Make the backup repository controller doesn't invalidate the BSL on restart
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/petar/GoLLRB/llrb"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
@@ -38,8 +39,6 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
"github.com/vmware-tanzu/velero/pkg/constant"
|
||||
"github.com/vmware-tanzu/velero/pkg/label"
|
||||
@@ -119,7 +118,22 @@ func (r *BackupRepoReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||
// BSL may be recreated after deleting, so also include the create event
|
||||
&velerov1api.BackupStorageLocation{},
|
||||
kube.EnqueueRequestsFromMapUpdateFunc(r.invalidateBackupReposForBSL),
|
||||
builder.WithPredicates(kube.NewUpdateEventPredicate(r.needInvalidBackupRepo)),
|
||||
builder.WithPredicates(
|
||||
// Combine three predicates together to guarantee
|
||||
// only BSL's Delete Event and Update Event can enqueue.
|
||||
// We don't care about BSL's Generic Event and Create Event,
|
||||
// because BSL's periodical enqueue triggers Generic Event,
|
||||
// and the BackupRepository controller restart will triggers BSL create event.
|
||||
kube.NewUpdateEventPredicate(
|
||||
r.needInvalidBackupRepo,
|
||||
),
|
||||
kube.NewGenericEventPredicate(
|
||||
func(client.Object) bool { return false },
|
||||
),
|
||||
kube.NewCreateEventPredicate(
|
||||
func(client.Object) bool { return false },
|
||||
),
|
||||
),
|
||||
).
|
||||
Complete(r)
|
||||
}
|
||||
|
||||
@@ -98,10 +98,22 @@ func NewGenericEventPredicate(f func(object client.Object) bool) predicate.Predi
|
||||
}
|
||||
|
||||
// NewUpdateEventPredicate creates a new Predicate that checks the Update event with the provided func
|
||||
func NewUpdateEventPredicate(f func(objectOld client.Object, objectNew client.Object) bool) predicate.Predicate {
|
||||
func NewUpdateEventPredicate(
|
||||
f func(objectOld client.Object, objectNew client.Object) bool,
|
||||
) predicate.Predicate {
|
||||
return predicate.Funcs{
|
||||
UpdateFunc: func(event event.UpdateEvent) bool {
|
||||
return f(event.ObjectOld, event.ObjectNew)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NewCreateEventPredicate(
|
||||
f func(object client.Object) bool,
|
||||
) predicate.Predicate {
|
||||
return predicate.Funcs{
|
||||
CreateFunc: func(event event.CreateEvent) bool {
|
||||
return f(event.Object)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,12 +202,27 @@ func TestNewGenericEventPredicate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewUpdateEventPredicate(t *testing.T) {
|
||||
predicate := NewUpdateEventPredicate(func(client.Object, client.Object) bool {
|
||||
return false
|
||||
})
|
||||
predicate := NewUpdateEventPredicate(
|
||||
func(client.Object, client.Object) bool {
|
||||
return false
|
||||
},
|
||||
)
|
||||
|
||||
assert.False(t, predicate.Update(event.UpdateEvent{}))
|
||||
assert.True(t, predicate.Create(event.CreateEvent{}))
|
||||
assert.True(t, predicate.Delete(event.DeleteEvent{}))
|
||||
assert.True(t, predicate.Generic(event.GenericEvent{}))
|
||||
}
|
||||
|
||||
func TestNewCreateEventPredicate(t *testing.T) {
|
||||
predicate := NewCreateEventPredicate(
|
||||
func(client.Object) bool {
|
||||
return false
|
||||
},
|
||||
)
|
||||
|
||||
assert.False(t, predicate.Create(event.CreateEvent{}))
|
||||
assert.True(t, predicate.Update(event.UpdateEvent{}))
|
||||
assert.True(t, predicate.Generic(event.GenericEvent{}))
|
||||
assert.True(t, predicate.Delete(event.DeleteEvent{}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user