-
Notifications
You must be signed in to change notification settings - Fork 270
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
fix undefined log levels #402
Conversation
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.
Looks good! Had some minor comments/questions
return metadata | ||
} | ||
err = json.NewDecoder(strings.NewReader(identityDoc)).Decode(&metadata) | ||
if err != nil { | ||
log.Log().Msg("Unable to fetch instance identity document from ec2 metadata") | ||
log.Warn().Msg("Unable to fetch instance identity document from ec2 metadata") |
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.
log.Err(err)
?
- Both comments are nit for sure, but thinking if there's a log within
if err != nil
then it should be error for consistency
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.
I don't think we can make a strict rule like that. We have a fallback for this error, so I think it can stay a Warn.
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.
Not sure I agree that all loggin within err != nil should be error level, but we should come up with a consistent understanding of what these levels mean
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.
Agreed the rule can't be that strict, but if having a fallback doesn't classify as error, then what about:
ERR Unable to retrieve an IMDSv2 token, continuing with IMDSv1
v1 is the fallback in this case? Are there any formal docs for log-levels similar to semantic versioning or something? Agreed we need some kinda consistency
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.
yeah I changed that one to WARN
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.
I don't think there's anything formal for log levels... I think we probably log way too much in NTH, so maybe we should consider what actually makes sense to log so that someone can view the logs and be confident things are working and have enough information to debug certain error scenarios.
@@ -186,7 +186,7 @@ func main() { | |||
previousErr = err | |||
} | |||
if duplicateErrCount >= duplicateErrThreshold { | |||
log.Log().Msg("Stopping NTH - Duplicate Error Threshold hit.") | |||
log.Warn().Msg("Stopping NTH - Duplicate Error Threshold hit.") |
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.
log.panic since we're panicking ?
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 could, but IMHO it's clearer when they're separate. I don't think I'd expect a log to panic if I was reading and I didn't know of that weirdness.
return metadata | ||
} | ||
err = json.NewDecoder(strings.NewReader(identityDoc)).Decode(&metadata) | ||
if err != nil { | ||
log.Log().Msg("Unable to fetch instance identity document from ec2 metadata") | ||
log.Warn().Msg("Unable to fetch instance identity document from ec2 metadata") |
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.
Not sure I agree that all loggin within err != nil should be error level, but we should come up with a consistent understanding of what these levels mean
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.
🚀
Issue #, if available:
N/A
Description of changes:
Fix undefined log levels:
BEFORE:
AFTER:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.