Toolkit: Use systemd-detect-virt instead of /.dockerenv to detect container builds.#11039
Merged
dmcilvaney merged 10 commits intomicrosoft:3.0-devfrom Nov 20, 2024
Merged
Conversation
reubeno
reviewed
Nov 14, 2024
reubeno
reviewed
Nov 14, 2024
c42b604 to
c61f7b6
Compare
dmcilvaney
commented
Nov 14, 2024
cwize1
reviewed
Nov 15, 2024
nicogbg
approved these changes
Nov 15, 2024
Contributor
Author
|
Pipe line to validate this keeps working: https://dev.azure.com/mariner-org/mariner/_git/CBL-Mariner-Pipelines/pullrequest/21071 |
jslobodzian
reviewed
Nov 15, 2024
jslobodzian
reviewed
Nov 15, 2024
cwize1
approved these changes
Nov 18, 2024
dmcilvaney
commented
Nov 19, 2024
12 tasks
dmcilvaney
commented
Nov 19, 2024
jslobodzian
approved these changes
Nov 19, 2024
dmcilvaney
added a commit
to dmcilvaney/CBL-Mariner
that referenced
this pull request
Nov 22, 2024
durgajagadeesh
pushed a commit
to durgajagadeesh/azurelinux_djpalli
that referenced
this pull request
Dec 31, 2024
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Merge Checklist
All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)
*-staticsubpackages, etc.) have had theirReleasetag incremented../cgmanifest.json,./toolkit/scripts/toolchain/cgmanifest.json,.github/workflows/cgmanifest.json)./LICENSES-AND-NOTICES/SPECS/data/licenses.json,./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md,./LICENSES-AND-NOTICES/SPECS/LICENSE-EXCEPTIONS.PHOTON)*.signatures.jsonfilessudo make go-tidy-allandsudo make go-test-coveragepassSummary
There have been several issues with a mismatch between the build environment and the detected state by the toolkit. When running in docker, the chroots generally need to be configured externally with their mounts and re-used. This can be done via setting
CHROOT_DIR=/path/to/reusable/chroots, and if the toolkit thinks it's in a container, it will switch modes.See https://github.com/microsoft/azurelinux-tutorials/tree/main/build-in-container for more details.
Some builds are currently failing because what is ostensibly a container environment does not have
/.dockerenvpresent.In the opposite direction, there are also situations where WSL images (which should work fine as a normal build) are reporting as docker because they have a
/.dockerenvfile present.systemdhas a tool (systemd-detect-virt) which is designed to detect what sort of virtualization is being used to run the current environment. Instead of designing a new system to re-implement this behavior, we can just use this tool. We already have an implicit build dependency onsystemd(we run the docker service etc.) so adding it as an explicit requirement shouldn't change anything.Also, to help people self-diagnose, sanity check the configurations and warn the user:
systemd-detect-virttool is not present, print a warning but fallback to the old behavior.To validate this we will need to add a new testcase to the toolkit sanity test pipeline that ensures the chroots keep working.
We will need to back-port this to 2.0 as well.
Change Log
systemd-detect-virtover/.dockerenvfor container detectionDoes this affect the toolchain?
NO
Associated issues
Test Methodology
pipeline PR soon): https://dev.azure.com/mariner-org/mariner/_build/results?buildId=675755&view=resultshttps://dev.azure.com/mariner-org/mariner/_build/results?buildId=676056&view=resultshttps://dev.azure.com/mariner-org/mariner/_build/results?buildId=678948&view=results