Repository navigation
Conversation
t-8ch
left a comment
There was a problem hiding this comment.
I focused on step 1) for now.
You could also drop the other steps for now and we do one after the other.
3b2caf8 to
90dc4e3
Compare
| for lic in repo_conf.splitlines(): | ||
| if lic.startswith('SignWith'): | ||
| self.keyid = lic.split()[1] | ||
| conf_dist = self.volume.joinpath('conf', 'distributions') |
There was a problem hiding this comment.
In the end we want to have a repository/SBOM for the build environment, even if that wasn't an initvm.
We can probably skip it for now, but will need some solution before making this a stable feature.
There was a problem hiding this comment.
I also thought of that, but wasn't sure how/if to approach it properly, because I am not so sure if copying the exact same approach from initvm is actually useful for the container use case.
Sure, SBOM generation for the container environment should be done. But for that I guess we should first look how we want to approach SBOM generation for ELBE in the first place (as you mentioned debsbom before).
For the packages, do you think it is worth to assemble the Debian packages from the container standalone like we do for initvm? Wouldn't it be more convenient to just archive the whole container including all the configuration / scripting / ...
There was a problem hiding this comment.
Wouldn't it be more convenient to just archive the whole container including all the configuration / scripting /
We'll need a machine-readable description of it, not only the raw artifacts.
There was a problem hiding this comment.
We'll need a machine-readable description of it, not only the raw artifacts.
Yes, definitely! I meant the "archived container" just as replacement for the binary artifacts of the initvm CD, not as replacement for the SBOM.
3ad19f5 to
0cbcbdb
Compare
0cbcbdb to
b415f97
Compare
95af6b2 to
37ead4c
Compare
| ' RAM. Use --basetemp=<dir> or set TMPDIR to select another' | ||
| ' location.', | ||
| ) | ||
| os.environ['TMPDIR'] = str(var_tmp) |
There was a problem hiding this comment.
While I am aware that I asked for this, it is quite complicated...
Maybe we test for the free space instead? That could be done easily in pure python.
There was a problem hiding this comment.
Hmm. If you really want it, I can of course implement it. The change for that would be small (see below). But I am not really sure if just checking for the amount of free space is the correct approach. I see two problems with that
- It introduces an arbitrary constant. How could we know how much space we really need?
- Even if there is enough space in the RAM for the full build, it still leads to excessive RAM usage, leaving fewer RAM for the build as well as parallel processes. My initial issue that triggered the idea to move to /var/tmp was actually not that the build was failing, but that my browser that I had open in parallel got unusable slow. We can then of course keep some buffer, but again, how much buffer is sufficient?
--- a/conftest.py
+++ b/conftest.py
@@ -2,10 +2,12 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2024 Linutronix GmbH
import os
-import subprocess
+import shutil
import tempfile
from pathlib import Path
import pytest
+# Minimum free space required in the temp dir for large build artifacts.
+MIN_TMP_FREE = 20 * 1024**3
# https://stackoverflow.com/a/61193490
def pytest_addoption(parser):
@@ -22,12 +24,6 @@
)
-def _is_ram_backed(path):
- fstype = subprocess.run(
- ['stat', '-f', '-c', '%T', path],
- capture_output=True, text=True, check=False,
- ).stdout.strip()
- return fstype in ('tmpfs', 'ramfs')
-
-
def pytest_configure(config):
config.addinivalue_line('markers', 'slow: mark test as slow to run')
@@ -46,19 +42,22 @@
os.environ.setdefault('PYTHONWARNINGS', ' '.join(warnings))
- # Avoid filling up the RAM with large build artifacts: unless the user
- # chose a location, move away from the default temp dir if it is RAM-backed.
+ # Avoid filling up the temp dir (often RAM-backed) with large build
+ # artifacts: unless the user chose a location, move away from the default
+ # temp dir if it has too little free space.
if 'TMPDIR' not in os.environ and not config.option.basetemp:
- if _is_ram_backed(Path(tempfile.gettempdir())):
+ if shutil.disk_usage(tempfile.gettempdir()).free < MIN_TMP_FREE:
var_tmp = Path('/var/tmp')
- if not var_tmp.is_dir() or not os.access(var_tmp, os.W_OK | os.X_OK):
+ if (
+ not var_tmp.is_dir()
+ or not os.access(var_tmp, os.W_OK | os.X_OK)
+ or shutil.disk_usage(var_tmp).free < MIN_TMP_FREE
+ ):
raise pytest.UsageError(
- f'{tempfile.gettempdir()} is RAM-backed and {var_tmp} is not a'
- ' writable directory. Large build artifacts would fill up the'
- ' RAM. Use --basetemp=<dir> or set TMPDIR to select another'
- ' location.',
+ f'{tempfile.gettempdir()} has less than'
+ f' {MIN_TMP_FREE // 1024**3} GiB free and {var_tmp} is not a'
+ ' writable directory with enough free space. Use'
+ ' --basetemp=<dir> or set TMPDIR to select another location.',
)
os.environ['TMPDIR'] = str(var_tmp)
# tempfile has cached the old location by now, so reset
tempfile.tempdir = None
|
|
||
| class LocalProjectBackend(ProjectBackend): | ||
| def __init__(self, cache_dir, outdir): | ||
| self.pm = ProjectManager(cache_dir) |
There was a problem hiding this comment.
The database is still stored in /var/cache/elbe. Can we move it into the cache_dir parameter here?
There was a problem hiding this comment.
Refactored the whole handling around the cache dir. This was also needed for native builds (because it otherwise resulted in too long socket paths with the gpg agent).
4d50acb to
2596a54
Compare
| def __init__(self, xml): | ||
|
|
||
| self.xml = xml | ||
| self._saved_config = {} |
There was a problem hiding this comment.
Could you mention in the commit message why we need this?
There was a problem hiding this comment.
Rebased this branch onto master and tried to explain this commit better
elbepack: virtapt: restore global apt config on delete
VirtApt modifies the process-global apt_pkg.config (Dir::*, APT::*) to point
into its temporary directory.
Until now, the modification by VirtApt (as consequence of the elbe
check_updates command) and a build never occured in the same process.
But if we want to support fully native builds and tests (i.e. without
containers and without VM), these apt_pkg.config settings are no longer
strictly isolated process-wise, so they could leak over.
Therefore, revert the settings after VirtApt is done by remembering the
original values and restoring them in delete().
Signed-off-by: Florian Kauer <florian.kauer@linutronix.de>
2596a54 to
eff1fe3
Compare
/tmp is usually RAM-backed, so when putting build artifacts there, it will fill up very quickly and exhaust the RAM. Therefore, use /var/tmp per default. On Debian systems /var/tmp will still follow a retention policy, so any potential leftovers will be removed after 30 days (in the default configuration). On systems where /tmp is not RAM-backed, still use it. Signed-off-by: Florian Kauer <florian.kauer@linutronix.de>
Add a build_driver fixture that hides how the XML files under test are
built, so we can in future support multiple different drivers like
initvm and container based.
Use absolute paths since native builds run in-process and the build
changes the working directory of the pytest process (e.g. asyncworker
chdir('/')). Relative XML paths used by later tests then fail to load.
Signed-off-by: Florian Kauer <florian.kauer@linutronix.de>
Split the test_xml to only contain code that is not directly related to the initvm. This will enable us in the next step to add further tests that will use the container-based approach. Signed-off-by: Florian Kauer <florian.kauer@linutronix.de>
Build a simple image without a bootloader to demonstrate an ELBE build that does not require elevated privileges. Signed-off-by: Florian Kauer <florian.kauer@linutronix.de>
…without udev Setup UUID as needed e.g. for grub, because that is usually also done by udev. So without udev, we need a replacement for that functionality. Signed-off-by: Florian Kauer <florian.kauer@linutronix.de>
Run the XML build tests by calling elbe build directly on the host instead of going through an initvm, using the build_driver abstraction. Tests that need root privileges are skipped when not run as root. Signed-off-by: Florian Kauer <florian.kauer@linutronix.de>
With the recent additions, it is no longer necessary to spawn an initvm to build ELBE images. Therefore, provide a container that enables this use case and replace the existing legacy containerfile with it. Signed-off-by: Florian Kauer <florian.kauer@linutronix.de>
Provide a test driver to run the same tests as for the initvm and native for the container-based build as well. Detect whether the XML under test actually needs a rootful container by checking xml_needs_rootful(). When it does not, run the container rootless via --userns auto instead of requiring elevated privileges, and only skip the test when a rootful container is required and the tests are not run as root. Signed-off-by: Florian Kauer <florian.kauer@linutronix.de>
Ubuntu 26.04 uses uutils coreutils by default, which installs chroot to /usr/bin instead of /usr/sbin like GNU coreutils on Debian. The hardcoded /usr/sbin/chroot then fails with FileNotFoundError, e.g. in the doctest of shellhelper.chroot() in the GitHub CI. Call chroot by name instead. In shellhelper.chroot() the PATH of the target is used for the lookup, which contains both directories. For 'elbe chroot', add the sbin directories using get_env_with_sbin() like it is done for other tools living in sbin. Signed-off-by: Florian Kauer <florian.kauer@linutronix.de>
1dacc79 to
b786833
Compare
This supersedes #482 by removing the manual mknod procedures with passing udev and /dev directly into the container for the rootful case.
Also reordered the commits as discussed:
fc80da4
54c6257
da13574
d532e23
9843820
d7f66a3
707b6c6
ea2994e
ec47114
b5b9d22
No additional commits, but requires to manually unshare if not done via container.
0095a8d
43a09d5
41e12bf
76aa59e
79d2fd0
d4cabf0