Skip to content

Commit 2888f3d

Browse files
committed
Do not update status when reconciler exits due to panic
Currently we use deferred call to always update the status field when Reconcile call exits, which seems correct for any other error except Reconciler exits due to panic. This change adds a call to recover fucntion and try to handle panic and log error. Closes: OSPRH-16940
1 parent 7ebacee commit 2888f3d

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

controllers/galera_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ func (r *GaleraReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
404404
// Always patch the instance status when exiting this function so we can
405405
// persist any changes.
406406
defer func() {
407+
// Don't update the status, if Reconciler Panics
408+
if r := recover(); r != nil {
409+
log.Info(fmt.Sprintf("Panic during reconcile %v\n", r))
410+
panic(r)
411+
}
407412
condition.RestoreLastTransitionTimes(
408413
&instance.Status.Conditions, savedConditions)
409414
if instance.Status.Conditions.IsUnknown(condition.ReadyCondition) {

controllers/mariadbaccount_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ func (r *MariaDBAccountReconciler) Reconcile(ctx context.Context, req ctrl.Reque
9696
// Always patch the instance status when exiting this function so we can
9797
// persist any changes.
9898
defer func() {
99+
// Don't update the status, if Reconciler Panics
100+
if r := recover(); r != nil {
101+
log.Info(fmt.Sprintf("Panic during reconcile %v\n", r))
102+
panic(r)
103+
}
99104
condition.RestoreLastTransitionTimes(
100105
&instance.Status.Conditions, savedConditions)
101106
if instance.Status.Conditions.IsUnknown(condition.ReadyCondition) {

controllers/mariadbdatabase_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ func (r *MariaDBDatabaseReconciler) Reconcile(ctx context.Context, req ctrl.Requ
8686
// Always patch the instance status when exiting this function so we can
8787
// persist any changes.
8888
defer func() {
89+
// Don't update the status, if Reconciler Panics
90+
if r := recover(); r != nil {
91+
log.Info(fmt.Sprintf("Panic during reconcile %v\n", r))
92+
panic(r)
93+
}
8994
condition.RestoreLastTransitionTimes(
9095
&instance.Status.Conditions, savedConditions)
9196
if instance.Status.Conditions.IsUnknown(condition.ReadyCondition) {

0 commit comments

Comments
 (0)