Fix stack log on panic

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
Brad Davidson 2023-04-21 19:44:08 +00:00 committed by Brad Davidson
parent c44d33d29b
commit f1b6a3549c
3 changed files with 8 additions and 8 deletions

View File

@ -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))

View File

@ -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))

View File

@ -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)