Skip to content

NIFI-16333 - Bypass Secrets Manager cache when a connector starts - #11663

Open
pvillard31 wants to merge 3 commits into
apache:mainfrom
pvillard31:NIFI-16333
Open

NIFI-16333 - Bypass Secrets Manager cache when a connector starts#11663
pvillard31 wants to merge 3 commits into
apache:mainfrom
pvillard31:NIFI-16333

Conversation

@pvillard31

Copy link
Copy Markdown
Contributor

Summary

NIFI-16333 - Bypass Secrets Manager cache when a connector starts

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

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 contains commits signed with a registered key indicating Verified status

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 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

@pvillard31
pvillard31 requested a review from markap14 September 10, 2026 13:15

@exceptionfactory exceptionfactory left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adjusting this behavior @pvillard31, this sounds reasonable for Connector starting. The general approach looks good, I noted a couple minor recommendations


final StartRecordingSecretConnector connector = new StartRecordingSecretConnector();
final StandardConnectorNode connectorNode = createConnectorNode(connector, secretsManager);
seedActiveConfiguration(connectorNode, "requiredStep", Map.of("RequiredSecret", secretReference));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requiredStep and RequiredSecret string literals are repeated here and in the Connector class, they should be moved to static final variables.

connectorNode.start(scheduler).get(5, TimeUnit.SECONDS);
connectorNode.start(scheduler).get(5, TimeUnit.SECONDS);

assertEquals(List.of("first", "second"), connector.getStartedSecrets());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first and second strings are repeated and should be declared once and reused.

* @implSpec Implementations that cache Secret values must override this method to honor {@code useCache}.
* @param useCache whether cached Secret values may be used
*/
default void resolvePropertyValues(final boolean useCache) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it is more verbose, I recommend creating an enum named something like CacheResolution with values of ENABLED and DISABLED to start with. That should make the behavior more readable, and provide the option for future extension.

}

try (final NarCloseable ignored = NarCloseable.withComponentNarLoader(extensionManager, connectorDetails.getConnector().getClass(), getIdentifier())) {
activeFlowContext.getConfigurationContext().resolvePropertyValues(false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this introduce a potential issue where we would call resolvePropertyValues(false); and then later call resolvePropertyValues(true) such that the latter call would resolve values using a stale cache, whereas this call used newer versions?

If so, would it make sense to just simply call invalidateCache() instead? Then there'd be no need to introduce a new override to resolvePropertyValues...

@pvillard31

Copy link
Copy Markdown
Contributor Author

Thanks @markap14 - this is a good idea and I followed your recommendation, this makes it cleaner. Thanks for the review @exceptionfactory.

@markap14 markap14 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pvillard31 this looks simpler and more straight-forward. +1 from me. @exceptionfactory any other concerns or shall we merge (pending successful CI checks)?

@pvillard31

Copy link
Copy Markdown
Contributor Author

rebased and fixed merge conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants