Merge pull request #16150 from OdedViner/log_panics_controller

core: log panics in controller reconcile functions
This commit is contained in:
Travis Nielsen authored and GitHub committed 2025-07-29 09:59:27 -06:00
commit 7b2dfdba17
24 files changed
+33

No files matched your search

@@ -20,6 +20,7 @@ import (
"context"
"fmt"
"reflect"
"runtime/debug"
"slices"
"strconv"
"strings"
@@ -281,3 +282,11 @@ var ClusterResource = k8sutil.CustomResource{
Kind: reflect.TypeOf(cephv1.CephCluster{}).Name(),
APIVersion: fmt.Sprintf("%s/%s", cephv1.CustomResourceGroup, cephv1.Version),
}
// RecoverAndLogException handles and logs panics from a controller Reconcile loop.
func RecoverAndLogException() {
if r := recover(); r != nil {
logger.Errorf("Panic: %v", r)
logger.Errorf("Stack trace:\n%s", string(debug.Stack()))
}
}