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
fix(leaderelection): survive malformed API error bodies and lock annotations
try_acquire_or_renew() parsed the raw error body with json.loads and
indexing straight into it, on the assumption that whatever came back is
a Kubernetes Status object. Anything sitting in front of the API server
(in an ingress, load balancer or proxy) happily answers with an HTML
error page, an empty payload or some other non-JSON body, and
ApiException.body can also be None. Each of those raised out of the
election loop and took the whole leader election down, which is the one
failure mode this code exists to prevent - a controller that stops
renewing its lease without ever calling onstopped_leading leaves the
workload in limbo until an operator notices.
Treat an unparsable or missing error body as 'not a 404' and retry on
the next period, in both the sync and the aio elector (the aio one also
crashed on an empty body through an assert).
The same class of problem existed on the read path of the ConfigMap
lock: a corrupted leader-election annotation raised out of get() and
killed the elector. Treat a non-JSON annotation like a missing one so
the next update rewrites a clean record.
Signed-off-by: NK <nk@localhost.localdomain>
Signed-off-by: NK <92711184+nkbeast@users.noreply.github.com>
0 commit comments