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

Upgrade from 0.19.x to 0.20.x leads to fakedynamic.NewSimpleDynamicClient panic #914

Closed
zbindenren opened this issue Jan 6, 2021 · 7 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@zbindenren
Copy link

zbindenren commented Jan 6, 2021

With 0.19.x this code works:

func TestArgo(t *testing.T) {
	c := fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()).Resource(
		schema.GroupVersionResource{
			Group:    "argoproj.io",
			Version:  "v1alpha1",
			Resource: "applications",
		},
	)

	c.Namespace("default").List(context.Background(), metav1.ListOptions{})
}

When I update to 0.20.x I get a panic:

=== RUN   TestArgo
--- FAIL: TestArgo (0.00s)
panic: coding error: you must register resource to list kind for every resource you're going to LIST when creating the client.  See NewSimpleDynamicClientWithCustomListKinds or register the list into the scheme: argoproj.io/v1alpha1, Resource=applications out of map[] [recovered]
        panic: coding error: you must register resource to list kind for every resource you're going to LIST when creating the client.  See NewSimpleDynamicClientWithCustomListKinds or register the list into the scheme: argoproj.io/v1alpha1, Resource=applications out of map[]

goroutine 7 [running]:
testing.tRunner.func1.1(0x1347360, 0xc0003c8f40)
        /home/rz/.gimme/versions/go1.15.5.linux.amd64/src/testing/testing.go:1072 +0x30d
testing.tRunner.func1(0xc00042fe00)
        /home/rz/.gimme/versions/go1.15.5.linux.amd64/src/testing/testing.go:1075 +0x41a
panic(0x1347360, 0xc0003c8f40)
        /home/rz/.gimme/versions/go1.15.5.linux.amd64/src/runtime/panic.go:969 +0x1b9
k8s.io/client-go/dynamic/fake.(*dynamicResourceClient).List(0xc000492540, 0x16aa440, 0xc000044128, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/rz/golang/pkg/mod/k8s.io/client-go@v0.20.1/dynamic/fake/simple.go:317 +0xcbf
git.pnet.ch/kubernetes/namespace-creator/pkg/kubernetes.TestArgo(0xc00042fe00)
        /home/rz/repos/git.pnet.ch/kubernetes/namespace-creator/pkg/kubernetes/client_test.go:66 +0x1f5
testing.tRunner(0xc00042fe00, 0x15a3508)
        /home/rz/.gimme/versions/go1.15.5.linux.amd64/src/testing/testing.go:1123 +0xef
created by testing.(*T).Run
        /home/rz/.gimme/versions/go1.15.5.linux.amd64/src/testing/testing.go:1168 +0x2b3
FAIL    git.pnet.ch/kubernetes/namespace-creator/pkg/kubernetes 0.015s
FAIL
@kouvaliasnick
Copy link

I have exactly the same issue. Has anyone managed to get insights on this?
I have just found the related commit and I will investigate more tomorrow

@cdmurph32
Copy link

cdmurph32 commented May 11, 2021

I ran into the same problem. After looking at the commit @kouvaliasnick found, I got my tests working again by modifying it to use NewSimpleDynamicClientWithCustomListKinds() instead of NewSimpleDynamicClient().
Kind of a pain that you have to explicitly add the list type, especially for v1 types.

func NewSimpleDynamicClientWithCustomListKinds(scheme *runtime.Scheme, gvrToListKind map[schema.GroupVersionResource]string, objects ...runtime.Object) *FakeDynamicClient {

@benmoss
Copy link
Member

benmoss commented Jun 7, 2021

There's an explanation from @deads2k here #949 (comment)

kingdonb pushed a commit to kingdonb/flux that referenced this issue Jul 27, 2021
kubernetes/client-go#914 (comment)

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
timonwong added a commit to timonwong/k8sutils that referenced this issue Jul 29, 2021
timonwong added a commit to timonwong/k8sutils that referenced this issue Jul 29, 2021
kingdonb pushed a commit to kingdonb/flux that referenced this issue Aug 4, 2021
kubernetes/client-go#914 (comment)

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
kingdonb pushed a commit to kingdonb/flux that referenced this issue Aug 17, 2021
* remove "replace" statement for go-autorest

With SOPS upgraded, "go mod tidy" now fails until this is removed.

* Resolve client-go issue from upgrade to 1.20

kubernetes/client-go#914 (comment)

* register deployments type

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
kingdonb pushed a commit to fluxcd/flux that referenced this issue Aug 17, 2021
* remove "replace" statement for go-autorest

With SOPS upgraded, "go mod tidy" now fails until this is removed.

* Resolve client-go issue from upgrade to 1.20

kubernetes/client-go#914 (comment)

* register deployments type

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
kingdonb pushed a commit to kingdonb/flux that referenced this issue Aug 17, 2021
* remove "replace" statement for go-autorest

With SOPS upgraded, "go mod tidy" now fails until this is removed.

* Resolve client-go issue from upgrade to 1.20

kubernetes/client-go#914 (comment)

* register deployments type

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
kingdonb pushed a commit to kingdonb/flux that referenced this issue Aug 17, 2021
* remove "replace" statement for go-autorest

With SOPS upgraded, "go mod tidy" now fails until this is removed.

* Resolve client-go issue from upgrade to 1.20

kubernetes/client-go#914 (comment)

* register deployments type

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
kingdonb pushed a commit to kingdonb/flux that referenced this issue Aug 17, 2021
* remove "replace" statement for go-autorest

With SOPS upgraded, "go mod tidy" now fails until this is removed.

* Resolve client-go issue from upgrade to 1.20

kubernetes/client-go#914 (comment)

* register deployments type

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
kingdonb pushed a commit to kingdonb/flux that referenced this issue Aug 18, 2021
* remove "replace" statement for go-autorest

With SOPS upgraded, "go mod tidy" now fails until this is removed.

* Resolve client-go issue from upgrade to 1.20

kubernetes/client-go#914 (comment)

* register deployments type

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 5, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 5, 2021
@benmoss
Copy link
Member

benmoss commented Oct 5, 2021

/close

@k8s-ci-robot
Copy link
Contributor

@benmoss: Closing this issue.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

skitt added a commit to skitt/lighthouse that referenced this issue Dec 20, 2021
This helps with go install (see
<golang/go#44840>). The side-effect upgrade
to Kubernetes 1.20 requires explicitly adding the GatewayList /
Gateway connection (see
<kubernetes/client-go#914>).

Signed-off-by: Stephen Kitt <skitt@redhat.com>
astoycos pushed a commit to astoycos/submariner that referenced this issue May 12, 2022
For a Fake k8s client we must now
explicitly register all resouces
we expect to list in the scheme.

Otherwise we'll run into
kubernetes/client-go#914

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
astoycos pushed a commit to astoycos/submariner that referenced this issue May 12, 2022
For a Fake k8s client we must now
explicitly register all resouces
we expect to list in the scheme.

Otherwise we'll run into
kubernetes/client-go#914

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
astoycos pushed a commit to astoycos/submariner that referenced this issue May 12, 2022
For a Fake k8s client we must now
explicitly register all resouces
we expect to list in the scheme.

Otherwise we'll run into
kubernetes/client-go#914

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
astoycos pushed a commit to astoycos/submariner that referenced this issue May 12, 2022
For a Fake k8s client we must now
explicitly register all resouces
we expect to list in the scheme.

Otherwise we'll run into
kubernetes/client-go#914

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
astoycos pushed a commit to astoycos/submariner that referenced this issue May 12, 2022
For a Fake k8s client we must now
explicitly register all resouces
we expect to list in the scheme.

Otherwise we'll run into
kubernetes/client-go#914

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
astoycos pushed a commit to astoycos/submariner that referenced this issue May 16, 2022
For a Fake k8s client we must now
explicitly register all resouces
we expect to list in the scheme.

Otherwise we'll run into
kubernetes/client-go#914

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
astoycos pushed a commit to astoycos/submariner that referenced this issue May 23, 2022
For a Fake k8s client we must now
explicitly register all resouces
we expect to list in the scheme.

Otherwise we'll run into
kubernetes/client-go#914

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
astoycos pushed a commit to astoycos/submariner that referenced this issue Jun 3, 2022
For a Fake k8s client we must now
explicitly register all resouces
we expect to list in the scheme.

Otherwise we'll run into
kubernetes/client-go#914

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
astoycos pushed a commit to astoycos/submariner that referenced this issue Jun 3, 2022
For a Fake k8s client we must now
explicitly register all resouces
we expect to list in the scheme.

Otherwise we'll run into
kubernetes/client-go#914

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
vthapar pushed a commit to submariner-io/submariner that referenced this issue Jun 4, 2022
For a Fake k8s client we must now
explicitly register all resouces
we expect to list in the scheme.

Otherwise we'll run into
kubernetes/client-go#914

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
novad03 pushed a commit to novad03/k8s-submariner that referenced this issue Nov 25, 2023
For a Fake k8s client we must now
explicitly register all resouces
we expect to list in the scheme.

Otherwise we'll run into
kubernetes/client-go#914

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

6 participants