mattcasters opened a new pull request, #11645:
URL: https://github.com/apache/nifi/pull/11645

   # Summary
   
   [NIFI-16318](https://issues.apache.org/jira/browse/NIFI-16318)
   
   Importing a versioned flow with **Keep existing Parameter Contexts** checked 
still mutated the matched live Parameter Context. When another running flow 
referenced those parameters through an ENABLED Controller Service, import 
failed:
   
   ```
   Cannot update parameter 'impala_driver_class' because it is referenced by
   StandardControllerServiceNode[..., name=Impala_BDA2PRD_ConnectionPool, 
active=true],
   which currently has a state of ENABLED
   ```
   
   When those components were stopped, import succeeded and **overwrote** the 
live parameter with the value from the registry.
   
   ## Root cause
   
   Keep existing Parameter Contexts was implemented only as a rename switch in 
`ProcessGroupResource`. `REPLACE` suffixes snapshot context names (`P` → `P 
(1)`). `KEEP_EXISTING` leaves names unchanged so they match live contexts.
   
   The snapshot then went through `updateProcessGroupContents` → 
`StandardProcessGroup.updateFlow` → 
`StandardVersionedComponentSynchronizer.addMissingConfiguration` with **no 
knowledge** of KEEP_EXISTING vs REPLACE. That merge:
   
   1. Treated existence using `getParameter()` (effective + resolved aliases).
   2. Wrote the result as a **local** parameter, which could materialize a 
local override for an inherited name.
   3. If the name was not found on the context being updated, it called 
`createParameter()` with the **registry value**.
   4. Always called `setParameters`, even for description-only maps.
   
   `StandardParameterContext.verifyCanSetParameters` then compared updates 
against the **local** map. An inherited name looked like a new parameter 
(`current == null`), so `isRuntimeAffectingChange` returned true. 
`referencesParameterContext` includes groups that inherit the context, so an 
ENABLED Controller Service in another flow blocked the import.
   
   Once referencing services were disabled, `setParameters` succeeded and wrote 
the snapshot value onto the live context.
   
   ## Fix
   
   - Thread `preserveExistingParameterContextEntries` from KEEP_EXISTING import 
into `FlowSynchronizationOptions`.
   - In `addMissingConfiguration`:
     - Never overwrite an existing **local** value.
     - Skip description updates on KEEP_EXISTING import (version upgrades still 
apply description-only updates from the local raw parameter).
     - Do not materialize a local override for a parameter that already exists 
via inheritance (`getRawEffectiveParameters()`).
     - Still add parameters that are absent from the effective set.
     - Call `setParameters` only when there is something to add or update.
   - Validate parameter updates against **effective** parameters so inherited 
names and aliases are not treated as runtime-affecting adds.
   
   REPLACE is unchanged: snapshot contexts are renamed, then created from the 
snapshot.
   
   # Tracking
   
   - Apache NiFi Jira issue: NIFI-16318
   - Pull Request title starts with NIFI-16318
   - Pull Request commit message starts with NIFI-16318
   - Single signed commit on a feature branch from current `main`
   
   # Verification
   
   - CheckStyle: `./mvnw -pl 
nifi-framework-bundle/nifi-framework/nifi-framework-core-api,nifi-framework-bundle/nifi-framework/nifi-framework-components,nifi-framework-bundle/nifi-framework/nifi-framework-core,nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api,nifi-system-tests/nifi-system-test-suite
 -am checkstyle:check`
   - Unit tests: `StandardVersionedComponentSynchronizerTest`, 
`TestStandardParameterContext`
   - System tests added in `ParameterContextPreservationIT` (KEEP_EXISTING 
import with an ENABLED referencing Controller Service, and inherited-parameter 
override)


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