-
Notifications
You must be signed in to change notification settings - Fork 575
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
[logging] Adds a method for using specific messaging for known errors #517
Conversation
Pull Request Test Coverage Report for Build 138755272
💛 - Coveralls |
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.
Almost good to me. Add minor comments, so could you please take a look into it?
@@ -0,0 +1,45 @@ | |||
package logging |
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.
May need to have copyright as multus/multus.go
logging/known_errors.go
Outdated
"strings" | ||
) | ||
|
||
// knownErrorPatterns Returns list of all known error patterns |
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 to use variable instead of function?
var knownErrorPatterns = []string{
"error dialing DHCP daemon",
}
logging/known_errors.go
Outdated
for _, eachstringer := range a { | ||
for _, eachknownerror := range knownerrors { | ||
if strings.Contains(fmt.Sprintf("%s", eachstringer), eachknownerror) { | ||
knownerrormessage, _ = getKnownErrorMessage(eachknownerror) |
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 to add error handling for getKnownErrorMessage() because getKnownErrorMessage() returns error.
return val, nil | ||
} | ||
|
||
return "", fmt.Errorf("Known error key '" + patternkey + "' does not have a message") |
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.
We may be use lower case for error message
https://github.com/golang/go/wiki/CodeReviewComments#error-strings
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.
still need to fix
logging/known_errors.go
Outdated
if strings.Contains(fmt.Sprintf("%s", eachstringer), eachknownerror) { | ||
knownerrormessage, _ = getKnownErrorMessage(eachknownerror) | ||
knownerrormessage = " (" + knownerrormessage + ") " | ||
break knownerrorloop |
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.
use continue instead of break?
99b8ba8
to
488fdc5
Compare
Thank you very much for the thorough review! Quite helpful. I have a new commit up to address it 👍 |
This pull request is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This introduces a new set of "known errors" -- a series of known errors that may occur, especially related to usage.
The goal is to add some actionable instructions for users when they encounter something that we know to occur with some frequency. In this case, we start with a single known error -- that error being when the DHCP CNI daemon isn't running the DHCP IPAM CNI plugin returns an error stating so much. Here, we instruct the user to make sure the DHCP CNI daemon is running.
The downside is that this makes the error messages even longer for the time being. However, I'm hopeful that in the future this makes for a way to shorten at least some known error messages.