You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
kubectl delete doesn't account for list/watch permissions on resource being deleted since Kubernetes 1.25 #1411
With the introduction of 77c921a the kubectl delete operation will indefinitely wait on the "resource deleted?" condition by means of list and watch when the user doesn't have permissions on the verb list and watch.
For example, if user is not given privilege to list or watch resources of kind "kind-foo", kubectl delete kind-foo resource-foo operation will never terminate even after resource-foo is removed from the server.
Not certain if the above change is intentional, however, the delete operation should account for the the case where user is forbidden to list and watch resources to resolve above side-effects.
What you expected to happen:
When user is not given list and watch access on kind-foo,kubectl delete kind-foo resource-foo should exit after it finds the reosurce-foo is removed in the apiserver.
How to reproduce it (as minimally and precisely as possible):
Grant user to create resource-foo (say demo-ns) of kind-foo (say ns or namespace) and revoke list and watch verbs in order not to see other user's resources.
kubectl delete kind-foo resource-foo # This step will never terminate even after resource-foo is deleted in server.
Anything else we need to know?:
NA
Environment:
Kubernetes client and server versions (use kubectl version):
Kubernetes server and kubectl version based on v1.25.6
Created a namespace called aiotrix
Created a user and associated the role with only the create access to the services
Create a service using the user context
Finally delete the service using the same user context
I'm getting the below error response with immediately
Error from server (Forbidden): services "nginx" is forbidden: User "user1" cannot delete resource "services" in API group "" in the namespace "aiotrix"
Please correct me if I'm wrong.
Role:
kind: RoleapiVersion: rbac.authorization.k8s.io/v1metadata:
namespace: aiotrixname: pod-readerrules:
- apiGroups: [""] # the core API groupresources: ["pods"]verbs: ["get", "watch", "list", "delete"]
- apiGroups: [""] # the core API groupresources: ["services"]verbs: ["create"]
Console:
➜ rbac kubectl config use-context user1-context
Switched to context "user1-context".
➜ rbac kubectl delete service nginx
Error from server (Forbidden): services "nginx" is forbidden: User "user1" cannot delete resource "services" in API group "" in the namespace "aiotrix"
➜ rbac kubectl get services
Error from server (Forbidden): services is forbidden: User "user1" cannot list resource "services" in API group "" in the namespace "aiotrix"
I got that problem too, my user can delete a namespace but is not allowed to list / watch others - so kubectl delete namespace XX will result in an endless error flow and never terminates:
$ kubectl delete namespace project-release
namespace "project-release" deleted
W0801 11:07:28.867409 745140 reflector.go:533] vendor/k8s.io/client-go/tools/watch/informerwatcher.go:146: failed to list *unstructured.Unstructured: namespaces "project-release" is forbidden: User "u-87672762" cannot list resource "namespaces" in API group "" at the cluster scope
E0801 11:07:28.867560 745140 reflector.go:148] vendor/k8s.io/client-go/tools/watch/informerwatcher.go:146: Failed to watch *unstructured.Unstructured: failed to list *unstructured.Unstructured: namespaces "project-release" is forbidden: User "u-87672762" cannot list resource "namespaces" in API group "" at the cluster scope
... and so on ...
That will run endlessly and never terminate.
Version used is: v1.27.4
This issue is labeled with priority/important-soon but has not been updated in over 90 days, and should be re-triaged.
Important-soon issues must be staffed and worked on either currently, or very soon, ideally in time for the next release.
You can:
Confirm that this issue is still relevant with /triage accepted (org members only)
Deprioritize it with /priority important-longterm or /priority backlog
This is also happening to me when deleting a namespace using github actions:
Run:
kubectl delete namespace $PR_NAMESPACE
namespace "pr-33" deleted
E0912 02:18:00.967377 1[5](https://github.com/***/actions/runs/10806417576/job/30026001219#step:5:5)28 reflector.go:158] "Unhandled Error" err="k8s.io/client-go/tools/watch/informerwatcher.go:14[6](https://github.com/***/actions/runs/10806417576/job/30026001219#step:5:6): Failed to watch *unstructured.Unstructured: the server has asked for the client to provide credentials"
W0912 02:18:02.362545 1528 reflector.go:561] k8s.io/client-go/tools/watch/informerwatcher.go:146: failed to list *unstructured.Unstructured: Unauthorized
E0912 02:18:02.362601 1528 reflector.go:158] "Unhandled Error" err="k8s.io/client-go/tools/watch/informerwatcher.go:146: Failed to watch *unstructured.Unstructured: failed to list *unstructured.Unstructured: Unauthorized"
W0912 02:18:05.061413 1528 reflector.go:561] k8s.io/client-go/tools/watch/informerwatcher.go:146: failed to list *unstructured.Unstructured: Unauthorized
E0912 02:18:05.061454 1528 reflector.go:158] "Unhandled Error" err="k8s.io/client-go/tools/watch/informerwatcher.go:146: Failed to watch *unstructured.Unstructured: failed to list *unstructured.Unstructured: Unauthorized"
W0912 02:18:08.91926[7](https://github.com/***/actions/runs/10806417576/job/30026001219#step:5:7) 1528 reflector.go:561] k8s.io/client-go/tools/watch/informerwatcher.go:146: failed to list *unstructured.Unstructured: Unauthorized
E0912 02:1[8](https://github.com/***/actions/runs/10806417576/job/30026001219#step:5:8):08.919313 1528 reflector.go:158] "Unhandled Error" err="k8s.io/client-go/tools/watch/informerwatcher.go:146: Failed to watch *unstructured.Unstructured: failed to list *unstructured.Unstructured: Unauthorized"
The delete actually works fine, but my cleanup pipeline is always marked failed because of infinite error output.
Activity
ardaguclu commentedon Apr 14, 2023
@mpuckett159 what do you think?
mpuckett159 commentedon Apr 14, 2023
Hm ok, I'll investigate further. Thank you for opening this.
eddiezane commentedon Apr 26, 2023
/triage accepted
/priority important-soon
We should get the fix backported.
Marly thinks it's because visitor ignore errors is set incorrectly.
/assign @mpuckett159
praem90 commentedon Jun 27, 2023
I've tried to reproduce the issue but failed.
I've followed the below steps:
Created a namespace called
aiotrixCreated a user and associated the role with only the
createaccess to theservicesCreate a service using the user context
Finally delete the service using the same user context
I'm getting the below error response with immediately
Please correct me if I'm wrong.
Role:
Console:
Kubectl version:
praem90 commentedon Jul 10, 2023
@narendramadanapalli Could you please help me to reproduce this issue?
tkrah commentedon Aug 1, 2023
I got that problem too, my user can delete a namespace but is not allowed to list / watch others - so kubectl delete namespace XX will result in an endless error flow and never terminates:
That will run endlessly and never terminate.
Version used is: v1.27.4
liggitt commentedon Aug 1, 2023
cc @soltysh for visibility to impact of wait changes on delete
as a workaround, you can indicate you don't want to wait for deletion with
--wait=falsek8s-triage-robot commentedon Jan 19, 2024
This issue is labeled with
priority/important-soonbut has not been updated in over 90 days, and should be re-triaged.Important-soon issues must be staffed and worked on either currently, or very soon, ideally in time for the next release.
You can:
/triage accepted(org members only)/priority important-longtermor/priority backlog/closeFor more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/
/remove-triage accepted
k8s-triage-robot commentedon Apr 18, 2024
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/staleis appliedlifecycle/stalewas applied,lifecycle/rottenis appliedlifecycle/rottenwas applied, the issue is closedYou can:
/remove-lifecycle stale/closePlease send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
k8s-triage-robot commentedon May 18, 2024
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/staleis appliedlifecycle/stalewas applied,lifecycle/rottenis appliedlifecycle/rottenwas applied, the issue is closedYou can:
/remove-lifecycle rotten/closePlease send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
amannijhawan commentedon Aug 1, 2024
@mpuckett159 any update on this issue ?
We recently started hitting this on k8s version 1.28+
Verified that the SA has role to delete the pod but not watch it.
[PLAT-14793] [K8s]Rolling restart on k8s universe hangs at 6%
Jyosua commentedon Sep 12, 2024
This is also happening to me when deleting a namespace using github actions:
The delete actually works fine, but my cleanup pipeline is always marked failed because of infinite error output.