Matt Gilman created NIFI-16442:
----------------------------------

             Summary: Apply connector property migration when a configuration 
provider document is loaded
                 Key: NIFI-16442
                 URL: https://issues.apache.org/jira/browse/NIFI-16442
             Project: Apache NiFi
          Issue Type: Bug
          Components: Core Framework
            Reporter: Matt Gilman
            Assignee: Matt Gilman


When a ConnectorConfigurationProvider is configured, a connector property 
migration does not survive the provider document.

Connector.migrateProperties runs while inheriting or reloading a connector and 
updates the in-memory working configuration. The provider document is left 
unchanged. The next provider load installs that document through 
replaceWorkingConfiguration without running migrateProperties. 
Configuration-step verification syncs from the provider first, so the obsolete 
property name is present when AbstractConnector validates the step:

Property '<old property name>' is not defined by the Connector for 
Configuration Step '<step name>'

On an individual configuration step, that failure is easy to miss because the 
result subject is the old property name and does not match a current 
descriptor. Verifying the full configuration reports it.

Reads and writes need to stay separate. ConnectorConfigurationProvider loads on 
read and saves on write. ConnectorSyncMode.SYNC_WITH_PROVIDER refreshes memory 
from the external store. A read must not save.

Expected behavior:

- When a provider document is loaded, including configuration-step verification 
and getConnector(SYNC_WITH_PROVIDER), migrate it in memory before installing 
it. Verification then sees the current property names. Do not call 
ConnectorConfigurationProvider.save from that path.
- During flow synchronization, when getSyncDirective supplies a working 
configuration, persist the migrated stored keys through the existing save. This 
follows notifyMigrationComplete: the framework originated the change, so the 
external document is updated. Do not persist required defaults that the 
framework applied because they were missing. Do not persist anything when the 
connector declares no configuration steps.
- Compare persisted forms when deciding whether the working configuration 
changed. A framework-applied required default must not make every later flow 
synchronization call inheritConfiguration.
- If the new property name is already present, renameProperty keeps that value 
and removes the old key.
- If save throws, catch it for that connector, inherit the migrated 
configuration in memory, and leave the provider document unchanged. 
VersionedFlowSynchronizer.inheritConnectors does not catch exceptions from 
syncConnector, so a thrown save must not abort the remaining connectors. The 
next flow synchronization tries the save again. Verification does not.

Tests:

- A provider document with a renamed property is installed under the new name, 
and the load does not call save.
- Flow synchronization calls save with the renamed document and without a 
framework-applied required default. A second synchronization of the same 
document does not call save, and it does not call inheritConfiguration only 
because memory contains that default.
- When both the old and new property names are present, the new name keeps its 
value.
- When save throws, syncConnector returns and a later synchronization calls 
save again.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to