-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 racy notificationManager #3714
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.
Only the small change of check the error. Asides that, everything looks solid
apidef/notifications.go
Outdated
ContentType: "application/json", | ||
Body: notification, | ||
} | ||
postBody, _ := json.Marshal(notification) |
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.
would worth to check the error anyway
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.
solved!
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.
LGTM
defer resp.Body.Close() | ||
_, errRead := ioutil.ReadAll(resp.Body) | ||
if errRead != nil { | ||
log.Error("Request failed, trying again in 10s. Error was: ", err) |
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's logging err
and not errRead
. Can we log errRead
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.
Also can we reuse variable err
instead of having new errMarshaling
, errRead
etc initialised each time
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.
solved @jeffy-mathew
Kudos, SonarCloud Quality Gate passed!
|
* using native http client for notification manager * handling errors in NotificationsManager * fixing errors Co-authored-by: Jeffy Mathew <[email protected]>
Description
Using a native
http.Client
forNotificationManager
since the lib we were using (goreq
) is archived and has some data race problems franela/goreq#111In this way we avoid random data races related to the
NotificationManager
in our CI pipeline.Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
fork, don't request your
master
!master
branch (left side). Also, you should startyour branch off our latest
master
.go mod tidy && go mod vendor
go fmt -s
go vet