From 96d7932495d9d8ed4ea531d9974cbb431d2b692c Mon Sep 17 00:00:00 2001 From: Christoph Barbian Date: Tue, 15 Oct 2024 14:15:11 +0200 Subject: [PATCH] fix potential nil dereferencing panic --- pkg/component/reconciler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/component/reconciler.go b/pkg/component/reconciler.go index 7f2ad235..5bb2ef6b 100644 --- a/pkg/component/reconciler.go +++ b/pkg/component/reconciler.go @@ -228,8 +228,11 @@ func (r *Reconciler[T]) Reconcile(ctx context.Context, req ctrl.Request) (result status.ProcessingDigest = "" status.ProcessingSince = nil } - if status.State == StateProcessing && now.Sub(status.ProcessingSince.Time) >= timeout { + if status.State == StateProcessing && err == nil && now.Sub(status.ProcessingSince.Time) >= timeout { // TODO: maybe it would be better to have a dedicated StateTimeout? + // note: it is guaranteed that status.ProcessingSince is not nil here because + // - it was not cleared above because of the mutually exclusive clauses on status.State and err + // - it was set during reconcile when state was set to StateProcessing status.SetState(StateError, readyConditionReasonTimeout, "Reconcilation of dependent resources timed out") }