-
Notifications
You must be signed in to change notification settings - Fork 904
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
deepequal check in helper.CreateOrUpdateWork() always return false, because resource.MarshalJSON() will add \n at the end of JSON #5938
Comments
thanks @zach593 @snowplayfire |
Thank you very much, it was a great find. I still have a doubt. Before the work is updated, the manifest file ends with |
/assign @zach593 |
When the object is passed to the kube-apiserver, the entire object will be unmarshaled as |
@zach593 Thank you for your answer. |
Hi @zach593, can you help point out the location of the decision logic code for these controllers? |
I don't understand this clearly. Can you explain it a little bit more, maybe we can track it with a new issue? |
already got one: #6017 |
Thanks to both of you. @zach593 and @snowplayfire. |
In work status controller, the location is
If the karmada/pkg/util/helper/workstatus.go Lines 300 to 310 in 8313813
If other interpreters are implemented and enabled, then obviously this will depend on how the interpreter is implemented. As for rb/crb status controller, karmada/pkg/controllers/status/rb_status_controller.go Lines 114 to 128 in 8313813
The And the |
What happened:
deepequal check in
helper.CreateOrUpdateWork()
always return false, becauseresource.MarshalJSON()
will add\n
at the end of JSON, but the workloads read from work.Spec.Workload.Manifests never have this\n
. So everytime this function is called, an update operation will occur.Fortunately, the same thing doesn't happen to work-status-controller, rb/crb-status-controller. Although they are both using
DeepEqual()
onruntime.RawExtension
, but the byte slices are obtained from resource interpret webhook.What you expected to happen:
remove unecessary update operations.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
@snowplayfire found this, I'm just providing some possible fixes here. Many thanks to her, I sincerely hope she has a happy holiday.
This is the root cause why binding controller can’t use
DeepEqual()
to skip the update operation when calling theensureWork()
. But for deepequal to work, we need another PR to copy part of the karmada webhook logic to the update operation, which I will complete as soon as possible.For fixing this issue, one way is just need one line: replace
resource.MarshalJSON()
withjson.Marshal(resource)
, it could work. #5939But deepequal checks should be used in semantic scenarios, not to judge byte streams. Therefore, if we want to use semantic deepequal checking to fix it, we need to directly judge the unmarshaled workload read from work. #5940
Environment:
kubectl-karmada version
orkarmadactl version
):The text was updated successfully, but these errors were encountered: