Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

yp969803
Copy link
Contributor

Description

Remove binding from PodMonitor's status when workload deletd or invalid Ref

_Closes: #7919

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 September 18, 2025 11:34
@pull-request-size pull-request-size bot added size/L and removed size/M labels Sep 18, 2025
@yp969803
Copy link
Contributor Author

@simonpasquier merge request

@simonpasquier
Copy link
Contributor

We could merge it (once the tests pass) but I'd like that we explore how we can reduce the code duplication (it won't be sustainable when we add probes, prometheusrules, etc.).

@yp969803
Copy link
Contributor Author

don't know why !! but things are not updating, logic is similar to smon

@simonpasquier
Copy link
Contributor

The operator's logs say

ts=2025-09-18T12:11:57.486836263Z level=debug caller=/workspace/pkg/operator/resource_reconciler.go:501 msg="Prometheus deleted" component=prometheus-controller key=gatedfeatures-rmpodmonito
rbindingduringworkloaddelete--edc253da/workload-del-pmon-test
ts=2025-09-18T12:11:57.488789314Z level=error caller=/workspace/pkg/operator/resource_reconciler.go:680 msg="Unhandled Error" logger=UnhandledError err="sync \"gatedfeatures-rmpodmonitorbindingduringworkloaddelete--edc253da/workload-del-pmon-test\" failed: failed to remove \"monitoring.coreos.com/status-cleanup\" finalizer: prometheuses.monitoring.coreos.com \"workload-del-pmon-test\" not found"

but I'm not sure why and if it's related to the test failure. Have you tested manually?

@yp969803
Copy link
Contributor Author

yp969803 commented Sep 19, 2025

Have you tested manually

yes it is not updating manually also, in my local

@yp969803
Copy link
Contributor Author

ts=2025-09-18T12:11:57.486836263Z level=debug caller=/workspace/pkg/operator/resource_reconciler.go:501 msg="Prometheus deleted" component=prometheus-controller key=gatedfeatures-rmpodmonito
rbindingduringworkloaddelete--edc253da/workload-del-pmon-test
ts=2025-09-18T12:11:57.488789314Z level=error caller=/workspace/pkg/operator/resource_reconciler.go:680 msg="Unhandled Error" logger=UnhandledError err="sync \"gatedfeatures-rmpodmonitorbindingduringworkloaddelete--edc253da/workload-del-pmon-test\" failed: failed to remove \"monitoring.coreos.com/status-cleanup\" finalizer: prometheuses.monitoring.coreos.com \"workload-del-pmon-test\" not found"

this is not related to test failure, ig this is due to the prom is still present in the queue or cache after it is deleted. Will try to fix this later

@yp969803
Copy link
Contributor Author

yp969803 commented Sep 22, 2025

the problem happens here

	pm, ok := obj.(*monitoringv1.PodMonitor)
		if !ok {
			fmt.Println("not ok ma hu")
			return
		}

the obj is not typecasted in podMonitor @simonpasquier, i think the issue is with cache

}

// Remove bindings from all podMonitors which reference the workload.
if err := c.promInfs.ListAll(labels.Everything(), func(obj any) {
Copy link
Contributor

Choose a reason for hiding this comment

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

small typo, big effect :)

Suggested change
if err := c.promInfs.ListAll(labels.Everything(), func(obj any) {
if err := c.pmonInfs.ListAll(labels.Everything(), func(obj any) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have heard somewhere that -> naming and managing cache are the toughest things in software development

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 the changes

@simonpasquier simonpasquier enabled auto-merge (squash) September 23, 2025 07:37
@simonpasquier simonpasquier merged commit 7a2bb75 into prometheus-operator:main Sep 23, 2025
26 of 29 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.

3 participants