Dennis-Mircea opened a new pull request, #1174:
URL: https://github.com/apache/flink-kubernetes-operator/pull/1174
<!--
*Thank you very much for contributing to the Apache Flink Kubernetes
Operator - we are happy that you want to help us improve the project. To help
the community review your contribution in the best possible way, please go
through the checklist below, which will get the contribution into a shape in
which it can be best reviewed.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA
issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are
made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the
pull request", where *FLINK-XXXX* should be replaced by the actual issue
number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following
this pattern: `[hotfix][docs] Fix typo in event time introduction` or
`[hotfix][javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the
pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean
verify` passes. You can read more on how we use GitHub Actions for CI
[here](https://nightlies.apache.org/flink/flink-kubernetes-operator-docs-main/docs/development/guide/#cicd).
- Each pull request should address only one issue, not mix up code from
multiple issues.
- Each commit in the pull request has a meaningful commit message
(including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and
this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
[FLIP-514](https://cwiki.apache.org/confluence/display/FLINK/FLIP-514%3A+Custom+Evaluator+plugin+for+Flink+Autoscaler)
introduced the `ScalingMetricsEvaluatorPlugin` SPI, but only a single
evaluator instance was honored per job.
`job.autoscaler.metrics.custom-evaluators` was already parsed as a list, and
when more than one entry was configured the autoscaler logged a warning and
silently fell back to the first entry, ignoring the rest.
This change lifts that limitation. All configured instances are now resolved
and composed into an ordered chain, so a job can combine several evaluators
instead of picking one.
The ordering contract and the resolution code follow the existing
`ScalingExecutorPlugin` chain (FLIP-575) so both autoscaler plugin families
behave the same way.
## Brief change log
- Add a `priority()` method to `ScalingMetricsEvaluatorPlugin`, defaulting
to `0`. Lower values run first.
- Resolve every configured instance in `ScalingMetricEvaluator` and sort the
chain by ascending `priority()`, mirroring
`ScalingExecutor#resolveCustomScalingExecutors`. Duplicate instance names are
ignored with a warning, and instances whose class is missing or unregistered
are skipped.
- Apply the chain per vertex. Each evaluator receives an unmodifiable view
of the metrics as already overridden by the earlier ones, so on a conflicting
`ScalingMetric` the later evaluator wins.
- Isolate failures, so an evaluator that throws is logged and skipped
without breaking the rest of the chain.
- Build one `Context` per instance, carrying that instance's prefix-stripped
configuration.
- Log the resolved chain in priority order on every cycle, matching the
executor's existing log line.
- Update the `job.autoscaler.metrics.custom-evaluators` description and the
generated configuration docs.
## Verifying this change
Covered by unit tests in `ScalingMetricEvaluatorTest`:
- `testResolveCustomEvaluators` covers resolution: single instance,
per-instance scoped configuration, unknown class, missing `.class` option,
nothing configured, ordering by ascending priority, and no registered
evaluators.
- `testCustomEvaluatorChain` verifies the chain composes and is ordered by
priority rather than by configuration order. The chaining evaluator is listed
first but has priority 100, so it runs last and increments the base evaluator's
value from 100000 to 100001.
- `testCustomEvaluatorChainContinuesAfterFailure` verifies that an evaluator
throwing mid-chain is isolated and the remaining evaluators still run.
- `testSameEvaluatorClassRegisteredUnderMultipleInstances` verifies that one
class registered under two names resolves to two entries backed by a single
object, each with its own scoped configuration.
The full `flink-autoscaler` suite passes (260 tests), along with `mvn clean
install -Pgenerate-docs` leaving the tree clean, `javadoc:javadoc`, checkstyle
and spotless.
## 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: yes, the
autoscaler metric evaluation path
## Documentation
- Does this pull request introduce a new feature? yes
- If yes, how is the feature documented? docs & JavaDocs
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR,
please
change the checkbox below to `[X]` followed by the name of the tool, and
uncomment the
"Generated-by" line. See the ASF Generative Tooling Guidance for details:
https://www.apache.org/legal/generative-tooling.html
You are responsible for the quality and correctness of every change in this
PR
regardless of the tooling used. Low-effort AI-generated PRs will be closed.
See
AGENTS.md for the full guidance.
-->
- [X] Yes (please specify the tool below)
Generated-by: [Claude Opus 5]
--
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]