Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Create client for checking CRD deletion #1305

Merged
merged 1 commit into from
Dec 9, 2020

Conversation

GinnyJI
Copy link
Contributor

@GinnyJI GinnyJI commented Dec 4, 2020

The default client uses cache, and therefore, it might fail to notice if
a CR is deleted. We instead use our own client who doesn't use the
cache.

Tested: make test-e2e

Fix #1285

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 4, 2020
@adrianludwin
Copy link
Contributor

Just a few nits but otherwise lgtm

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 7, 2020
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

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

Whoops, forgot to include my actual comments last week! Here they are - a few nits still but mainly lgtm.

incubator/hnc/internal/reconcilers/setup.go Show resolved Hide resolved
incubator/hnc/internal/reconcilers/setup.go Show resolved Hide resolved
incubator/hnc/internal/reconcilers/setup.go Outdated Show resolved Hide resolved
incubator/hnc/internal/reconcilers/setup.go Show resolved Hide resolved
incubator/hnc/internal/reconcilers/setup.go Outdated Show resolved Hide resolved
The default client uses cache, and therefore, it might fail to notice if
a CR is deleted. We instead use our own client who doesn't use the
cache.

Tested: make test-e2e
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
/hold
/assign @rjbez17

Hey Ryan, since we can't reliably reproduce this problem, we don't have a test proving that it's fixed, but using an uncached client seems like the right thing to do in this case. Does this sound reasonable to you?

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 7, 2020
@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 7, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianludwin, GinnyJI

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 7, 2020
// Create creates all reconcilers.
//
// This function is called both from main.go as well as from the integ tests.
func Create(mgr ctrl.Manager, f *forest.Forest, maxReconciles int) error {
func Create(mgr ctrl.Manager, f *forest.Forest, maxReconciles int, useFakeClient bool) error {
Copy link

Choose a reason for hiding this comment

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

Since the client is created 100% by variables/info available outside this function, wouldn't it make more sense to just pass the client into this function instead of using a special bool to create a fake client or not?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a good point, although in this context I'm not sure it's worth the added complexity. The interface and global variable would still have to be declared in this file, while the clients that implement it would now be in cmd/manager/main.go and internal/reconcilers/suite_test.go, so the logic would be fairly scattered. The way @GinnyJI has written it, pretty much everything you need to know is in the same place, and I think that simplicity is worthwhile.

If we start adding a bunch more options here, then I'd be open to refactoring it. wdyt?

Copy link

Choose a reason for hiding this comment

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

Yeah, that sounds good.

@rjbez17
Copy link

rjbez17 commented Dec 9, 2020

/lgtm
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 9, 2020
@k8s-ci-robot k8s-ci-robot merged commit 215d7d6 into kubernetes-retired:master Dec 9, 2020
@adrianludwin adrianludwin added this to the hnc-v0.7 milestone Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HNC: subnamespaces are deleted because we don't realize CRDs are being deleted
4 participants