-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Namespace deletion is stuck when using namespace selector startup mode #1088
Labels
bug
Something isn't working
Comments
more code snippets. The CRD we use: # A demo CRD for the Kopf example operators.
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: kopfexamples.kopf.dev
spec:
scope: Namespaced
group: kopf.dev
names:
kind: KopfExample
plural: kopfexamples
singular: kopfexample
shortNames:
- kopfexes
- kopfex
- kexes
- kex
versions:
- name: v1
served: true
storage: true
subresources: { status: { } } # comment/uncomment for experiments
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
x-kubernetes-preserve-unknown-fields: true
status:
type: object
x-kubernetes-preserve-unknown-fields: true
additionalPrinterColumns:
- name: Duration
type: string
priority: 0
jsonPath: .spec.duration
description: For how long the pod should sleep.
- name: Children
type: string
priority: 0
jsonPath: .status.create_fn.children
description: The children pods created.
- name: Message
type: string
priority: 0
jsonPath: .status.create_fn.message
description: As returned from the handler (sometimes). and the resource manifest: apiVersion: kopf.dev/v1
kind: KopfExample
metadata:
name: kopf-example-1
namespace: example
labels:
somelabel: somevalue
annotations:
someannotation: somevalue
spec:
duration: 1m
field: value
items:
- item1
- item2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Long story short
When running a kopf operator with namespace selector AND deleting this namespace that contains a resource with a finalizer: kopf may not call the delete handler method.
Deleting the namespace stops the watch-stream for this namespace before the resources contained in that namespace get the chance have its delete method to be called.
Therefore, the finalizer is never removed and the namespace deletion is stuck waiting all resources to be deleted (but they won't since the watch-stream is stopped).
We manage to find a workaround using the clusterwide setting.
Earlier, we say "may not call"; in some cases the delete handler is called but it is quickly canceled by a CancelledError coming from kopf. We suppose it may be relatee to the event queue size. In the simple example provided, we never manage to get the delete handler to be called.
Kopf version
1.36.2
Kubernetes version
1.27.4
Python version
3.11.1
Code
Logs
Additional information
After some code digging trying to understand what's going on, we think the problem is here and the namespace is removed from the watching list without any check:
kopf/kopf/_core/reactor/observation.py
Line 202 in 91e8fd6
The text was updated successfully, but these errors were encountered: