Skip to content
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

improving command error message info #37

Merged
merged 1 commit into from
Apr 13, 2024

Conversation

zhangzhiqiangcs
Copy link
Contributor

When zfs_exporter is used in containers, more error message will help uesr know the container is missing common shared library like zfsutils-linux.

currently, the error message like

ts=2024-01-13T02:59:35.655Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=dataset-filesystem durationSeconds=0 err="exit status 127"
ts=2024-01-13T02:59:35.655Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=dataset-snapshot durationSeconds=0 err="exit status 127"
ts=2024-01-13T02:59:35.655Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=dataset-volume durationSeconds=0 err="exit status 127"
ts=2024-01-13T02:59:35.655Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=pool durationSeconds=0 err="exit status 127"

after this pr, the error message is like

ts=2024-01-13T02:59:04.950Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=pool durationSeconds=0 err="Failed to wait command /usr/sbin/zpool list -Ho name, err output: \"zpool: error while loading shared libraries: libzfs.so.4: cannot open shared object file: No such file or directory\n\": exit status 127"
ts=2024-01-13T02:59:04.950Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=dataset-filesystem durationSeconds=0 err="Failed to wait command /usr/sbin/zpool list -Ho name, err output: \"zpool: error while loading shared libraries: libzfs.so.4: cannot open shared object file: No such file or directory\n\": exit status 127"
ts=2024-01-13T02:59:04.951Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=dataset-snapshot durationSeconds=0 err="Failed to wait command /usr/sbin/zpool list -Ho name, err output: \"zpool: error while loading shared libraries: libzfs.so.4: cannot open shared object file: No such file or directory\n\": exit status 127"

Copy link
Owner

@pdf pdf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, couple of minor change requests.

zfs/pool.go Outdated Show resolved Hide resolved
zfs/pool.go Outdated Show resolved Hide resolved
@zhangzhiqiangcs zhangzhiqiangcs force-pushed the improving-error-message-info branch 3 times, most recently from b4b1cf3 to 7fc2e88 Compare January 13, 2024 05:33
@pdf pdf added the enhancement New feature or request label Jan 23, 2024
@pdf
Copy link
Owner

pdf commented Jan 23, 2024

Please also apply these changes to the zfs execution

if err = c.Start(); err != nil {

@zhangzhiqiangcs
Copy link
Contributor Author

zhangzhiqiangcs commented Jan 24, 2024

Please also apply these changes to the zfs execution

if err = c.Start(); err != nil {

@pdf As far as I know, if c.Start() fails,usually means fork/exec error, we can not get the stderr of the command. Please check and let me know If I was wrong

And the error I encountered libzfs.so.4: cannot open shared object file will be catched at cmd.Wait() not cmd.Start()

@zhangzhiqiangcs
Copy link
Contributor Author

ping @pdf, Could you give some suggestions or merge this

@pdf
Copy link
Owner

pdf commented Feb 24, 2024

Sorry for the delay, I've been travelling for work.

Please also apply these changes to the zfs execution

if err = c.Start(); err != nil {

@pdf As far as I know, if c.Start() fails,usually means fork/exec error, we can not get the stderr of the command. Please check and let me know If I was wrong

And the error I encountered libzfs.so.4: cannot open shared object file will be catched at cmd.Wait() not cmd.Start()

What I meant was, please apply this logic to the call to zfs in that file as you have for the call to zpool in zpool.go

@zhangzhiqiangcs
Copy link
Contributor Author

I see, just done it @pdf

Copy link
Owner

@pdf pdf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, apologies for the delay.

@pdf pdf merged commit 2277832 into pdf:master Apr 13, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants