Skip to content

Commit 2641fcf

Browse files
Merge pull request openstack-k8s-operators#1485 from ratailor/OSPRH-17071
Do not update status when reconciler exits due to panic
2 parents fdf9869 + 38ba64c commit 2641fcf

6 files changed

Lines changed: 31 additions & 0 deletions

controllers/client/openstackclient_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
122122

123123
// Always patch the instance status when exiting this function so we can persist any changes.
124124
defer func() {
125+
// Don't update the status, if reconciler Panics
126+
if r := recover(); r != nil {
127+
Log.Info(fmt.Sprintf("panic during reconcile %v\n", r))
128+
panic(r)
129+
}
125130
condition.RestoreLastTransitionTimes(&instance.Status.Conditions, savedConditions)
126131
// update the Ready condition based on the sub conditions
127132
if instance.Status.Conditions.AllSubConditionIsTrue() {

controllers/core/openstackcontrolplane_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ func (r *OpenStackControlPlaneReconciler) Reconcile(ctx context.Context, req ctr
168168

169169
// Always patch the instance status when exiting this function so we can persist any changes.
170170
defer func() {
171+
// Don't update the status, if reconciler Panics
172+
if r := recover(); r != nil {
173+
Log.Info(fmt.Sprintf("panic during reconcile %v\n", r))
174+
panic(r)
175+
}
171176
//Log all the conditions
172177

173178
// update the Ready condition based on the sub conditions

controllers/core/openstackversion_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package core
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"os"
2223
"strings"
2324

@@ -128,6 +129,11 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req
128129

129130
// Always patch the instance status when exiting this function so we can persist any changes.
130131
defer func() {
132+
// Don't update the status, if reconciler Panics
133+
if r := recover(); r != nil {
134+
Log.Info(fmt.Sprintf("panic during reconcile %v\n", r))
135+
panic(r)
136+
}
131137
// update the Ready condition based on the sub conditions
132138
if instance.Status.Conditions.AllSubConditionIsTrue() {
133139
instance.Status.Conditions.MarkTrue(

controllers/dataplane/openstackdataplanedeployment_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
129129

130130
// Always patch the instance status when exiting this function so we can persist any changes.
131131
defer func() { // update the Ready condition based on the sub conditions
132+
// Don't update the status, if reconciler Panics
133+
if r := recover(); r != nil {
134+
Log.Info(fmt.Sprintf("panic during reconcile %v\n", r))
135+
panic(r)
136+
}
132137
if instance.Status.Conditions.AllSubConditionIsTrue() {
133138
instance.Status.Conditions.MarkTrue(
134139
condition.ReadyCondition, condition.ReadyMessage)

controllers/dataplane/openstackdataplanenodeset_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req
183183

184184
// Always patch the instance status when exiting this function so we can persist any changes.
185185
defer func() { // update the Ready condition based on the sub conditions
186+
// Don't update the status, if reconciler Panics
187+
if r := recover(); r != nil {
188+
Log.Info(fmt.Sprintf("panic during reconcile %v\n", r))
189+
panic(r)
190+
}
186191
if instance.Status.Conditions.AllSubConditionIsTrue() {
187192
instance.Status.Conditions.MarkTrue(
188193
condition.ReadyCondition, dataplanev1.NodeSetReadyMessage)

controllers/operator/openstack_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ func (r *OpenStackReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
179179

180180
// Always patch the instance status when exiting this function so we can persist any changes.
181181
defer func() {
182+
// Don't update the status, if reconciler Panics
183+
if r := recover(); r != nil {
184+
Log.Info(fmt.Sprintf("panic during reconcile %v\n", r))
185+
panic(r)
186+
}
182187
// update the Ready condition based on the sub conditions
183188
if instance.Status.Conditions.AllSubConditionIsTrue() {
184189
instance.Status.Conditions.MarkTrue(

0 commit comments

Comments
 (0)