diff --git a/flyteadmin/pkg/rpc/adminservice/base.go b/flyteadmin/pkg/rpc/adminservice/base.go index 4f57846ff0..132b8334c8 100644 --- a/flyteadmin/pkg/rpc/adminservice/base.go +++ b/flyteadmin/pkg/rpc/adminservice/base.go @@ -51,7 +51,7 @@ func (m *AdminService) interceptPanic(ctx context.Context, request proto.Message } m.Metrics.PanicCounter.Inc() - logger.Fatalf(ctx, "panic-ed for request: [%+v] with err: %v", request, err) + logger.Fatalf(ctx, "panic-ed for request: [%+v] with err: %v with Stack: %v", request, err, string(debug.Stack())) } const defaultRetries = 3 diff --git a/flyteadmin/pkg/rpc/adminservice/base_test.go b/flyteadmin/pkg/rpc/adminservice/base_test.go new file mode 100644 index 0000000000..6e3f1ab4a9 --- /dev/null +++ b/flyteadmin/pkg/rpc/adminservice/base_test.go @@ -0,0 +1,40 @@ +package adminservice + +import ( + "context" + "testing" + + "github.com/flyteorg/flytestdlib/logger" + + "github.com/flyteorg/flytestdlib/promutils" + "github.com/golang/protobuf/proto" + "github.com/stretchr/testify/assert" +) + +func Test_interceptPanic(t *testing.T) { + m := AdminService{ + Metrics: InitMetrics(promutils.NewTestScope()), + } + + ctx := context.Background() + + // Mute logs to avoid .Fatal() (called in interceptPanic) causing the process to close + assert.NoError(t, logger.SetConfig(&logger.Config{Mute: true})) + + func() { + defer func() { + if err := recover(); err != nil { + assert.Fail(t, "Unexpected error", err) + } + }() + + a := func() { + defer m.interceptPanic(ctx, proto.Message(nil)) + + var x *int + *x = 10 + } + + a() + }() +}