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

fix(flaky): ensure that the CM finalizer is always removed #1091

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions test/e2e/parallel/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package parallel

import (
"context"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -284,6 +285,20 @@ func TestE2EFlow(t *testing.T) {
require.NoError(t, err)
require.NotEmpty(t, cm)

// ensure that the finalizer is removed in all cases, so the cleanup logic
// is not blocked and can delete the Space
var removeOnce sync.Once
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as in the other PR - it should be safe but maybe we could move this definition up one level.

removeFinalizer := func() {
removeOnce.Do(func() {
_, err = wait.For(t, memberAwait.Awaitility, &corev1.ConfigMap{}).
Update(cmName, cm.Namespace, func(cm *corev1.ConfigMap) {
cm.Finalizers = nil
})
require.NoError(t, err)
})
}
defer removeFinalizer()

deletePolicy := metav1.DeletePropagationForeground
deleteOpts := &client.DeleteOptions{
PropagationPolicy: &deletePolicy,
Expand Down Expand Up @@ -325,11 +340,7 @@ func TestE2EFlow(t *testing.T) {

t.Run("remove finalizer", func(t *testing.T) {
// when removing the finalizer from the CM
_, err = wait.For(t, memberAwait.Awaitility, &corev1.ConfigMap{}).
Update(cmName, cm.Namespace, func(cm *corev1.ConfigMap) {
cm.Finalizers = nil
})
require.NoError(t, err)
removeFinalizer()

// then check remaining resources are deleted
err = memberAwait.WaitUntilNamespaceDeleted(t, laraUserName, "dev")
Expand Down
Loading