Skip to content

change Lister to DynamicClient for subscription clean up in Teardown #2616

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

Merged
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
14 changes: 7 additions & 7 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ func TearDown(namespace string) {
var (
clientCtx = context.Background()
client = ctx.Ctx().Client()
dynamic = ctx.Ctx().DynamicClient()
inNamespace = k8scontrollerclient.InNamespace(namespace)
logf = ctx.Ctx().Logf
)
Expand All @@ -403,14 +404,13 @@ func TearDown(namespace string) {
return client.DeleteAllOf(clientCtx, &operatorsv1alpha1.Subscription{}, inNamespace)
}).Should(Succeed(), "failed to delete test subscriptions")

Eventually(func() (remaining []operatorsv1alpha1.Subscription, err error) {
list := &operatorsv1alpha1.SubscriptionList{}
err = client.List(clientCtx, list, inNamespace)
if list != nil {
remaining = list.Items
var subscriptiongvr = schema.GroupVersionResource{Group: "operators.coreos.com", Version: "v1alpha1", Resource: "subscriptions"}
Eventually(func() ([]unstructured.Unstructured, error) {
list, err := dynamic.Resource(subscriptiongvr).Namespace(namespace).List(context.Background(), metav1.ListOptions{})
Copy link
Member

Choose a reason for hiding this comment

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

I think this logic makes sense, moving the call from the cache to the api-server. Maybe if this works well we can expand the change to the other types in TearDown() as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good to me. Thanks!

if err != nil {
return nil, err
}

return
return list.Items, nil
}).Should(BeEmpty(), "failed to await deletion of test subscriptions")

logf("deleting test installplans...")
Expand Down