Dennis-Mircea opened a new pull request, #1080:
URL: https://github.com/apache/flink-kubernetes-operator/pull/1080
…K8s resource spec for adaptive scheduler, ignoring JM running configuration
<!--
*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
`NativeFlinkService.supportsInPlaceScaling()` currently only inspects the
Kubernetes `FlinkDeployment` resource spec to determine whether the adaptive
scheduler is configured. If the adaptive scheduler is set through mechanisms
outside the K8s spec (such as Flink's native `flink-conf.yaml`, environment
variables, or command-line dynamic properties) the operator incorrectly
concludes that in-place scaling is not supported and falls back to a full
restart/redeploy cycle.
This PR adds a fallback path: when the K8s resource spec does not indicate
`jobmanager.scheduler: Adaptive`, the operator queries the JobManager's
**actual running configuration** via the `JobManagerJobConfigurationHeaders`
REST endpoint. If the JM confirms the adaptive scheduler is active, in-place
scaling proceeds normally.
## Brief change log
- **`NativeFlinkService.java`**
- Changed `supportsInPlaceScaling` from `static` to instance method
(needed for `getClusterClient` and `operatorConfig` access)
- Added JM REST configuration fallback when `observeConfig.get(SCHEDULER)`
is not `Adaptive`:
- Sends a `JobManagerJobConfigurationHeaders` request to the running JM
- Searches the response for the `jobmanager.scheduler` key
- Returns `true` only if the value equals `Adaptive`
- Graceful degradation: if the JM REST call fails (e.g., JM unreachable),
in-place scaling is denied
- The terminal/reconciling state check is correctly preserved - both the
K8s spec path and JM fallback path flow through to it (no early return on
success)
- Extracted `SCHEDULER` to a static import for readability
- Added imports: `ConfigurationInfoEntry`,
`JobManagerJobConfigurationHeaders`, `Optional`, `static SCHEDULER`
- **`NativeFlinkServiceTest.java`**
- Updated existing `testScaling` service setup to also override
`getClusterClient` (returns a `TestingClusterClient` configured to return
`Default` scheduler from JM config, so existing "do not scale without adaptive
scheduler" assertions remain valid)
- Added new `testScalingWithJmConfigFallback()` test with 5 cases:
1. **JM returns Adaptive** - scaling succeeds ✅
2. **JM returns Default** - scaling denied ❌
3. **JM REST throws exception** - scaling denied (graceful degradation) ❌
4. **JM returns Adaptive but job is FAILED** - scaling denied (terminal
state check is not skipped) ❌
5. **JM returns empty config (no scheduler key)** - scaling denied ❌
- Added imports: `ConfigurationInfo`, `ConfigurationInfoEntry`,
`EmptyResponseBody`, `JobManagerJobConfigurationHeaders`
## Verifying this change
This change is verified by the new `testScalingWithJmConfigFallback` test
which covers the complete matrix of fallback scenarios. Case 4 is the critical
regression test - it verifies that the terminal/reconciling state check is
never bypassed when the adaptive scheduler confirmation comes from the JM REST
fallback path rather than the K8s spec. All 10 tests in
`NativeFlinkServiceTest` pass.
## 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
--
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]