bobpaulin commented on code in PR #11872:
URL: https://github.com/apache/nifi/pull/11872#discussion_r4645426497
##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/registry/flow/mapping/VersionedComponentFlowMapper.java:
##########
@@ -1102,33 +1108,48 @@ private org.apache.nifi.flow.ScheduledState
mapScheduledState(final ScheduledSta
}
/**
- * Map the given ConnectorNode to a VersionedConnector. When the Connector
is in Troubleshooting state, the Connector's
- * Managed Process Group is also serialized into the VersionedConnector so
that any user modifications made while in
- * Troubleshooting mode survive a restart. The provided
ControllerServiceProvider is required for mapping the Managed
- * Process Group; if {@code null}, the Managed Process Group is not
serialized even if the Connector is in Troubleshooting.
+ * Map the given ConnectorNode to a VersionedConnector. The parameter
context, managed-flow bundle, and active
+ * configuration are written from the node's atomic snapshot. While the
connector is in Troubleshooting, the live
+ * managed group is written so the user's edits survive a restart;
otherwise the managed group comes from that
+ * snapshot. The provided ControllerServiceProvider is required for the
live mapping; if {@code null} while
+ * Troubleshooting, the managed group is omitted.
*
* @param connectorNode the connector node to map
- * @param controllerServiceProvider the controller service provider used
when mapping the Managed Process Group; may be null
+ * @param controllerServiceProvider the controller service provider used
when mapping the live Managed Process Group; may be null
* @return the mapped VersionedConnector
*/
public VersionedConnector mapConnector(final ConnectorNode connectorNode,
final ControllerServiceProvider controllerServiceProvider) {
final VersionedConnector versionedConnector = new VersionedConnector();
versionedConnector.setInstanceIdentifier(connectorNode.getIdentifier());
versionedConnector.setName(connectorNode.getName());
-
versionedConnector.setScheduledState(mapConnectorState(connectorNode.getDesiredState()));
+ versionedConnector.setScheduledState(mapConnectorState(connectorNode));
versionedConnector.setType(connectorNode.getCanonicalClassName());
+
+ final ConnectorFlowSnapshot authoritativeSnapshot =
connectorNode.getAuthoritativeFlowSnapshot();
+ final FrameworkFlowContext activeFlowContext =
connectorNode.getActiveFlowContext();
versionedConnector.setBundle(mapBundle(connectorNode.getBundleCoordinate()));
- final List<VersionedConfigurationStep> activeFlowConfiguration =
createVersionedConfigurationSteps(connectorNode.getActiveFlowContext());
+ final ConnectorConfiguration activeConfiguration =
authoritativeSnapshot == null
+ ?
activeFlowContext.getConfigurationContext().toConnectorConfiguration()
+ : authoritativeSnapshot.activeConfiguration();
Review Comment:
[Claude Opus 5.5] Confirmed, thanks for the detailed reproduction. I first
changed the tests to show the problem.
testCommitMigratedConfigurationWritesMergedConfigurationOntoActive now asserts
that the authoritative snapshot holds the migrated configuration after commit,
and it failed with the pre-migration value.
testMigrateActionStaysDisallowedAfterMigrationAndAcrossRestart now restarts
once before migrating and checks that the migrated processor is still in the
managed flow after the final restart. The processor was present right after the
migration and gone after the restart.
commitMigratedConfiguration now replaces the active configuration with the
merged configuration and then captures a fresh snapshot, so the next flow save
writes the migrated configuration and managed flow. If the capture fails, the
pre-migration active configuration is restored before the exception reaches the
migration manager, so its rollback still leaves the Connector consistent. Both
tests pass now, along with the rest of ConnectorVersionedFlowMigrationIT and
ConnectorVersionedFlowMigrationRestartIT.
--
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]