bbende opened a new pull request, #11965: URL: https://github.com/apache/nifi/pull/11965
<!-- Licensed to the Apache Software Foundation (ASF) under one or more --> <!-- contributor license agreements. See the NOTICE file distributed with --> <!-- this work for additional information regarding copyright ownership. --> <!-- The ASF licenses this file to You under the Apache License, Version 2.0 --> <!-- (the "License"); you may not use this file except in compliance with --> <!-- the License. You may obtain a copy of the License at --> <!-- http://www.apache.org/licenses/LICENSE-2.0 --> <!-- Unless required by applicable law or agreed to in writing, software --> <!-- distributed under the License is distributed on an "AS IS" BASIS, --> <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> <!-- See the License for the specific language governing permissions and --> <!-- limitations under the License. --> # Summary [NIFI-16629](https://issues.apache.org/jira/browse/NIFI-16629) When a node becomes Cluster Coordinator but a different node's flow wins the flow election, the coordinator loads a flow that references parameter context assets and connector assets it does not have. Asset synchronization was skipped entirely on the coordinator, so components referencing those assets stayed invalid until the assets were manually re-uploaded or the node was restarted after another node became coordinator. Non-coordinator nodes could also fail with a `NullPointerException` when the coordinator reported an asset with missing content. This change makes the coordinator fetch missing assets from the nodes whose flow was elected: - `FlowElection` and `ClusterCoordinator` expose `getElectedFlowNodeIdentifiers()`, the nodes that voted for the elected flow. `PopularVoteFlowElection` records them when the election completes. No cluster protocol changes are needed, because the coordinator reads them from its own in-memory election. - `StandardAssetSynchronizer` and `StandardConnectorAssetSynchronizer` keep skipping synchronization when the coordinator voted for the elected flow. Otherwise they list assets from each elected-flow node in a fixed order and download only the content missing locally. They never overwrite a file the coordinator already has, and they then restart the components that reference the synchronized assets. A source that rejects or times out the listing request is retried within the existing retry window, then skipped in favor of the next source. - On non-coordinator nodes, if the coordinator reports missing content for an asset that exists locally, the local file is kept and a warning is logged instead of throwing a `NullPointerException`. - `ParameterContextResource` and `ConnectorResource` asset listing endpoints answer replicated requests sent directly from a cluster node before the local flow is initialized. Otherwise the coordinator and the elected-flow node wait on each other during startup: each returns HTTP 409 until it finishes initializing, and both retry until timing out. Authorization is unchanged and still runs first. The shortcut only applies when the request carries the replicated header and comes from a cluster node identity verified by client certificate. NAR synchronization in `StandardNarManager` has the same coordinator skip and is out of scope for this PR. ### Testing - New system test `ClusteredAssetCoordinatorElectionIT` restarts a two-node cluster where node 1 becomes coordinator with an empty flow and no assets. It verifies that node 1 restores parameter context assets and connector assets from node 2 with identical bytes and the original asset ids, and that the referencing processor and connector become valid. - Strengthened `TestPopularVoteFlowElection`, `TestNodeClusterCoordinator`, and `TestConnectorResource` to cover elected voter tracking, coordinator delegation, and serving cluster-node asset listings without consulting replication state. - Regression: `ClusteredParameterContextIT`, `ClusteredConnectorAssetsIT`, `JoinClusterWithDifferentFlowIT`, and `TestStandardFlowService` pass. # Tracking Please complete the following tracking steps prior to pull request creation. ### Issue Tracking - [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created ### Pull Request Tracking - Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000` - Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000` - Pull request contains [commits signed](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) with a registered key indicating `Verified` status ### Pull Request Formatting - Pull Request based on current revision of the `main` branch - Pull Request refers to a feature branch with one commit containing changes # Verification Please indicate the verification steps performed prior to pull request creation. ### Build - [X] Build completed using `./mvnw clean install -P contrib-check` - [X] JDK 21 - [X] JDK 25 ### Licensing - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html) - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files ### Documentation - [ ] Documentation formatting appears as expected in rendered files -- 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]
