Skip to content

Conversation

bentsherman
Copy link
Member

Fix #5494 #5943

This PR fixes support for plugin secrets (i.e. AWS secrets) in the config by loading the config before resolving plugins. If the config attempts to use secrets, it will be reloaded with the complete set of secrets providers.

This is possible because plugin config must be static, unlike other config which can be dynamic and reference secrets. Therefore, we can simply load the config to extract the list of plugins (and other config settings like tower.enabled and process.executor which can trigger additional core plugins.

To minimize the impact of loading the config twice, we only reload the config if we detect that secrets were used by the config on the first load. This way, the double config load should only affect users who want to use secrets in the config.

In summary:

  1. Load config with "shim" secrets provider which only tracks whether secrets are used by config
  2. Load plugins
  3. Load secrets provider
  4. Reload config if secrets were used in config

Copy link

netlify bot commented Jul 3, 2025

Deploy Preview for nextflow-docs-staging ready!

Name Link
🔨 Latest commit 0ba2507
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/6894e99e3a39640008aec646
😎 Deploy Preview https://deploy-preview-6249--nextflow-docs-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@bentsherman bentsherman linked an issue Jul 3, 2025 that may be closed by this pull request
@bentsherman
Copy link
Member Author

Here is how I've been testing:

  1. Build with make pack
  2. Upload dist binary to s3
  3. Launch this pipeline in platform: https://github.com/bentsherman/nf-tests/tree/plugin-secrets
  4. Download dist binary from s3 and replace default nextflow in pre-run script

However, it's not loading the xpack-amzn plugin:

Jul-03 19:06:49.448 [main] DEBUG nextflow.plugin.PluginsFacade - Plugins resolved requirement=[[email protected], [email protected], [email protected], [email protected]]

It's at least loading nf-amazon since the workDir is s3, but I can't remember how to trigger the xpack plugin

@bentsherman
Copy link
Member Author

I wonder if the issue is that I'm using the dist release instead of the standard release

@pditommaso pditommaso marked this pull request as draft July 6, 2025 13:34
Copy link
Member

@pditommaso pditommaso left a comment

Choose a reason for hiding this comment

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

This looks smart. Moving to draft until the problem with the plugins is addressed. Also unit test and integration test should be added (it may be convenience setup a test GH repo for this)

@bentsherman bentsherman marked this pull request as ready for review July 7, 2025 16:49
@bentsherman
Copy link
Member Author

It turns out the issue was that I was using the single-VM CE, which doesn't support AWS secrets. It works with AWS Batch.

Regarding testing, I don't think we'll need a git repo unless you want to do an e2e test with platform. I'll add a local e2e test that just tests the detection of config secrets -> config reloading.

@bentsherman
Copy link
Member Author

One minor issue with this double-loading approach is that you can't use secrets in a config include (#5312). On the first load, the secret will be null and the include will likely fail, which means the run will fail

However, you should be able to work around this using a dynamic include:

includeConfig secrets.GITHUB_TOKEN
    ? "https://raw.githubusercontent.com/markpanganiban/nf-test/master/ubuntu.config?token=${secrets.GITHUB_TOKEN}"
    : '/dev/null'

On the first load, it will access the secret, triggering a reload, but won't attempt to include the secured config. On the second load it will include the config.

I will add this to the docs on config secrets

@bentsherman bentsherman force-pushed the fix-plugin-secrets-config branch from e8f25b9 to 5d5ef8a Compare July 7, 2025 17:39
@bentsherman bentsherman requested a review from a team as a code owner July 7, 2025 17:39
@bentsherman bentsherman force-pushed the fix-plugin-secrets-config branch from 5d5ef8a to f03a097 Compare July 10, 2025 17:18
@bentsherman
Copy link
Member Author

The e2e test that I added is failing in GitHub, but not sure why because it works for me locally

@bentsherman bentsherman linked an issue Jul 10, 2025 that may be closed by this pull request
@bentsherman bentsherman requested a review from pditommaso July 14, 2025 14:12
@bentsherman bentsherman added this to the 25.10 milestone Jul 14, 2025
@pditommaso

This comment was marked as resolved.

@bentsherman

This comment was marked as resolved.

@bentsherman bentsherman force-pushed the fix-plugin-secrets-config branch from dd8a536 to 3cb54c2 Compare July 17, 2025 22:29
@bentsherman bentsherman force-pushed the fix-plugin-secrets-config branch from 3cb54c2 to 2012d05 Compare July 28, 2025 15:29
Signed-off-by: Ben Sherman <[email protected]>
@bentsherman bentsherman force-pushed the fix-plugin-secrets-config branch from 2012d05 to 0ba2507 Compare August 7, 2025 17:59
Copy link
Collaborator

@christopher-hakkaart christopher-hakkaart left a comment

Choose a reason for hiding this comment

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

Some very minor suggestions. Feel free to ignore if the meaning changes.

@@ -13,6 +13,8 @@ This feature allows you to decouple the use of secrets in your pipelines from th

When a pipeline is launched, Nextflow injects the secrets into the run without leaking them into temporary execution files. Secrets are provided to tasks as environment variables.

Secrets can be used with the local executor and the grid executors (e.g., Slurm or Grid Engine). Secrets can be used with the AWS Batch executor when launched from [Seqera Platform](https://seqera.io/blog/pipeline-secrets-secure-handling-of-sensitive-information-in-tower/).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Secrets can be used with the local executor and the grid executors (e.g., Slurm or Grid Engine). Secrets can be used with the AWS Batch executor when launched from [Seqera Platform](https://seqera.io/blog/pipeline-secrets-secure-handling-of-sensitive-information-in-tower/).
Secrets can be used with the local executor and grid executors (e.g., Slurm or Grid Engine). Secrets can be used with the AWS Batch executor when launched from [Seqera Platform](https://seqera.io/blog/pipeline-secrets-secure-handling-of-sensitive-information-in-tower/).

@@ -45,9 +47,32 @@ aws {
The above snippet accesses the secrets `MY_ACCESS_KEY` and `MY_SECRET_KEY` and assigns them to the corresponding AWS config settings.

:::{warning}
Secrets cannot be assigned to pipeline parameters.
Secrets should not be assigned to pipeline parameters, as they can be easily leaked by the pipeline.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Secrets should not be assigned to pipeline parameters, as they can be easily leaked by the pipeline.
Secrets should not be assigned to pipeline parameters, as they can be leaked by the pipeline.

Highly optional suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants