-
Notifications
You must be signed in to change notification settings - Fork 611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: fix dockerfile secrets in modules by making secret pure #8049
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This fixes the use case in the docs (pending docs fix that I'll submit). 👍 |
The use case of: 1. Building Dockerfiles via the `Container.build` or `Directory.dockerBuild` APIs 2. That have secrets attached 3. That were created by modules and returned as `Container` values Appears to have been broken for a while. Before the secret isolation in v0.12.1, it was broken because these returned Dockerfiles were re-evaulated when the core ID was loaded after the function returned but the accessor was calculated again based on the *caller*, which resulted in a different secret value and thus missing secrets when the Dockerfile evaluation got unlazied. After v0.12.1, the error changed to be a bit earlier, but still happened as the core ID for the returned Dockerfile build was being loaded. It now was happening because the `Container.build` implementation synchronously looked up secrets before they had been identified and passed from the function call client to the caller's secret store. The fix here is deceptively simple: just don't mark `secret` as impure anymore. It's no longer necessary to do this because of the changes made in v0.12.1. Whereas previously `secret` actually looked up and calculated the accessor in some codepaths, it now just returns a static value based purely on the inputs. The reason this fixes the issue is a bit subtle and honestly might be a bit shaky; worth more thought. It's because when secret is pure, the whole `dockerBuild` API doesn't get cache invalidated and thus allows loading the return value to rely on dagql caching and skip the part where we were synchronously trying to find secrets that weren't loaded yet. Instead what happens now is the value gets loaded but returned from the cache, which allows the passing of secrets from the function call client to the caller to happen. Then when the Dockerfile-built Container is evaluated, the secrets will indeed be there. Signed-off-by: Erik Sipsma <erik@sipsma.dev>
sipsma
force-pushed
the
dockerfile-secrets
branch
from
July 30, 2024 06:49
0737a35
to
5bc5e7f
Compare
jedevc
approved these changes
Jul 30, 2024
helderco
approved these changes
Jul 30, 2024
renovate bot
referenced
this pull request
in scottames/daggerverse
Aug 2, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [dagger/dagger](https://togithub.com/dagger/dagger) | patch | `v0.12.3` -> `v0.12.4` | --- ### Release Notes <details> <summary>dagger/dagger (dagger/dagger)</summary> ### [`v0.12.4`](https://togithub.com/dagger/dagger/blob/HEAD/CHANGELOG.md#v0124---2024-08-01) [Compare Source](https://togithub.com/dagger/dagger/compare/v0.12.3...v0.12.4) ##### Changed - Deprecate old `pipeline` APIs by [@​jedevc](https://togithub.com/jedevc) in [https://github.com/dagger/dagger/pull/8064](https://togithub.com/dagger/dagger/pull/8064) \ These operations have been no-ops since v0.11.0, and will be removed in v0.13.0. ##### Fixed - Fix errors when using Dockerfile builds from module functions that have secrets by [@​sipsma](https://togithub.com/sipsma) in [https://github.com/dagger/dagger/pull/8049](https://togithub.com/dagger/dagger/pull/8049) - Fix dagger `terminal` prompt with debian-based images by [@​vmaffet](https://togithub.com/vmaffet) in [https://github.com/dagger/dagger/pull/7960](https://togithub.com/dagger/dagger/pull/7960) - Fix occasional leaks in secret scrubbing algorithm by [@​jedevc](https://togithub.com/jedevc) in [https://github.com/dagger/dagger/pull/8047](https://togithub.com/dagger/dagger/pull/8047) - Fix frequent context switches in `--progress=plain` output by [@​jedevc](https://togithub.com/jedevc) in [https://github.com/dagger/dagger/pull/7956](https://togithub.com/dagger/dagger/pull/7956) - Extend multi git server support to Azure devOps by [@​grouville](https://togithub.com/grouville) in [https://github.com/dagger/dagger/pull/8063](https://togithub.com/dagger/dagger/pull/8063) \ Our support for Azure refs was broken on monorepos. We special-case Azure DevOps since it doesn't work with the go standard convention of discovering the root of a git repository ##### What to do next? - Read the [documentation](https://docs.dagger.io) - Join our [Discord server](https://discord.gg/dagger-io) - Follow us on [Twitter](https://twitter.com/dagger_io) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 4pm on thursday" in timezone America/Los_Angeles, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/scottames/daggerverse). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: scottames-github-bot[bot] <162828115+scottames-github-bot[bot]@users.noreply.github.com>
scottames
referenced
this pull request
in scottames/containers
Aug 2, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [dagger/dagger](https://togithub.com/dagger/dagger) | patch | `v0.12.3` -> `v0.12.4` | --- ### Release Notes <details> <summary>dagger/dagger (dagger/dagger)</summary> ### [`v0.12.4`](https://togithub.com/dagger/dagger/blob/HEAD/CHANGELOG.md#v0124---2024-08-01) [Compare Source](https://togithub.com/dagger/dagger/compare/v0.12.3...v0.12.4) ##### Changed - Deprecate old `pipeline` APIs by [@​jedevc](https://togithub.com/jedevc) in [https://github.com/dagger/dagger/pull/8064](https://togithub.com/dagger/dagger/pull/8064) \ These operations have been no-ops since v0.11.0, and will be removed in v0.13.0. ##### Fixed - Fix errors when using Dockerfile builds from module functions that have secrets by [@​sipsma](https://togithub.com/sipsma) in [https://github.com/dagger/dagger/pull/8049](https://togithub.com/dagger/dagger/pull/8049) - Fix dagger `terminal` prompt with debian-based images by [@​vmaffet](https://togithub.com/vmaffet) in [https://github.com/dagger/dagger/pull/7960](https://togithub.com/dagger/dagger/pull/7960) - Fix occasional leaks in secret scrubbing algorithm by [@​jedevc](https://togithub.com/jedevc) in [https://github.com/dagger/dagger/pull/8047](https://togithub.com/dagger/dagger/pull/8047) - Fix frequent context switches in `--progress=plain` output by [@​jedevc](https://togithub.com/jedevc) in [https://github.com/dagger/dagger/pull/7956](https://togithub.com/dagger/dagger/pull/7956) - Extend multi git server support to Azure devOps by [@​grouville](https://togithub.com/grouville) in [https://github.com/dagger/dagger/pull/8063](https://togithub.com/dagger/dagger/pull/8063) \ Our support for Azure refs was broken on monorepos. We special-case Azure DevOps since it doesn't work with the go standard convention of discovering the root of a git repository ##### What to do next? - Read the [documentation](https://docs.dagger.io) - Join our [Discord server](https://discord.gg/dagger-io) - Follow us on [Twitter](https://twitter.com/dagger_io) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 4pm on thursday" in timezone America/Los_Angeles, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/scottames/containers). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: scottames-github-bot[bot] <162828115+scottames-github-bot[bot]@users.noreply.github.com>
scottames
referenced
this pull request
in scottames/dots
Aug 10, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [dagger/dagger](https://togithub.com/dagger/dagger) | patch | `v0.12.3` -> `v0.12.4` | --- ### Release Notes <details> <summary>dagger/dagger (dagger/dagger)</summary> ### [`v0.12.4`](https://togithub.com/dagger/dagger/blob/HEAD/CHANGELOG.md#v0124---2024-08-01) [Compare Source](https://togithub.com/dagger/dagger/compare/v0.12.3...v0.12.4) ##### Changed - Deprecate old `pipeline` APIs by [@​jedevc](https://togithub.com/jedevc) in [https://github.com/dagger/dagger/pull/8064](https://togithub.com/dagger/dagger/pull/8064) \ These operations have been no-ops since v0.11.0, and will be removed in v0.13.0. ##### Fixed - Fix errors when using Dockerfile builds from module functions that have secrets by [@​sipsma](https://togithub.com/sipsma) in [https://github.com/dagger/dagger/pull/8049](https://togithub.com/dagger/dagger/pull/8049) - Fix dagger `terminal` prompt with debian-based images by [@​vmaffet](https://togithub.com/vmaffet) in [https://github.com/dagger/dagger/pull/7960](https://togithub.com/dagger/dagger/pull/7960) - Fix occasional leaks in secret scrubbing algorithm by [@​jedevc](https://togithub.com/jedevc) in [https://github.com/dagger/dagger/pull/8047](https://togithub.com/dagger/dagger/pull/8047) - Fix frequent context switches in `--progress=plain` output by [@​jedevc](https://togithub.com/jedevc) in [https://github.com/dagger/dagger/pull/7956](https://togithub.com/dagger/dagger/pull/7956) - Extend multi git server support to Azure devOps by [@​grouville](https://togithub.com/grouville) in [https://github.com/dagger/dagger/pull/8063](https://togithub.com/dagger/dagger/pull/8063) \ Our support for Azure refs was broken on monorepos. We special-case Azure DevOps since it doesn't work with the go standard convention of discovering the root of a git repository ##### What to do next? - Read the [documentation](https://docs.dagger.io) - Join our [Discord server](https://discord.gg/dagger-io) - Follow us on [Twitter](https://twitter.com/dagger_io) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 4pm on thursday" in timezone America/Los_Angeles, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/scottames/dots). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yMC4xIiwidXBkYXRlZEluVmVyIjoiMzguMjAuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: scottames-github-bot[bot] <162828115+scottames-github-bot[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The use case of:
Container.build
orDirectory.dockerBuild
APIsContainer
valuesAppears to have been broken for a while.
Before the secret isolation in v0.12.1, it was broken because these returned Dockerfiles were re-evaulated when the core ID was loaded after the function returned but the accessor was calculated again based on the caller, which resulted in a different secret value and thus missing secrets when the Dockerfile evaluation got unlazied.
After v0.12.1, the error changed to be a bit earlier, but still happened as the core ID for the returned Dockerfile build was being loaded. It now was happening because the
Container.build
implementation synchronously looked up secrets before they had been identified and passed from the function call client to the caller's secret store.The fix here is deceptively simple: just don't mark
secret
as impure anymore. It's no longer necessary to do this because of the changes made in v0.12.1. Whereas previouslysecret
actually looked up and calculated the accessor in some codepaths, it now just returns a static value based purely on the inputs.The reason this fixes the issue is a bit subtle and honestly might be a bit shaky; worth more thought. It's because when secret is pure, the whole
dockerBuild
API doesn't get cache invalidated and thus allows loading the return value to rely on dagql caching and skip the part where we were synchronously trying to find secrets that weren't loaded yet.Instead what happens now is the value gets loaded but returned from the cache, which allows the passing of secrets from the function call client to the caller to happen. Then when the Dockerfile-built Container is evaluated, the secrets will indeed be there.
Some more details in this comment: #8035 (comment)
Fixes #8035
This does appear to fix the issue based on the integ test added and the other secret tests I ran so far seem unimpacted.
However this is such a subtle one-line change that I want to digest it a little more and at minimum probably add even more integ tests to ensure every possible corner case is exercised. Marking as a draft pending those extra tests.
EDIT: after thinking some more, it still makes sense to me. Expanded the test coverage a bit more too to test evaluation from both within the module and on the cli client side