E53B Update service monitor status binding only if a change is detected by yp969803 · Pull Request #7827 · prometheus-operator/prometheus-operator · GitHub
[go: up one dir, main page]

Skip to content

Conversation

yp969803
Copy link
Contributor

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.


@yp969803 yp969803 requested a review from a team as a code owner August 21, 2025 08:55
@yp969803
Copy link
Contributor Author

@simonpasquier PTAL!

if binding.Namespace == c.workload.GetNamespace() &&
binding.Name == c.workload.GetName() &&
binding.Resource == c.gvr.Resource {
if binding.Conditions[0].ObservedGeneration == conditions[0].ObservedGeneration &&
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@yp969803
Copy link
Contributor Author

@simonpasquier merge request

binding.Name == c.workload.GetName() &&
binding.Resource == c.gvr.Resource {

for _, cond := range binding.Conditions {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor
@simonpasquier simonpasquier left a 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.

}

for i := range a {
if a[i].Type != b[i].Type ||
Copy link
Contributor

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.

Copy link
Contributor Author
@yp969803 yp969803 Aug 25, 2025

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

@pull-request-size pull-request-size bot added size/L and removed size/S labels Aug 25, 2025
Copy link
Contributor
@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@simonpasquier simonpasquier enabled auto-merge (squash) August 25, 2025 14:17
@simonpasquier simonpasquier merged commit 7c66cf2 into prometheus-operator:main Aug 26, 2025
47 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update service monitor status binding only if a change is detected
2 participants
0