-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Update service monitor status binding only if a change is detected #7827
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to compare all conditions to be future-proof.
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.
done
…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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
@simonpasquier done
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.
dome @simonpasquier
…ates by comparing conditions directly
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It implies that a and b have identical sort order.
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.
i assumed that both the condiotions arrays are in correct order
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok sorted arrays based on timestamp
…by removing LastTransitionTime
…y using copies of slices
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.
Thanks!
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
x
in 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.