bobpaulin commented on code in PR #11872:
URL: https://github.com/apache/nifi/pull/11872#discussion_r4487014599


##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ConnectorResource.java:
##########
@@ -725,6 +732,36 @@ public Response updateRunStatus(
         );
     }
 
+    /**
+     * Each node verifies a START against its own Connector only, so the 
merged Connector entity is consulted to reject a START
+     * while the nodes load different Connector versions.
+     */
+    private void verifyClusterLoadsSameBundle() {
+        final URI runStatusUri = getAbsolutePath();
+        final String runStatusPath = runStatusUri.getPath();
+        final URI connectorUri = 
UriBuilder.fromUri(runStatusUri).replacePath(runStatusPath.substring(0, 
runStatusPath.lastIndexOf('/'))).build();
+
+        final NodeResponse nodeResponse;
+        try {
+            nodeResponse = replicateNodeResponse(connectorUri, HttpMethod.GET, 
new MultivaluedHashMap<>(), null);
+        } catch (final InterruptedException e) {
+            Thread.currentThread().interrupt();
+            throw new IllegalStateException("Interrupted while verifying the 
Connector version on each cluster node", e);
+        }
+
+        if (!(nodeResponse.getUpdatedEntity() instanceof final ConnectorEntity 
connectorEntity) || connectorEntity.getComponent() == null
+                || connectorEntity.getComponent().getAvailableActions() == 
null) {
+            return;
+        }
+
+        for (final ConnectorActionDTO action : 
connectorEntity.getComponent().getAvailableActions()) {
+            final String reason = action.getReasonNotAllowed();
+            if (reason != null && 
reason.startsWith(ConnectorEntityMerger.LOADED_BUNDLE_MISMATCH_REASON)) {

Review Comment:
   Agree we can do better here.  A boolean is better than the string matching 
but I do not see how this would remove the GET request.  We could potentially 
issue the expected bundle version on the PUT so that each node can verify the 
version they're starting matches.  Then we could remove the extra GET and the 
bundle versions would be compared via a string match but an exact match rather 
than matching on reason text.



-- 
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]

Reply via email to