kopf
kopf copied to clipboard
Stop the handler execution after delete the object inside the handler
Problem
When i am delete a resource inside a handler kopf trying to patch the object and running inconsistencies checks, but it's not needed because the object does not exist anymore. This is consume the CPU and locks the interpreter.
Proposal
Maybe create any object inside the handler and call him for break execution manually after delete.
Checklist
- [x] Many users can benefit from this feature, it is not a one-time case
- [x] The proposal is related to the K8s operator framework, not to the K8s client libraries
I think I'm seeing a side-effect of this. Whenever the operator is deleting a managed StatefulSet, the Pod deletion handler goes in a loop with this, until I manually delete the KopfFinalizerMarker from the pod:
[2020-10-12 18:44:49,305] kopf.objects [DEBUG ] Patching with: {'metadata': {'annotations': {'kopf.zalando.org/touch-dummy': '2020-10-12T18:44:49.305390'}}, 'status': {'kopf': {'dummy': '2020-10-12T18:44:49.305390'}}}
[2020-10-12 18:44:49,325] kopf.objects [WARNING ] Patching failed with inconsistencies: (('remove', ('status', 'kopf'), {'dummy': '2020-10-12T18:44:49.305390'}, None),)
[2020-10-12 18:44:49,434] kopf.objects [DEBUG ] Handler 'on_pod_event' is invoked.
[2020-10-12 18:44:49,441] kopf.objects [DEBUG ] ignored pod event: pod=mycluster-0 containers_ready=False deleting=True phase=Pending member_info=None
[2020-10-12 18:44:49,443] kopf.objects [INFO ] Handler 'on_pod_event' succeeded.
[2020-10-12 18:44:49,443] kopf.objects [DEBUG ] Deletion event: {'kind': 'Pod', 'apiVersion': 'v1', ... snip ...
[2020-10-12 18:44:49,448] kopf.objects [DEBUG ] Patching with: {'metadata': {'annotations': {'kopf.zalando.org/touch-dummy': '2020-10-12T18:44:49.448459'}}, 'status': {'kopf': {'dummy': '2020-10-12T18:44:49.448459'}}}
[2020-10-12 18:44:49,471] kopf.objects [WARNING ] Patching failed with inconsistencies: (('remove', ('status', 'kopf'), {'dummy': '2020-10-12T18:44:49.448459'}, None),)
If this is the same thing, I'd call this a bug rather than a enhancement request, tho.
@akojima This looks like a different bug. Can you please report it separately, with a scenario & a snippet to reproduce the issue?
While I understand the patching inconsistencies (due to K8s 1.16+ structural schemas), they are not the problem — since there are equivalent annotations.
However, the pod must be released from the finalizer, in theory. I would like to reproduce it locally to see why it is not.
I just ran into this issue.
Deleting the KopfFinalizerMarker
did the trick for me as well.
@akojima Did you end up opening a separate bug?
If not, I'll try to find out what causes the issue and open it myself.
@OmegaVVeapon Please do. I didn't file a separate issue yet, I started isolating it but couldn't finish and got busy with other things.
FWIW the bug I mentioned bit me again and I was able to create a minimal test case, which I posted as #601.