pvillard31 commented on code in PR #11399:
URL: https://github.com/apache/nifi/pull/11399#discussion_r3641108853


##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/connector/StandardConnectorNode.java:
##########
@@ -378,41 +380,71 @@ public void inheritConfiguration(final 
List<VersionedConfigurationStep> activeCo
                 final Bundle flowContextBundle) throws FlowUpdateException {
 
         logger.debug("Inheriting configuration for {}", this);
-        final MutableConnectorConfigurationContext configurationContext = 
createConfigurationContext(activeConfig);
+
+        // Give the Connector a chance to evolve its persisted property/step 
names before we build the runtime
+        // configuration contexts. Active and working configs are migrated 
independently because they can diverge.
+        final Map<String, Map<String, ConnectorValueReference>> 
migratedActiveProperties = migrateProperties(activeConfig);
+        final Map<String, Map<String, ConnectorValueReference>> 
migratedWorkingProperties = migrateProperties(workingConfig);
+
+        final MutableConnectorConfigurationContext activeSeedContext = 
createConfigurationContext(migratedActiveProperties);
         final FrameworkFlowContext inheritContext = 
flowContextFactory.createWorkingFlowContext(identifier,
-            connectorDetails.getComponentLog(), configurationContext, 
flowContextBundle);
+            connectorDetails.getComponentLog(), activeSeedContext, 
flowContextBundle);
 
-        // Apply the update for the active config
+        // Apply the active configuration. This restores activeFlowContext to 
migratedActiveProperties and internally
+        // rebuilds workingFlowContext aliased to activeFlowContext's 
configuration; we discard that alias below and
+        // construct an independent working context so active and working do 
not share configuration state when the
+        // two lists actually diverge.
         applyUpdate(inheritContext);
 
-        // Configure the working config but do not apply
-        for (final VersionedConfigurationStep step : workingConfig) {
-            final StepConfiguration stepConfig = createStepConfiguration(step);
-            setConfiguration(step.getName(), stepConfig, true);
+        // Tear down the working context that applyUpdate created aliased to 
active, and rebuild it around an
+        // independent configuration seeded from migratedWorkingProperties. 
Then fire onConfigurationStepConfigured
+        // for every step so renamed steps trigger the flow-builder callback 
under their new name and any
+        // value-derived flow state (resolved asset paths, secret values, 
etc.) is populated against the fresh
+        // working context.
+        destroyWorkingContext();

Review Comment:
   Could the PR description mention that inheritConfiguration now rebuilds the 
working context independently from active rather than layering working config 
onto an active-derived clone, since this affects every Connector on restart, 
not only ones that implement migrateProperties?



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