From b8955a5475fe7b6c436757477c887ed7ef82eee7 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Thu, 21 Jan 2021 16:51:47 +0300 Subject: [PATCH] fix: attach stack trace to panic error message Also removes debugging log. Signed-off-by: Andrey Smirnov --- pkg/controller/runtime/adapter.go | 3 ++- pkg/controller/runtime/dependency/dependency.go | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/controller/runtime/adapter.go b/pkg/controller/runtime/adapter.go index 7390896c..7ccf2dfe 100644 --- a/pkg/controller/runtime/adapter.go +++ b/pkg/controller/runtime/adapter.go @@ -9,6 +9,7 @@ import ( "errors" "fmt" "log" + "runtime/debug" "sort" "time" @@ -315,7 +316,7 @@ func (adapter *adapter) runOnce(ctx context.Context, logger *log.Logger) (err er defer func() { if p := recover(); p != nil { - err = fmt.Errorf("controller %q panicked: %s", adapter.name, p) + err = fmt.Errorf("controller %q panicked: %s\n\n%s", adapter.name, p, string(debug.Stack())) } }() diff --git a/pkg/controller/runtime/dependency/dependency.go b/pkg/controller/runtime/dependency/dependency.go index 5734eb48..5816e06e 100644 --- a/pkg/controller/runtime/dependency/dependency.go +++ b/pkg/controller/runtime/dependency/dependency.go @@ -7,7 +7,6 @@ package dependency import ( "fmt" - "log" "github.com/talos-systems/os-runtime/pkg/controller" ) @@ -29,8 +28,6 @@ func Less(a, b *controller.Dependency) bool { aStr := fmt.Sprintf("%s\000%s\000%s", a.Namespace, a.Type, aID) bStr := fmt.Sprintf("%s\000%s\000%s", b.Namespace, b.Type, bID) - log.Printf("%q, %q", aStr, bStr) - return aStr < bStr }