Skip to content

Commit 176cc94

Browse files
authored
add panic debug (#451)
1 parent b742eba commit 176cc94

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pkg/module_manager/module_manager.go

+16
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,22 @@ func (mm *ModuleManager) GetValuesValidator() *validation.ValuesValidator {
835835

836836
func (mm *ModuleManager) HandleKubeEvent(kubeEvent KubeEvent, createGlobalTaskFn func(*hooks.GlobalHook, controller.BindingExecutionInfo), createModuleTaskFn func(*modules.BasicModule, *hooks.ModuleHook, controller.BindingExecutionInfo)) {
837837
mm.LoopByBinding(OnKubernetesEvent, func(gh *hooks.GlobalHook, m *modules.BasicModule, mh *hooks.ModuleHook) {
838+
defer func() {
839+
if err := recover(); err != nil {
840+
logEntry := log.WithField("function", "HandleKubeEvent").WithField("event", "OnKubernetesEvent")
841+
842+
if gh != nil {
843+
logEntry.WithField("GlobalHook name", gh.GetName()).WithField("GlobakHook path", gh.GetPath())
844+
}
845+
846+
if mh != nil {
847+
logEntry.WithField("ModuleHook name", mh.GetName()).WithField("ModuleHook path", mh.GetPath())
848+
}
849+
850+
logEntry.Errorf("panic occurred: %s", err)
851+
}
852+
}()
853+
838854
if gh != nil {
839855
if gh.GetHookController().CanHandleKubeEvent(kubeEvent) {
840856
gh.GetHookController().HandleKubeEvent(kubeEvent, func(info controller.BindingExecutionInfo) {

0 commit comments

Comments
 (0)