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


##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java:
##########
@@ -3870,11 +3892,17 @@ public ConnectorEntity scheduleConnector(final Revision 
revision, final String i
 
         final RevisionUpdate<ConnectorDTO> snapshot = 
revisionManager.updateRevision(claim, user, () -> {
             switch (state) {
-                case RUNNING -> connectorDAO.startConnector(id);
+                case RUNNING -> connectorDAO.startConnector(id, 
controllerFacade::saveImmediate);
                 case STOPPED -> connectorDAO.stopConnector(id);
                 default -> throw new IllegalArgumentException("Unsupported 
scheduled state for Connector: " + state);
             }
-            controllerFacade.save();
+            // Evolution sets the desired state to RUNNING as soon as it is 
claimed so a joining node starts too.
+            // Persisting that state before the hook succeeds makes a failed 
evolution auto-start on restart.
+            // The repository saves once the upgraded flow is applied, and a 
failed evolution puts the desired state back.
+            final ConnectorNode scheduled = connectorDAO.getConnector(id, 
ConnectorSyncMode.LOCAL_ONLY);
+            if (scheduled.getCurrentState() != ConnectorState.DRAINING || 
!scheduled.isPendingFlowEvolution()) {

Review Comment:
   [Claude Opus 5.5] Agreed. I removed the special case, so RUNNING is always 
saved when the upgrade begins, and a restart during the drain resumes it. 
testRestartKeepsPendingUpgrades covers this. I left the failure path unsaved: 
shutdown also interrupts the drain, and saving that failure would record 
STOPPED and stop the upgrade from resuming. The developer guide now says this.



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