From f1b6a3549ce68fbebe567f37d724bab8a3b7b15f Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Fri, 21 Apr 2023 19:44:08 +0000 Subject: [PATCH] Fix stack log on panic Signed-off-by: Brad Davidson --- pkg/agent/cridockerd/cridockerd.go | 2 +- pkg/daemons/executor/embed.go | 12 ++++++------ pkg/server/server.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/agent/cridockerd/cridockerd.go b/pkg/agent/cridockerd/cridockerd.go index 8927a1e1024e..2ca681bfcbc9 100644 --- a/pkg/agent/cridockerd/cridockerd.go +++ b/pkg/agent/cridockerd/cridockerd.go @@ -34,7 +34,7 @@ func Run(ctx context.Context, cfg *config.Node) error { go func() { defer func() { if err := recover(); err != nil { - logrus.Fatalf("cri-dockerd panic: %s", debug.Stack()) + logrus.WithField("stack", string(debug.Stack())).Fatalf("cri-dockerd panic: %v", err) } }() logrus.Fatalf("cri-dockerd exited: %v", command.ExecuteContext(ctx)) diff --git a/pkg/daemons/executor/embed.go b/pkg/daemons/executor/embed.go index c09dd8277bae..4498f52fb31f 100644 --- a/pkg/daemons/executor/embed.go +++ b/pkg/daemons/executor/embed.go @@ -57,7 +57,7 @@ func (e *Embedded) Kubelet(ctx context.Context, args []string) error { go func() { defer func() { if err := recover(); err != nil { - logrus.WithField("stack", debug.Stack()).Fatalf("kubelet panic: %v", err) + logrus.WithField("stack", string(debug.Stack())).Fatalf("kubelet panic: %v", err) } }() // The embedded executor doesn't need the kubelet to come up to host any components, and @@ -79,7 +79,7 @@ func (*Embedded) KubeProxy(ctx context.Context, args []string) error { go func() { defer func() { if err := recover(); err != nil { - logrus.WithField("stack", debug.Stack()).Fatalf("kube-proxy panic: %v", err) + logrus.WithField("stack", string(debug.Stack())).Fatalf("kube-proxy panic: %v", err) } }() logrus.Fatalf("kube-proxy exited: %v", command.ExecuteContext(ctx)) @@ -101,7 +101,7 @@ func (*Embedded) APIServer(ctx context.Context, etcdReady <-chan struct{}, args <-etcdReady defer func() { if err := recover(); err != nil { - logrus.WithField("stack", debug.Stack()).Fatalf("apiserver panic: %v", err) + logrus.WithField("stack", string(debug.Stack())).Fatalf("apiserver panic: %v", err) } }() logrus.Fatalf("apiserver exited: %v", command.ExecuteContext(ctx)) @@ -130,7 +130,7 @@ func (e *Embedded) Scheduler(ctx context.Context, apiReady <-chan struct{}, args } defer func() { if err := recover(); err != nil { - logrus.WithField("stack", debug.Stack()).Fatalf("scheduler panic: %v", err) + logrus.WithField("stack", string(debug.Stack())).Fatalf("scheduler panic: %v", err) } }() logrus.Fatalf("scheduler exited: %v", command.ExecuteContext(ctx)) @@ -147,7 +147,7 @@ func (*Embedded) ControllerManager(ctx context.Context, apiReady <-chan struct{} <-apiReady defer func() { if err := recover(); err != nil { - logrus.WithField("stack", debug.Stack()).Fatalf("controller-manager panic: %v", err) + logrus.WithField("stack", string(debug.Stack())).Fatalf("controller-manager panic: %v", err) } }() logrus.Fatalf("controller-manager exited: %v", command.ExecuteContext(ctx)) @@ -180,7 +180,7 @@ func (*Embedded) CloudControllerManager(ctx context.Context, ccmRBACReady <-chan <-ccmRBACReady defer func() { if err := recover(); err != nil { - logrus.WithField("stack", debug.Stack()).Fatalf("cloud-controller-manager panic: %v", err) + logrus.WithField("stack", string(debug.Stack())).Fatalf("cloud-controller-manager panic: %v", err) } }() logrus.Errorf("cloud-controller-manager exited: %v", command.ExecuteContext(ctx)) diff --git a/pkg/server/server.go b/pkg/server/server.go index 7ad33280124a..e1020b70817f 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -181,7 +181,7 @@ func apiserverControllers(ctx context.Context, sc *Context, config *Config) { func runOrDie(ctx context.Context, name string, cb leader.Callback) { defer func() { if err := recover(); err != nil { - logrus.WithField("stack", debug.Stack()).Fatalf("%s controller panic: %v", name, err) + logrus.WithField("stack", string(debug.Stack())).Fatalf("%s controller panic: %v", name, err) } }() cb(ctx)