Dump stack trace when the plugin server handles panic

Mitigate the issue mentioned in #4782
When there's a bug or misconfiguration that causes nil pointer there
will be more stack trace information to help us debug.

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
pull/5110/head
Daniel Jiang 2022-07-11 01:41:00 +08:00
parent 267db7a931
commit 9102f53131
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1 @@
Dump stack trace when the plugin server handles panic

View File

@ -17,6 +17,8 @@ limitations under the License.
package framework
import (
"runtime/debug"
"github.com/pkg/errors"
"google.golang.org/grpc/codes"
)
@ -38,7 +40,8 @@ func handlePanic(p interface{}) error {
if _, ok := panicErr.(stackTracer); ok {
err = panicErr
} else {
err = errors.Wrap(panicErr, "plugin panicked")
errWithStacktrace := errors.Errorf("%v, stack trace: %s", panicErr, debug.Stack())
err = errors.Wrap(errWithStacktrace, "plugin panicked")
}
}