Skip to content

Commit 91c3c43

Browse files
operator: replace panic(fmt.Errorf(...)) with logr.Error + os.Exit(1)
1 parent 08d46e4 commit 91c3c43

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

operator/pkg/controller/clusterconfig/controller.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package clusterconfig
22

33
import (
44
"context"
5-
"fmt"
5+
"os"
66
"sync"
77
"time"
88

@@ -91,11 +91,10 @@ func (r *ClusterConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques
9191
if errors.IsNotFound(err) {
9292
if req.Name == instanceName {
9393
// NOTE: The main ClusterConfig object get created at operator startup,
94-
// so if, for whatever reason, this one get deleted we just "panic" so that
95-
// the operator restart and re-create the ClusterConfig
96-
panic(fmt.Errorf(
97-
"%s ClusterConfig object should not be deleted", req.Name,
98-
))
94+
// so if, for whatever reason, this one get deleted we log the error
95+
// and exit so that the operator restarts and re-creates the ClusterConfig
96+
reqLogger.Error(nil, "ClusterConfig object should not be deleted, exiting")
97+
os.Exit(1)
9998
}
10099
reqLogger.Info("ClusterConfig already deleted: nothing to do")
101100
return utils.EndReconciliation()

0 commit comments

Comments
 (0)