Skip to content

client.Get will hung when service-account lack of get and list permissions #550

Closed
@youyongsong

Description

@youyongsong

What happened?

I'm using the k8s client injected by the manager to get a secret resource, but I forgot to add the rbac rules to allow manager to list and get secret resources. Then the client.Get method hung and always retry to list secrets.

Here's the code:

secret := &corev1.Secret{}
err = client.Get(ctx,
	types.NamespacedName{
		Namespace: "default",
		Name:      "my-secret",
	},
	secret)

Here's the log:

E0806 02:11:02.862269       1 reflector.go:126] pkg/mod/k8s.io/client-go@v11.0.1-0.20190409021438-1a26190bd76a+incompatible/tools/cache/reflector.go:94: Failed to list *v1.Secret: secrets is forbidden: User "system:serviceaccount:cluster-registry-system:default" cannot list resource "secrets" in API group "" at the cluster scope
E0806 02:11:03.864770       1 reflector.go:126] pkg/mod/k8s.io/client-go@v11.0.1-0.20190409021438-1a26190bd76a+incompatible/tools/cache/reflector.go:94: Failed to list *v1.Secret: secrets is forbidden: User "system:serviceaccount:cluster-registry-system:default" cannot list resource "secrets" in API group "" at the cluster scope
E0806 02:11:04.867186       1 reflector.go:126] pkg/mod/k8s.io/client-go@v11.0.1-0.20190409021438-1a26190bd76a+incompatible/tools/cache/reflector.go:94: Failed to list *v1.Secret: secrets is forbidden: User "system:serviceaccount:cluster-registry-system:default" cannot list resource "secrets" in API group "" at the cluster scope

What i expected to happen?

I expected the client.Get will return an error immediately instead of always retry to list. Maybe it's a bug of DelegatingClient.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions