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

   # Summary
   
   NIFI-14995 - Improve Flow Differences Filter to account for renameProperty 
and createControllerService
   
   As we use more and more the `migrateProperties` capabilities, we see that we 
have some corner cases where the automated changes are showing as local changes 
which is confusing because a user is upgrading without making any changes to 
their versioned flows and the UI is showing that some local modifications have 
been made. Such scenarios should be better handled to not show local changes.
   
   One scenario has been handled in 
[NIFI-14985](https://issues.apache.org/jira/browse/NIFI-14985) to better deal 
with removed properties.
   
   This change is to handle two additional scenarios (this is combined in a 
single PR because of the approach taken that is introducing a concept of 
environmental context)
   
   ### Rename property with parameters
   
   Let's consider a processor version N with
   
   ````java
       public static final PropertyDescriptor ACCESS_KEY_ID = new 
PropertyDescriptor.Builder()
           .name("Access Key")
           .displayName("Access Key ID")
           .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
           .required(false)
           .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
           .sensitive(true)
           .build();
   ````
   
   And then version N+1 with
   
   ````java
       public static final PropertyDescriptor ACCESS_KEY_ID = new 
PropertyDescriptor.Builder()
           .name("Access Key ID")
           .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
           .required(false)
           .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
           .sensitive(true)
           .build();
   ...
       public void migrateProperties(PropertyConfiguration config) {
           config.renameProperty("Access Key", ACCESS_KEY_ID.getName());
       }
   ````
   
   If the versioned flow is containing:
   
   ````json
          "groupIdentifier" : "flow-contents-group",
          "identifier" : "8de3b31b-0a70-3e01-a01c-4ed2fe3a4cbe",
          "name" : "AWS Credentials Provider",
          "properties" : {
            "Access Key" : "#{AWS Access Key ID}",
            "default-credentials" : "false",
            "Session Time" : "3600",
            "assume-role-sts-signer-override" : "Default Signature",
            "assume-role-sts-region" : "us-west-2",
            "Secret Key" : "#{AWS Secret Access Key}",
            "anonymous-credentials" : "false"
          }, 
   ````
   
   Then we would show two local changes:
   - Property Parameterization Removed - Property 'Access Key ID' is no longer 
a parameter reference
   - Property Parameterized - Property 'Access Key ID' was parameterized
   
   We should not be showing this as local changes.
   
   ### Create Controller Service
   
   When using something like:
   
   ````java
        @Override
        public void migrateProperties(final PropertyConfiguration config) {
            if (!config.isPropertySet(ABC.getName())) {
                final String serviceId = config.createControllerService(
                        "org.apache.nifi.foo",
                        Map.of());
                config.setProperty(ABC, serviceId);
            }
            super.migrateProperties(config);
        } 
   ````
   
   Then we would be showing two local changes:
   - Property Added: the property ABC has been added
   - Component Created: a controller service has been created
   
   We should check that if the property being added is not a dynamic property, 
and is referencing the UUID of the created controller service, then both 
changes should not be showing as local changes.
   
   ### Approach
   
   Introducing a richer `EnvironmentalChangeContext` that is reused across all 
comparisons. This is how we can link a couple of differences as related to the 
same change and decide to filter out the differences or not.
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [ ] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue 
created
   
   ### Pull Request Tracking
   
   - [ ] Pull Request title starts with Apache NiFi Jira issue number, such as 
`NIFI-00000`
   - [ ] Pull Request commit message starts with Apache NiFi Jira issue number, 
as such `NIFI-00000`
   
   ### Pull Request Formatting
   
   - [ ] Pull Request based on current revision of the `main` branch
   - [ ] Pull Request refers to a feature branch with one commit containing 
changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request 
creation.
   
   ### Build
   
   - [ ] Build completed using `./mvnw clean install -P contrib-check`
     - [ ] JDK 21
     - [ ] JDK 25
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 
2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License 
Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` 
files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


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