bobpaulin commented on code in PR #11872:
URL: https://github.com/apache/nifi/pull/11872#discussion_r4556311588
##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java:
##########
@@ -4060,13 +4065,13 @@ public void restoreFlowPreservingIdentifiers(final
VersionedExternalFlow propose
// the live component is the encrypted payload rather than the
plaintext (or parameter reference) originally captured.
final FlowMappingOptions flowMappingOptions = new
FlowMappingOptions.Builder()
Review Comment:
[Claude Opus 5.5] Now uses `FlowMappingOptions.forPersistedFlow`. Those are
the same options `VersionedDataflowMapper` uses to write the flow, so
controller service references are restored the same way they're persisted. The
Troubleshooting restore across a restart is covered by
`ConnectorTroubleshootingIT`, including
`testProcessorsInTroubleshootingStillRunningAfterRestart`.
[Bob] I added a test here but I'd still be interested in a more targeted
review from you on these options.
This is what the agent said to explain the change
[Claude Opus 5.5]
In synchronizeFlow, these options control how the current group is turned
into a versioned flow before it is compared with the proposed snapshot. That
snapshot is always a persisted flow here. If the two sides are mapped
differently, unchanged values look different, and the synchronizer writes the
wrong value back.
On main, the method used registry-export settings for the last four options.
Each change fixes a mismatch:
mapControllerServiceReferencesToVersionedId: true → false. With true, every
property that references a controller service is rewritten from the service's
instance ID to its versioned ID. A persisted flow stores instance IDs, and this
restore uses instance IDs as runtime IDs, so every service reference looked
changed. With true, the synchronizer also rewrites parameter values that
reference a service from versioned ID back to instance ID
(StandardVersionedComponentSynchronizer around line 632), which is wrong for
values that are already instance IDs.
VersionedComponentFlowMapper.java
Ln 619–625
if (value != null && property.getControllerServiceDefinition() != null &&
flowMappingOptions.isMapControllerServiceReferencesToVersionedId()) {
// Property references a Controller Service. Instead of storing the
existing value, we want
// to store the Versioned Component ID of the service.
final ControllerServiceNode controllerService =
serviceProvider.getControllerServiceNode(value);
if (controllerService != null) {
value = getId(controllerService.getVersionedComponentId(),
controllerService.getIdentifier());
}
mapAssetReferences: false → true. With false, a parameter that references
assets is mapped with neither a value nor asset references (line 1099). The
persisted snapshot keeps those references, so asset-backed parameters looked
changed and could be restored wrong. StandardProcessGroup passes an
assetManager to the sync context (line 4250), which true requires.
mapFlowRegistryClientId: false → true. A persisted flow records the registry
client ID for versioned child groups, so the current side has to record it too.
mapPropertyDescriptors: true → false. A persisted flow does not include
property descriptors. Leaving them out avoids extra mapping work and
descriptor-only differences.
mapSensitiveConfiguration(true) with the property encryption provider was
already on main, and the comment above the builder explains it: the snapshot's
sensitive values are encrypted, so the current side has to be encrypted the
same way. The four changed options finish that alignment.
The only production callers are StandardFlowContext.restorePersistedFlow
(both overloads) at StandardFlowContext.java lines 124 and 135, which restore
connector snapshots and pre-upgrade flows. That is why the options were matched
to forPersistedFlow.
--
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]