Empty patch requests seen from helm-based operator even when there're no changes, overloading the kube apiserver #4956
Labels
kind/bug
Categorizes issue or PR as related to a bug.
language/helm
Issue is related to a Helm operator project
Milestone
Bug Report
We have an operator built on the operator-sdk and its helm-operator. We have been seeing empty patch requests going to the Kubernetes apiserver even there are no changes. We have a deployment scenario with hundreds of this operator, which caused heavy traffic onto the apiserver.
What did you do?
Follow the procedure here to deploy the operator in a Kubernetes cluster. We also enabled the apiserver audit logging to the "RequestResponse" level, and observed a set of empty patch requests received by the apiserver upon every reconcile event (which is every minute by default). One such patch request is the following; note that the
RequestObject
is "{}", an empty map.What did you expect to see?
We expect to see no patch requests being sent to the kube apiserver when there are no changes in the underlying resources.
What did you see instead? Under which circumstances?
We see empty patch requests being sent to the kube apiserver upon every reconcile event even when there are no changes.
Environment
Operator type: /language helm helm-operator
Kubernetes cluster type: vanilla
$ operator-sdk version
operator-sdk version: "v1.7.1-31-gf855bd6d", commit: "f855bd6d866a7f11ab6d145a5bc7939d4300c9bc", kubernetes version: "v1.20.2", go version: "go1.16.3", GOOS: "darwin", GOARCH: "amd64"
$ go version
(if language is Go)N/A
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"clean", BuildDate:"2021-04-08T21:15:16Z", GoVersion:"go1.16.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.10", GitCommit:"62876fc6d93e891aa7fbe19771e6a6c03773b0f7", GitTreeState:"clean", BuildDate:"2020-10-15T01:43:56Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
Possible Solution
Thanks to the pointer from Josh Manning and his team at RedHat, we have identified the cause. The 3-way merge call here will return a non-nil byte array "{}" when there is no change.
We've tested and confirmed that the following fix works. That's a change to add a check here for the "{}" scenario:
We intend to create a PR for the community to review.
The text was updated successfully, but these errors were encountered: