litiliu opened a new pull request, #1175: URL: https://github.com/apache/flink-kubernetes-operator/pull/1175
## What is the purpose of the change This pull request fixes [FLINK-40372](https://issues.apache.org/jira/browse/FLINK-40372). `OperatorJosdkMetrics` caches resource-level metric groups and counters by `ResourceID`, but `cleanupDone` previously only incremented a cleanup counter. Metrics for deleted resources therefore remained registered and strongly referenced for the lifetime of the operator. Workloads that continuously create uniquely named resources, such as periodic `FlinkStateSnapshot` resources, could grow resource metric cardinality without bound. This change removes the resource-specific metric caches and closes the resource metric group after JOSDK reports cleanup, unregistering the deleted resource's counters from the Flink metric registry. ## Brief change log - Remove resource and resource-namespace metric group cache entries when cleanup completes. - Remove cached counters belonging to the deleted resource scope. - Close the resource metric group to unregister its counters. - Extend the metric test listener and add coverage for cleanup, repeated cleanup, and same-name resource recreation. ## Verifying this change This change added tests and can be verified as follows: - `OperatorJosdkMetricsTest`: 3 tests passed, covering cleanup, repeated cleanup, and metric re-registration for a recreated resource. - Broader metrics test set: 41 tests passed across 8 metrics test classes. - Spotless and Checkstyle checks passed. - `git diff --check` passed. A full `mvn clean verify` has not been run locally. ## Does this pull request potentially affect one of the following parts: - Dependencies (does it add or upgrade a dependency): no - The public API, i.e., is any changes to the `CustomResourceDescriptors`: no - Core observer or reconciler logic that is regularly executed: no ## Documentation - Does this pull request introduce a new feature? no - If yes, how is the feature documented? not applicable --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (OpenAI Codex) Generated-by: OpenAI Codex (GPT-5) Reviewed by Human -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
