-
I have written a simple hook in Python and configured it to subscribe monitor deletion of certain secrets: CONFIG = {
"configVersion": "v1",
"kubernetes": [
{
"name": "Monitor secrets apikey-monitor=enabled label",
"allowFailure": True,
"apiVersion": "v1",
"kind": "Secret",
"executeHookOnEvent": ["Deleted"],
"labelSelector": {
"matchLabels": {"apikey-monitor": "enabled"},
},
"namespace": {
"labelSelector": {
"matchLabels": {"apikey-monitor": "enabled"},
},
},
},
],
} My hook script only runs its logic if When I delete a single secret with the monitored label from my cluster, then I am observing in the operator logs that my hook is called twice: { "level":"info","logger":"shell-operator.hook-manager.hook.executor","msg":"Deleting secret default/myapikey",
"binding":"Monitor secrets apikey-monitor=enabled label","event":"kubernetes","hook":"01-apikey.py",
"output":"stdout","queue":"main","task":"HookRun","time":"2025-07-30T14:47:43Z"}
{ "level":"info","logger":"shell-operator.hook-manager.hook.executor","msg":"Deleting secret default/myapikey",
"binding":"Monitor secrets apikey-monitor=enabled label","event":"kubernetes","hook":"01-apikey.py",
"output":"stdout","queue":"main","task":"HookRun","time":"2025-07-30T14:47:43Z"} What could be the reason for the double invocation? I've read the docs HOOKS.md and search the archives but I cannot find an explanation of the duplicate invocation. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Please, forget this thread and forgive the noise. The issue was due to a silly bug in my Python code - it's been a long time since I wrote any Python - where I missed the |
Beta Was this translation helpful? Give feedback.
Please, forget this thread and forgive the noise.
The issue was due to a silly bug in my Python code - it's been a long time since I wrote any Python - where I missed the
break
infor/else
🤦♂️