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
fixes a data race in SerializeObject function #94589
fixes a data race in SerializeObject function #94589
Conversation
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/writers.go
Show resolved
Hide resolved
} | ||
return |
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.
change looks good otherwise.
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.
The whole point of &deferredResponseWriter was to be able to write useful errors to the response if there was an encoding error. We should be able to determine if the error came from writing to the underlying http writer, and if not, we should continue trying to write an error to the http response
/hold
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.
edit: never mind, misread the error flow… was thrown off by the non-standard if err == nil
early return pattern
/hold cancel
792068d
to
a29445f
Compare
previously all sorts of errors including a data race were possible because deferredResponseWriter resets the writer and returns it to the pool. an attempt to write to a nil writer will lead to "invalid memory address or nil pointer dereference" sharing the same instance of deferredResponseWriter might lead to "index out of range [43] with length 30" and "recovered from err index > windowEnd" errors
a29445f
to
e6f9831
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: p0lyn0mial, sttts 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 |
…-upstream-release-1.18 Automated cherry pick of #94589: deferredResponseWriter returns after calling the Close()
…-upstream-release-1.19 Automated cherry pick of #94589: deferredResponseWriter returns after calling the Close()
Hi @p0lyn0mial and @sttts ! Can this fix be backported to 1.19 or is the upgrade to 1.20 mandatory please ? |
it was already backported to 1.19 - #98393 |
this was already backported to 1.18 and 1.19 |
@p0lyn0mial @liggitt Oh ok, thank you for the quick reply. I ask this because I arrived here from this one : kubernetes-sigs/prometheus-adapter#292 and we are in 1.19.8 and still observe these errors in the api-server logs :
Additionnal note : we looked at apiserver logs to try to understand a recent increase in apiserver memory consumption that cause some of our masters to be "NotReady" lately. |
Those are unrelated to this issue. The symptoms of this issue are listed in the description:
|
ok @liggitt thank you for your help |
What type of PR is this?
/kind bug
What this PR does / why we need it: It changes
deferredResponseWriter
to return after calling theClose()
method.Previously all sorts of errors including a data race were possible because
deferredResponseWriter
resets the writer and returns it to the pool. An attempt to write to a nil writer will lead toinvalid memory address or nil pointer dereference
. Sharing the same instance ofdeferredResponseWriter
might lead toindex out of range [43] with length 30
andrecovered from err index > windowEnd
errorsWhich issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: