-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Refactor getTTLFromAnnotations() to not return error #3939
Conversation
f193266
to
1924dca
Compare
source/source.go
Outdated
} | ||
ttlValue, err := parseTTL(ttlAnnotation) | ||
if err != nil { | ||
return ttlNotConfigured, fmt.Errorf("\"%v\" is not a valid TTL value", ttlAnnotation) | ||
log.Warnf("\"%v\" is not a valid TTL value", ttlAnnotation) |
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.Warnf("\"%v\" is not a valid TTL value", ttlAnnotation) | |
log.Warnf("\"%v\" is not a valid TTL value. It should follow Go duration like \"10m\" or \"3h\". Fraction is omitted.", ttlAnnotation) |
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.
It also accepts an integer number of seconds.
This isn't really the place to be giving detailed documentation, such as the rounding down of fractional seconds. At a more fundamental level, the log line omits important context: the name of the resource containing the ignored annotation. The previous code also omitted this context.
I could possibly see logging the error returned from the time.ParseDuration()
call.
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.
Ah yes. Providing the resource reference and the error of time.ParseDuration() seems a better idea.
/label tide/merge-method-squash |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: johngmyers 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 |
a961e39
to
4b42d5a
Compare
/lgtm |
Description
Refactors getTTLFromAnnotations() to not return an error. The only correct thing to do is to log the parsing failure and continue with a default TTL.
Checklist