Update service monitor status binding only if a change is detected#7827
Update service monitor status binding only if a change is detected#7827simonpasquier merged 6 commits intoprometheus-operator:mainfrom
Conversation
…s when conditions are unchanged
|
@simonpasquier PTAL! |
pkg/prometheus/operator.go
Outdated
| if binding.Namespace == c.workload.GetNamespace() && | ||
| binding.Name == c.workload.GetName() && | ||
| binding.Resource == c.gvr.Resource { | ||
| if binding.Conditions[0].ObservedGeneration == conditions[0].ObservedGeneration && |
There was a problem hiding this comment.
we need to compare all conditions to be future-proof.
…re updating status
|
@simonpasquier merge request |
pkg/prometheus/operator.go
Outdated
| binding.Name == c.workload.GetName() && | ||
| binding.Resource == c.gvr.Resource { | ||
|
|
||
| for _, cond := range binding.Conditions { |
There was a problem hiding this comment.
Let's always assume that we can have multiple conditions. We need to iterate over the conditions list too and compute the diff between conditions and binding.Conditions. If the diff is empty then we can return early. Otherwise we apply the diff.
…ates by comparing conditions directly
simonpasquier
left a comment
There was a problem hiding this comment.
Can we add unit tests for configResStatusConditionsEqual()?
IIUC now that #7829 merged, we should be able to only apply the modified binding instead of the full status field.
pkg/prometheus/operator.go
Outdated
| } | ||
|
|
||
| for i := range a { | ||
| if a[i].Type != b[i].Type || |
There was a problem hiding this comment.
It implies that a and b have identical sort order.
There was a problem hiding this comment.
i assumed that both the condiotions arrays are in correct order
There was a problem hiding this comment.
for safety and reliability, it's better to implement in a way that we don't depend on same order.
There was a problem hiding this comment.
ok sorted arrays based on timestamp
…by removing LastTransitionTime
…y using copies of slices
7c66cf2
into
prometheus-operator:main
fixes: #7792
Description
Update service monitor status binding only if a change is detected
Closes: #ISSUE-NUMBER
Type of change
What type of changes does your code introduce to the Prometheus operator? Put an
xin the box that apply.CHANGE(fix or feature that would cause existing functionality to not work as expected)FEATURE(non-breaking change which adds functionality)BUGFIX(non-breaking change which fixes an issue)ENHANCEMENT(non-breaking change which improves existing functionality)NONE(if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)Verification
Please check the Prometheus-Operator testing guidelines for recommendations about automated tests.
Changelog entry
Please put a one-line changelog entry below. This will be copied to the changelog file during the release process.