Skip to content

fix(statefulset): survive nil reconciler result instead of panicking#1754

Open
SAY-5 wants to merge 1 commit intoOT-CONTAINER-KIT:mainfrom
SAY-5:fix/statefulset-reconcile-nil-assertion-1753
Open

fix(statefulset): survive nil reconciler result instead of panicking#1754
SAY-5 wants to merge 1 commit intoOT-CONTAINER-KIT:mainfrom
SAY-5:fix/statefulset-reconcile-nil-assertion-1753

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 23, 2026

Fixes #1753.

Problem

statefulset.Reconcile unconditionally type-asserted the reconciler result as *appsv1.StatefulSet:

return *reconciled.(*appsv1.StatefulSet), err

reconciler.Reconcile can return (nil, err) when the underlying Create/Update failed, so the assertion panicked:

panic: interface conversion: client.Object is nil, not *v1.StatefulSet

This crashlooped the operator pod every reconcile cycle on RedisReplication CRs with an embedded sentinel (redis-s StatefulSet), and the managed StatefulSets lost their labels entirely.

Fix

Fall back to the expected StatefulSet and propagate err when the reconciler returned nil (or a non-StatefulSet), so the controller receives a valid value alongside the error and schedules a requeue instead of taking down the whole worker.

Test

go build ./internal/controller/common/statefulset/... clean; no existing tests in that package.

Reconcile unconditionally type-asserted the reconciler result as
*appsv1.StatefulSet. reconciler.Reconcile can return (nil, err) when
the downstream Create/Update failed, so the assertion panicked with
'interface conversion: client.Object is nil, not *v1.StatefulSet'
and crashlooped the operator whenever the sentinel StatefulSet
update path hit a transient error. Every subsequent reconcile
repeated the panic, and managed StatefulSets lost their labels
while operator pods cycled in CrashLoopBackOff.

Fall back to the expected StatefulSet and propagate err when the
reconciler returned nil (or a non-StatefulSet) so the controller
receives a valid value alongside the error and schedules a requeue
instead of taking down the whole worker.

Refs OT-CONTAINER-KIT/redis-operator issue 1753.

Signed-off-by: SAY-5 <say.apm35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic: interface conversion client.Object is nil, not *v1.StatefulSet during RedisReplication sentinel reconcile (v0.24.0)

1 participant