-
Notifications
You must be signed in to change notification settings - Fork 561
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
Toolkit: Use systemd-detect-virt instead of /.dockerenv to detect container builds. #11039
Merged
dmcilvaney
merged 10 commits into
microsoft:3.0-dev
from
dmcilvaney:damcilva/3.0/tools/docker_detect
Nov 20, 2024
Merged
Toolkit: Use systemd-detect-virt instead of /.dockerenv to detect container builds. #11039
dmcilvaney
merged 10 commits into
microsoft:3.0-dev
from
dmcilvaney:damcilva/3.0/tools/docker_detect
Nov 20, 2024
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
dmcilvaney
added
bug
Something isn't working
Tools
main
PR Destined for main
3.0-dev
PRs Destined for AzureLinux 3.0
2.0
AzureLinux 2.0
and removed
2.0
AzureLinux 2.0
labels
Nov 13, 2024
reubeno
reviewed
Nov 14, 2024
reubeno
reviewed
Nov 14, 2024
dmcilvaney
force-pushed
the
damcilva/3.0/tools/docker_detect
branch
from
November 14, 2024 23:09
c42b604
to
c61f7b6
Compare
dmcilvaney
commented
Nov 14, 2024
cwize1
reviewed
Nov 15, 2024
nicogbg
approved these changes
Nov 15, 2024
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
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)
*-static
subpackages, etc.) have had theirRelease
tag 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.json
filessudo make go-tidy-all
andsudo make go-test-coverage
passSummary
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
/.dockerenv
present.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
/.dockerenv
file present.systemd
has 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-virt
tool 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-virt
over/.dockerenv
for 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