From 7a9f0800d9fa2f7ed9ca097ec8c4d3c5c5b0b2f8 Mon Sep 17 00:00:00 2001 From: panjunxun Date: Fri, 28 Mar 2025 00:02:28 +0800 Subject: [PATCH] fix(multipath): Replace `errors.Is` with `errors.As` for error type checking `errors.Is` can't handle `*exec.ExitError` correctly. Use `errors.As` to ensure capturing and handling non - zero exit code errors. --- iscsi/multipath.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iscsi/multipath.go b/iscsi/multipath.go index 4555ffd..54db912 100644 --- a/iscsi/multipath.go +++ b/iscsi/multipath.go @@ -36,7 +36,7 @@ func ExecWithTimeout(command string, args []string, timeout time.Duration) ([]by if err != nil { var ee *exec.ExitError - if ok := errors.Is(err, ee); ok { + if ok := errors.As(err, &ee); ok { klog.V(2).Infof("Non-zero exit code: %s\n", err) err = fmt.Errorf("%s", ee.Stderr) }