-
Notifications
You must be signed in to change notification settings - Fork 167
Avoid ARG_MAX overflow in bootc image-mode builds
#4793
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
Merged
+109
−2
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| description: | | ||
| The generated Containerfile for bootc image-mode builds is now | ||
| transferred via ``push()`` instead of being inlined on the SSH | ||
| command line, preventing ``ARG_MAX`` overflow when plan environment | ||
| contains large values. |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1 |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| discover: | ||
| how: shell | ||
| tests: | ||
| - name: /smoke | ||
| test: /usr/bin/true | ||
|
|
||
| provision: | ||
| how: virtual | ||
|
|
||
| prepare: | ||
| - how: shell | ||
| script: echo "prepare phase 1" | ||
| - how: shell | ||
| script: echo "prepare phase 2" | ||
|
|
||
| execute: | ||
| how: tmt |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| summary: Test prepare with large plan environment | ||
| description: | | ||
| Verify that prepare succeeds when plan environment contains large | ||
| values (e.g. base64-encoded secrets). Without the push() fix, | ||
| the generated Containerfile was passed as a cat heredoc SSH | ||
| command-line argument, exceeding the OS ARG_MAX limit. | ||
| link: | ||
| - relates: https://github.com/teemtee/tmt/issues/4518 | ||
| tag+: | ||
| - provision-only | ||
| - provision-virtual | ||
| - image-mode | ||
| require: | ||
| - tmt+provision-virtual | ||
| duration: 2h |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| #!/bin/bash | ||
| . /usr/share/beakerlib/beakerlib.sh || exit 1 | ||
| . ../../images.sh || exit 1 | ||
|
|
||
| rlJournalStart | ||
| rlPhaseStartSetup | ||
| rlRun "PROVISION_HOW=${PROVISION_HOW:-virtual}" | ||
| rlRun "IMAGE_MODE=${IMAGE_MODE:-yes}" | ||
|
|
||
| # TODO: Enable IMAGES for container and virtual provision methods | ||
| # once the large-env fix is verified for those backends. | ||
| if [ "$IMAGE_MODE" = "yes" ]; then | ||
| rlRun "IMAGES='$TEST_IMAGE_MODE_IMAGES'" | ||
|
|
||
| elif [ "$PROVISION_HOW" = "container" ]; then | ||
| rlRun "IMAGES=" | ||
|
|
||
| elif [ "$PROVISION_HOW" = "virtual" ]; then | ||
| rlRun "IMAGES=" | ||
|
|
||
| else | ||
| rlRun "IMAGES=" | ||
| fi | ||
|
|
||
| rlRun "run=\$(mktemp -d -p /var/tmp)" 0 "Create run directory" | ||
| rlRun "pushd data" | ||
|
|
||
| # Size the env dynamically so 2 shell prepare steps produce a | ||
| # Containerfile that exceeds MAX_ARG_STRLEN (PAGE_SIZE * 32). | ||
| # Each RUN inlines the full export; raw_bytes * 4/3 (base64) ≈ | ||
| # half the limit, so two RUNs combined just exceed it. | ||
| rlRun "max_arg_strlen=\$(( \$(getconf PAGE_SIZE) * 32 ))" | ||
| rlRun "raw_bytes=\$(( max_arg_strlen * 5 / 12 ))" | ||
| rlRun "rlLogInfo \"MAX_ARG_STRLEN: \$max_arg_strlen raw_bytes: \$raw_bytes\"" | ||
| rlRun "python3 -c 'import base64; print(\"LARGE_SECRET: \" + base64.b64encode(b\"x\" * '\$raw_bytes').decode())' > large-env.yaml" | ||
| rlRun "rlLogInfo \"LARGE_SECRET size: \$(wc -c < large-env.yaml) bytes\"" | ||
|
|
||
| rlRun "export TMT_BOOT_TIMEOUT=300" | ||
| rlRun "export TMT_CONNECT_TIMEOUT=300" | ||
| rlPhaseEnd | ||
|
|
||
| while IFS= read -r image; do | ||
| phase_prefix="$(test_phase_prefix "$image")" | ||
|
|
||
| rlPhaseStartTest "$phase_prefix Prepare/install with large environment" | ||
| rlRun -s "tmt -vvv run --all --scratch -i \$run --environment-file large-env.yaml provision --how $PROVISION_HOW --image $image" | ||
|
|
||
| rlAssertGrep "building container image" $rlRun_LOG | ||
| rlAssertGrep "switching to new image" $rlRun_LOG | ||
| rlAssertGrep "rebooting to apply new image" $rlRun_LOG | ||
| rlPhaseEnd | ||
| done <<< "$IMAGES" | ||
|
|
||
| rlPhaseStartCleanup | ||
| rlRun "rm -f large-env.yaml" 0 "Remove generated env file" | ||
| rlRun "popd" | ||
| rlRun "rm -rf \$run" 0 "Remove run directory" | ||
| rlPhaseEnd | ||
| rlJournalEnd | ||
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.