Closed whiskeyjimbo closed 4 years ago
I beleive it shouldn't update the status field as long as you don't set anything on it locally. I will add a test case and check this, but until then you can simply update the status field with the values from the existing object to make sure it won't diff.
I haven't tested this with versions > 1.14.9 (amazon EKS...), I know in versions < 1.15 PDB is immutable, not sure if that is contributing to this but a thought.
I've checked this and it works as expected. The status fields are changed on the API server and since those fields are not declared as omitempty it will be checked against the desired state which which will always diff if their values are different. (If they would be omitempty, then you won't see a diff as long as you don't set them in your desired state explicitly)
// Number of pod disruptions that are currently allowed.
PodDisruptionsAllowed int32 `json:"disruptionsAllowed" protobuf:"varint,3,opt,name=disruptionsAllowed"`
// current number of healthy pods
CurrentHealthy int32 `json:"currentHealthy" protobuf:"varint,4,opt,name=currentHealthy"`
// minimum desired number of healthy pods
DesiredHealthy int32 `json:"desiredHealthy" protobuf:"varint,5,opt,name=desiredHealthy"`
// total number of pods counted by this disruption budget
ExpectedPods int32 `json:"expectedPods" protobuf:"varint,6,opt,name=expectedPods"`
PDB can be immutable but the issue here is only with the status fields, which are indeed dynamic, so that thing is not contributing.
I still recommend to set the above fields in your desired object's status to the values in the existing object, so that you can avoid the diff.
thanks for looking into this @pepov
@whiskeyjimbo this should help: https://github.com/banzaicloud/k8s-objectmatcher/pull/21
Describe the bug using objectmatcher on a v1beta.PodDisruptionBudget causes unnecessary patches because it is trying to update the status field of PDR which is dynamic
Steps to reproduce the issue: create a PDB and use objectmatch to update it.
Expected behavior
PDB status should not be updated as it is dynamic based off of pods
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem like release numberm version, branch, etc.