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

Log errors of runner commands only in debug mode #1870

Merged

Conversation

davidcassany
Copy link
Contributor

During any installation we currently have this logs

INFO[2023-12-01T12:14:42Z] Partitioning device...                       
DEBU[2023-12-01T12:14:42Z] Running cmd: 'parted --script --machine -- /dev/vda unit s mklabel gpt' 
DEBU[2023-12-01T12:14:42Z] Running cmd: 'partx -u /dev/vda'             
ERRO[2023-12-01T12:14:42Z] Error running command: exit status 1

Where the error message is likely to appear in clearly visible red red. This particular error happens because after running any partition related change in disk run partx to reload and update partitions. This is only a best effort call, meaning we ignore any error (if running in a container this is likely to always fail, but doesn't necessarily mean there is an installation error).
Given the fact there a few command calls for which we ignore reported errors it doesn't make much sense having the runner.Run method to log at error level all command failures, this is caller responsibility to know if this should be logged at error level or not.

Hence in this PR on runner.Run errors we actually log everything (command error and command output) at debug level. Since the method returns the error and the command output, the caller still has the chance to log error as error level if this is the desired behavior.

Signed-off-by: David Cassany <dcassany@suse.com>
@davidcassany davidcassany requested a review from a team as a code owner December 1, 2023 12:42
Signed-off-by: David Cassany <dcassany@suse.com>
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c786f64) 75.34% compared to head (a8b70e5) 75.33%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1870      +/-   ##
==========================================
- Coverage   75.34%   75.33%   -0.02%     
==========================================
  Files          66       66              
  Lines        6896     6893       -3     
==========================================
- Hits         5196     5193       -3     
  Misses       1323     1323              
  Partials      377      377              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@davidcassany
Copy link
Contributor Author

@frelon this is an approach to what we discussed a while ago to prevent having misleading log messages. Probably we can do some more stuff to improve this particular case, but in any case the change suggested here does not harm in any way (just moving logs from error level to debug level) and actually makes sense from a wider perspective.

Then we can still consider calling partx over block devices only in partitioner wrapper. Probably by checking the special bit rather than relaying only on /dev path? Not sure, opened to any suggestion and idea.

Copy link
Contributor

@frelon frelon left a comment

Choose a reason for hiding this comment

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

Makes sense, then we can log an error outside of the Runner if appropriate 👍

@davidcassany davidcassany enabled auto-merge (rebase) December 1, 2023 12:59
@davidcassany davidcassany merged commit 01154fe into rancher:main Dec 1, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants