-
Notifications
You must be signed in to change notification settings - Fork 810
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
Return error on the getTSDB function when user is not found. #6565
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: alanprot <[email protected]>
if db != nil { | ||
if err != nil { | ||
level.Warn(i.logger).Log("msg", "error getting user DB but userDB is not null", "err", err, "userID", userID) |
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.
why would this happen ?
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 should never happen.. it does not change the fact that if it happens if good to have a log! maybe i can add a comment
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 was trying to understand if you had an edge case in mind. either comment or
if db != nil && err == nil
return db, nil
works
@@ -2285,10 +2292,10 @@ func (i *Ingester) getOrCreateTSDB(userID string, force bool) (*userTSDB, error) | |||
|
|||
func (i *Ingester) blockChunkQuerierFunc(userId string) tsdb.BlockChunkQuerierFunc { |
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 a blocker] for the sake of following the same convention, should not this also return an error
What this PR does:
Im proposing to return an error on the
getTSDB
function when the userDB is not found.Everytime we invoke this function on the codebase we need to check if the return is nil but is very easy to forget to do so and cause problem like: #6518 #6521
Ex:
cortex/pkg/ingester/ingester.go
Lines 991 to 995 in 4b32f29
I think returning an error in such case will force us to always think about this case and prevent such scenarios in the future.
Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]