Concurrency rules between handlers #1046
-
What are the concurrency rules between handlers? For example, for my CRD, I have these async handlers:
The problem is that (2) and I haven't been able to find any description in the documentation about what things can run concurrently or not, mostly I'm concerned about:
I'm also happy to consider alternate patterns that don't require two handlers writing to the same field, but I can't think of a way to avoid it easily... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
It was somewhere is the docs, but the general rule is: one resource object is always sequential within its individual stream/lifecycle, multiple objects and kinds are concurrent to each other. This rule applies to short-running handlers only (creation/update/deletion/raw events). Timers & daemons run in parallel by design. You can consider them as side tools running elsewhere doing the updates. In neither case you can assume that the field is not patched by anything else while processing the change. It can be changed by any other application, such as kubectl, other operators, or the same operator accidentally running the 2nd instance. Kopf does not mutate domain-specific fields because it does not understand the domain. It only mutates its own annotations, finalizers, and whatever you code in the operator. Sorry, I didn’t get the pattern with 2 handlers, so as what is (5) — there are only 4 points. So I cannot hint on a better approach. But you can consider using Kopf’s indexes to keep track of pods belonging to a resource in a daemon/timer. It will add some inertia to the operator (e.g., 0.1-1 seconds) but might make it easier to track child pods. |
Beta Was this translation helpful? Give feedback.
It was somewhere is the docs, but the general rule is: one resource object is always sequential within its individual stream/lifecycle, multiple objects and kinds are concurrent to each other. This rule applies to short-running handlers only (creation/update/deletion/raw events).
Timers & daemons run in parallel by design. You can consider them as side tools running elsewhere doing the updates.
In neither case you can assume that the field is not patched by anything else while processing the change. It can be changed by any other application, such as kubectl, other operators, or the same operator accidentally running the 2nd instance.
Kopf does not mutate domain-specific fields because it…