-
Notifications
You must be signed in to change notification settings - Fork 947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prettify error messages for exec.Commands in Fluid #2718
Prettify error messages for exec.Commands in Fluid #2718
Conversation
Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com>
Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com>
} | ||
|
||
return err | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about change it into
if err != nil {
errMsg := fmt.Sprintf("failed to execute InstallRelease() command: %s", err)
log.Error(err, errMsg, "command", cmd.String())
err = errors.Wrap(err, "failed to create engine-related kubernetes resources")
}
return err
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With such implementation, log.Error
may print double err
info in the log.
And, errors.Wrap
returns something like failed to create engine-related kubernetes resources: exit status 1
which I think is more confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Codecov Report
@@ Coverage Diff @@
## master #2718 +/- ##
==========================================
- Coverage 67.55% 67.54% -0.01%
==========================================
Files 381 381
Lines 21968 21982 +14
==========================================
+ Hits 14840 14848 +8
- Misses 5381 5386 +5
- Partials 1747 1748 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
} | ||
return err | ||
} | ||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using errors.As
instead of strings.HasPrefix
?
if errors.Is(err, exec.ErrNotFound) {
return errors.New("fusemount command not found")
}
var fuseMountErr *exec.ExitError
if errors.As(err, &fuseMountErr) {
switch fuseMountErr.ExitCode() {
case 1:
return errors.New("timeout waiting for FUSE mount point to be ready")
case 2:
return fmt.Errorf("subPath \"%s\" not exists under FUSE mount", subPath)
}
}
return err
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx. Changed to errors.As
Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com>
Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com>
Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com>
Kudos, SonarCloud Quality Gate passed!
|
/test fluid-e2e |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cheyang The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
…#2718) * Prettify error log message when calling NodePublishVolume Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Prettify error logs when calling helm-related funcs Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Use instead `errors.As` Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Use instead `errors.As` Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Set higher log level for helm exec Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> --------- Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com>
…#2718) * Prettify error log message when calling NodePublishVolume Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Prettify error logs when calling helm-related funcs Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Use instead `errors.As` Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Use instead `errors.As` Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Set higher log level for helm exec Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> --------- Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> Signed-off-by: cheyang <cheyang@163.com>
* [juicefs] fix worker cache when set option (#2563) * fix worker cache when set option Signed-off-by: zwwhdls <zww@hdls.me> * update changelog in chart Signed-off-by: zwwhdls <zww@hdls.me> * fix unittest Signed-off-by: zwwhdls <zww@hdls.me> --------- Signed-off-by: zwwhdls <zww@hdls.me> Signed-off-by: cheyang <cheyang@163.com> * fix multi cache dir (#2639) * fix multi cache dir Signed-off-by: zwwhdls <zww@hdls.me> * fix unit test --------- Signed-off-by: zwwhdls <zww@hdls.me> Signed-off-by: cheyang <cheyang@163.com> * [Enhancement]CSI plugin checks mount point liveness before binding mount points (#2703) * Clean up broken mount point when NodeStageVolume Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Check mount point aliveness when NodePublishVolume Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Clean up broken mount point when NodeStageVolume Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Fix cleaning logic Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> --------- Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> Signed-off-by: cheyang <cheyang@163.com> * Prettify error messages for exec.Commands in Fluid (#2718) * Prettify error log message when calling NodePublishVolume Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Prettify error logs when calling helm-related funcs Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Use instead `errors.As` Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Use instead `errors.As` Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> * Set higher log level for helm exec Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> --------- Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> Signed-off-by: cheyang <cheyang@163.com> * update mount to check mountinfo, To #48327952 Signed-off-by: cheyang <cheyang@163.com> * update mount to check mountinfo, To #48327952 Signed-off-by: cheyang <cheyang@163.com> * Build docker images for v0.8.5, To #48327952 Signed-off-by: cheyang <cheyang@163.com> --------- Signed-off-by: zwwhdls <zww@hdls.me> Signed-off-by: cheyang <cheyang@163.com> Signed-off-by: dongyun.xzh <dongyun.xzh@alibaba-inc.com> Co-authored-by: Weiwei <zww@hdls.me> Co-authored-by: TzZtzt <trafalgarz@outlook.com>
Ⅰ. Describe what this PR does
Fluid relies on
exec.Command
to execute some operations and interacts with K8s API-Server(e.g. Thehelm
for install/check/delete engine-related resources).exec.Command
will always returns a meaninglesserr
that would confuses users about the cause of their problems.For example, when Fluid CSI Plugin fails to bind mount a FUSE mount point onto a pod, an event is issued on the pod showing messages like:
This PR prettifies such error messages with a clearer explanation about the cause. For example, the event message mentioned above would be changed to:
which indicates that it's highly possible the FUSE pod is still not ready on that node
Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews