Commit Graph

5075 Commits

Author SHA1 Message Date
Kai Lüke
e4f811dd0d disk_layout: optimize btrfs filesystem overhead
The defaults already give more space than the ext4 defaults but it's
recommended to use the mixed mode for filesystems smaller than 1-5 GB.
Another aspect is the duplication of metadata and while it currently is
off it's actually related to the underlying block device and could
change as soon as the block device type changes.

Select the mixed mode that uses a merged area for data and metadata
blocks. Also ensure that no metadata duplication gets enabled
automatically.
2021-07-27 14:23:47 +02:00
Kai Lüke
bc97e15c3c disk_layout: use btrfs for the OEM partition
The compression feature of btrfs allows us to store more in the
size-limited /usr and OEM partitions. The size should of course still
be monitored to not bloat the image but more headroom helps to try
things out quickly without hitting the hard limit which fails the
build.
Use btrfs for the OEM partition but with zlib compression because
the outdated GRUB version doesn't support zstd yet.
New subvolumes currently can't be used for the OEM partition as default
subvolumes because GRUB tries to read the grub.cfg from the top
subvolume (at least with our old version). (We could however use
subvolumes for the /usr partition when switching to btrfs if that
makes any sense.)
2021-07-27 14:08:42 +02:00
Kai Lüke
d0cf1a4d19 disk_util: support compressed btrfs filesystems
The limited /usr and OEM partiton size is a challenge when adding new
packages or updating a package. Since the disk layout can't be changed
for compatibility reasons when updating an existing instance, we can't
simply try out something without ensuring first that enough space is
there by removing something else. This situation can be relaxed by
leveraging btrfs compression. There was some support for btrfs but it
was a bit outdated and didn't allow to configure compression or setting
read-only flags.
Fix the btrfs support, allow to mark the default subvolume as read only
and add a compression variable that allows to select a compression
algorithm. Instead of enabling compression by setting the mount option,
we can set the filesystem attribute which has the benefit that
compression is still used with the default mount options for this (top)
directory and its contents. While for the ext2 /usr partition a hack
existed to force read-only mode by modifying some bytes and checking
these bytes could also be used to know if read-only should be used to
prevent corruption of dm-verity data, we rather check directly whether
dm-verity is active for this partition and mount it read-only (and
with the norecovery option to really prevent any write attempt).
2021-07-27 14:08:42 +02:00
Kai Lüke
29fbd62339
Merge pull request #135 from kinvolk/kai/test-update
jenkins/kola/qemu(_uefi): run update test from previous release
2021-07-27 12:50:29 +02:00
Kai Lüke
e96c1c5e6d jenkins/kola/qemu(_uefi): run update test from previous release
The newly enabled update test performs an update from the built image
to itself. This is useful to test that the update mechanism didn't
break but it doesn't say if the built image will be accepted as update
from the previous official release.

Introduce an additional kola run that begins from the previous official
release and tests to update to the built image. Since the test does two
updates it also covers the case of updating from the built image to the
built image. Thus, we can skip the test in the normal run.
This new kola run is done first to keep the qemu-latest symlink valid
for the main test suite.
2021-07-27 11:51:58 +02:00
Jeremi Piotrowski
e2c10a9fe8 bootstrap_sdk: override seed path after building stage1
When performing a full bootstrap (stage1-4), the stage1 results are currently
discarded because of the logic in catalyst_build: the first build stage uses
the "seed" and every following stage uses the previous stages results *but*
stage1 is built before catalyst_build. So from the point of view of
catalyst_build, stage2 is the first one and uses the seed tarball.

To make sure stage1 results are used if it was built, set the SEED variable to
the latest stage1 location.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2021-07-26 16:29:13 +00:00
Kai Lüke
1b70f59cd0 jenkins/kola: share a single qemu script file 2021-07-26 15:01:24 +02:00
Jeremi Piotrowski
8e44a167d5
Merge pull request #133 from kinvolk/jepio/fix-arm64-devcontainer
disk_layout: devcontainer: use architecture agnostic part uuid
2021-07-22 22:10:29 +02:00
Mathieu Tortuyaux
37bc8884e5
Merge pull request #132 from kinvolk/tormath1/qemu-option
build_lib/qemu_tmpl: fix short-form warning
2021-07-19 17:50:06 +02:00
Jeremi Piotrowski
4ba3218d6a boostrap_sdk: only build aarch64 cross-rust on x86 hosts
The rust ebuild has some magic to detect cross-toolchains present on the
system and enable building additional cross targets. The code to trigger
the rebuild of rust is part of install_cross_rust, and checks whether
the cross directories exist in the rust installation. If they don't,
then rust is removed and rebuilt to allow for the auto-detection to
happen.

Right now there are two issues with the code. Firstly, the path that is
checked is wrong, which leads to rust always being removed and rebuilt.
The path checked is /usr/lib/rust-*/rustlib but /usr/lib/rustlib is
where the files are installed.

The second issue is that it checks for aarch64 dirs when CHOST is
aarch64-cros-linux-gnu. However, on an aarch64 host the aarch64 dirs
will already exist from building the sdk itself. The rust ebuild is not
ready to handle aarch64 hosts yet and blows up. The correct behavior is
to combine the check for CHOST with a check for the right CBUILD.

On an aarch64 host we should presumably check for the x86 CHOST and rust
dirs, but that can be added later, because it needs more work.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2021-07-19 15:11:12 +00:00
Jeremi Piotrowski
e4f57bea82 bootstrap_sdk: fix issues around lib->lib64 symlink
The arm64 profiles don't specify SYMLINK_LIB=yes, which makes sense
since arm64 systems don't support multilib in the way that we are used
to from x86. What this means is that build artifacts are installed into
separate lib and lib64 directories. The root overlay installed in stage4
needs to check for SYMLINK_LIB before trying to create a symlink,
otherwise it fails to be applied because it collides with the directory
in the rootfs.

This uncovered a second minor issues - the rust toolchain bootstrap
scripts checked for /usr/lib64/rust*, but the ebuild installs to
/usr/lib/rust.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2021-07-19 15:11:09 +00:00
Jeremi Piotrowski
911da26072 disk_layout: devcontainer: use architecture agnostic part uuid
The previously used uuid 4f68bce3-e8cd-4db1-96e7-fbcaf984b709 is valid
for x86_64 root partitions, which resulted in the dev container not
working with systemd-nspawn on aarch64. systemd-nspawn fails with:

  No suitable root partition found in image

Change the partition uuid to the architecture agnostic one documented
in the man page:

  A GUID partition table (GPT) with a single partition of type 0fc63daf-8483-4772-8e79-3d69d8477de4.

This makes systemd-nspawn happy on aarch64.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2021-07-16 15:35:18 +00:00
Mathieu Tortuyaux
35387cfdff
build_lib/qemu_tmpl: fix short-form warning
starting from qemu-6.0.0, options with short-form are deprecated.

```
$ ./flatcar_production_qemu.sh
qemu-system-x86_64: -fsdev local,id=conf,security_model=none,readonly,path=/tmp/flatcar-configdrive.gyqmdrQqfA: warning: short-form boolean option 'readonly' deprecated
Please use readonly=on instead
```

See this commit: ccd3b3b811

Signed-off-by: Mathieu Tortuyaux <mathieu@kinvolk.io>
2021-07-16 16:04:50 +02:00
Kai Lüke
b55bfa3341
Merge pull request #130 from kinvolk/kai/gen-test-update
Generate test update payload and run the kola update test
2021-07-14 20:50:15 +02:00
Kai Lüke
177bea4a74 Generate test update payload and run the kola update test
The kola update tests need a dev-key-signed update payload. This was
lacking and caused the update tests to be skipped.
Generate the test update payload for both dev builds and release builds
and run the kola tests for both. The test update payload has a special
name to not confuse it with the real update payload for releases, and
we keep the previous behavior to sign releases. Therefore, the
generate_update function wasn't used but the extract_update function
extended with generating the additional test payload.
2021-07-12 18:49:54 +02:00
Kai Lüke
dbbdb32250
Merge pull request #128 from kinvolk/kai/systemd-run-unit-name
jenkins/systemd-run-wrap.sh: randomize unit name suffix
2021-07-09 11:07:33 +02:00
Kai Lüke
d1b97aff42 jenkins/systemd-run-wrap.sh: randomize unit name suffix
The timestamp alone was not enough to prevent unit name clashes.
Add a random suffix to greater reduce the chance of hitting a clash.
2021-07-08 21:31:04 +02:00
Kai Lüke
aa27b1d11f
Merge pull request #127 from kinvolk/kai/jenkins-inline
jenkins: move all inline bash scripts to flatcar-scripts
2021-07-05 20:05:38 +02:00
Kai Lüke
8eaef708be jenkins: move all inline bash scripts to flatcar-scripts
The logic of the inline bash scripts of each job was sometimes
separated into the flatcar-scripts/jenkins/*.sh helpers but mostly
part of the Groovy file. This coupling had its advantages but also
downsides when special cases needed to be added for different release
versions. Other issues were that the inline scripts needed the
backslash character to be escaped twice and Jenkins was not good in
terminating the child processes when stopping a job. Having inline
bash scripts in Groovy also mandated the use of Jenkins to build and
release Flatcar Container Linux which hinders test builds in other CI
platforms.
Move the inline bash scripts fully to to the files in
flatcar-scripts/jenkins/ and create new ones for job that didn't have
a script there yet. Also invoke them through a systemd-run wrapper
script which ensures that all child processes are terminated and also
sets up /opt/bin as additional path for the static lbzcat binary.
A workaround for bash 4 was needed to use a temporary file instead of
the <(cmd) bash feature which caused a strange syntax error, otherwise
the bash commands are moved as they are.
2021-06-30 16:31:58 +02:00
Thilo Fromm
0ec82836ad
Merge pull request #126 from kinvolk/t-lo/update-to-glibc-2.33-simple
catalyst_toolchains: don't touch the SDK
2021-06-29 14:20:23 +02:00
Thilo Fromm
d1e2f6d1f2 catalyst_toolchains: don't touch the SDK
This change removes 8 years old code from the toolchains build which
tries to update SDK libraries for unknown reasons, breaking the
toolchains build in the glibc-2.33 update.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-06-25 10:37:21 +02:00
Krzesimir Nowak
3cf5d83056
Merge pull request #121 from kinvolk/krnowak/jobs-be-gone
Drop `--jobs` parameter
2021-05-05 19:25:20 +02:00
Thilo Fromm
95ae4c90b7
Merge pull request #124 from kinvolk/t-lo/fix-sdk-bootstrap-part-2
bootstrap_sdk: use local SDK ebuilds for stage1 (part 2)
2021-04-23 16:24:21 +02:00
Thilo Fromm
11e862e2d5 jenkins/sdk.sh: add stage1 portage and overlay refs
Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-04-23 16:23:10 +02:00
Thilo Fromm
8877d7adcd bootstrap_sdk: use local SDK ebuilds for stage1
This change uses portage-stable and coreos-overlay from the local SDK
chroot (from /var/lib/gentoo/repos) in the stage 1 SDK bootstrap build.
This is part 2 of the SDK bootstrap stage 1 fix (part 1 is covered in
64d8a73ac0), which ensures stage 1 does
not introduce any changes in its ebuilds over the seed SDK.

The change also introduces an option to consciously divert from the
above enforcement by use of command line parameters:

--stage1_overlay_ref <gitref> will check out coreos-overlay and use
                                <gitref> for stage 1 instead of the
                                local SDK's
                                /var/lib/gentoo/repos/coreos-overlay

--stage1_portage_ref <gitref> will check out portage-stable and use
                                <gitref> for stage 1 instead of the
                                local SDK's
                                /var/lib/gentoo/repos/gentoo

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-04-23 16:23:03 +02:00
Thilo Fromm
64d8a73ac0
Merge pull request #123 from kinvolk/t-lo/fix-sdk-bootstrap
Fix SDK bootstrap in bootstrap_sdk: no package updates in stage 1
2021-03-15 15:06:13 +01:00
Thilo Fromm
659d4bf484
bootstrap_sdk: fix typo in top-level stage1 description
Co-authored-by: Sayan Chowdhury <sayan@kinvolk.io>
2021-03-05 12:11:18 +01:00
Thilo Fromm
ac31f8ac9a
bootstrap_sdk: fix typo in bootstrap process description
Co-authored-by: Marga Manterola <62987181+marga-kinvolk@users.noreply.github.com>
2021-03-04 19:03:00 +01:00
Thilo Fromm
12d59f88e0 build_library/catalyst_sdk.sh: save snapshot of coreos-overlay
This change to stage 4 of the SDK bootstrap process will keep a
snapshot of coreos-overlay in the SDK tarball. This snapshot can be
used in future SDK bootstraps' stage1 to ensure a clean stage 1 output
without any package updates.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-03-04 18:59:13 +01:00
Thilo Fromm
319e3e702f bootstrap_sdk stage1: more comments, restructured for clarity
Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-03-04 18:07:54 +01:00
Thilo Fromm
9fd60f9ea2
Spelling fixes in comments
Co-authored-by: Krzesimir Nowak <krzesimir@kinvolk.io>
2021-03-04 11:33:30 +01:00
Thilo Fromm
84d7bf63b1 bootstrap_sdk: no package updates in stage 1
This change updates the stage1 SDK bootstrap build to use local
("known good") package ebuilds only, preventing updated package ebuilds
to apply in stage 1. This fixes SDK build breakage we observed when
upgrading core libraries like readline.

The change also removes the seed update from stage 1 as it should not
be needed anymore now that we postpone any package updates to stage 2.

The following package ebuild repos are used for stage 1:
- for portage-stable, we simply copy /var/gentoo/repos/gentoo
   from the SDK root.
- coreos-overlay is more complicated since ebuilds are missing from
   the SDK. So we grok the version the SDK was built with from
     /mnt/host/source/.repo/manifests/default.xml
   and then we create a local stage 1 clone of
     https://github.com/kinvolk/coreos-overlay.git
   in which we then check out the revision noted in the default mnifest.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-03-03 17:32:38 +01:00
Kai Lüke
dd4a8e0335
Merge pull request #122 from kinvolk/kai/vm-matrix-reuse
jenkins/vm: expect a FORMATS parameter which has a list of formats
2021-02-19 15:14:24 +01:00
Kai Lüke
8aab1d6d5a jenkins/vm: expect a FORMATS parameter which has a list of formats
One Jenkins jobs for each image format caused a large overhead.
Allow to build multiple image formats in one job.
2021-02-18 13:42:15 +01:00
Krzesimir Nowak
a6a6e0be2c common: Make sure that NUM_JOBS is a positive integer 2021-02-18 08:25:21 +01:00
Krzesimir Nowak
6ed7cd66d5 *: Drop jobs parameter
The `--jobs` parameter that some scripts defined was not used anywhere
in jenkins or mantle. So the value of the parameter always ended up
being equal to `${NUM_JOBS}` set by `common.sh`. Also, even if the
`--jobs` parameter was used for some script, that script usually
didn't forward the jobs value to other scripts, so the other scripts
ended up using `${NUM_JOBS}` again. Also, the `${FLAGS_jobs}` variable
was used by some functions in the build library, and those functions
were sometimes invoked by scripts that didn't define the
`${FLAGS_jobs}` variable. It is tedious to track which script should
actually define the parameter, and where it should be forwarded.

Just get rid of this half-working pretense. If you want to affect how
many jobs `emerge` uses, export the `NUM_JOBS` environment variable
before calling any script.

For `EMERGE_FLAGS` and `REBUILD_FLAGS` we unconditionally specify the
`--jobs` flag's value to `${NUM_JOBS}` because they are passed to
`emerge`. On the other hand we drop the `--jobs` parameter from the
`UPDATE_ARGS` variable, because this variable passed to `setup_board`
or `update_chroot`, which don't have this flag any more.
2021-02-17 13:26:36 +01:00
Sayan Chowdhury
fcb58c6474
Merge pull request #120 from kinvolk/sayan/specify-num-jobs
image_to_vm.sh: Explicity mention the jobs param in image_to_vm step
2021-02-17 13:05:38 +05:30
Sayan Chowdhury
ee34c9d2e3
image_to_vm.sh: Explicity mention the jobs param in image_to_vm step
Now, in the oem aci creation step we make use of the jobs param.
Without this flag, an empty string is passed to to emerge which results
in failure.

Signed-off-by: Sayan Chowdhury <sayan.chowdhury2012@gmail.com>
2021-02-17 12:04:47 +05:30
Krzesimir Nowak
b1e730d0ed
Merge pull request #119 from kinvolk/krnowak/jobs-fix
Fix missing jobs parameter
2021-02-16 10:24:09 +01:00
Krzesimir Nowak
9cbf3049ea vm_image-util: Forward jobs parameter to build_oem_aci 2021-02-16 08:36:57 +01:00
Krzesimir Nowak
1084f961fd build_*_aci: Add missing jobs parameter
They end up using emerge_to_image which needs uses the `$FLAGS_jobs`
parameter. Seems like new portage does not like getting the parameter
like `--jobs=` (with an empty value).
2021-02-16 08:31:11 +01:00
Krzesimir Nowak
91a85ddc86
Merge pull request #118 from kinvolk/krnowak/portage-update
portage update: port check_root to python3 and fix SDK bootstrap
2021-02-15 12:47:26 +01:00
Krzesimir Nowak
f09a648222 check_out_of_date: Add a TODO about porting it
The script is written in python2 and it imports portage code. Since
the portage is going to become a python3-only code, the script needs
porting to python3. It is not the high priority right now, because it
seems to be not used by other scripts or jenkins.
2021-02-12 10:03:16 +01:00
Krzesimir Nowak
647690e264 build_library/check_root: Port to python3
The script needs to be ported, because it is importing portage code
which became python3 only.

The porting I did is likely a lousy job, but at least it stopped
failing with some p(yt)hony errors.
2021-02-12 10:03:16 +01:00
Krzesimir Nowak
917d12cd7e bootstrap_sdk: The CONTENTS files are now gzipped
A newer version of catalyst seems to be actually gzipping the CONTENTS
files, so take this into accout.
2021-02-12 10:03:16 +01:00
Krzesimir Nowak
746ac38cfb
Merge pull request #112 from kinvolk/krnowak/break_dep_loop
Improve the dependency cycle breaking logic
2021-02-12 10:01:27 +01:00
Krzesimir Nowak
7f2a437f0a build_packages: Build all packages in the broken cycle
Previously we broke the cycle caused by sys-apps/util-linux only,
while disabling cryptsetup USE flag in systemd to avoid another
cycle. That worked before, because the follow-up merge of the rest of
packages built sys-fs/cryptsetup before sys-apps/systemd. After an
update, the new portage is ordering the builds in different way and
sys-apps/systemd ended up being built before sys-fs/cryptsetup and
that failed during the configure phase because of unmet dependencies.

Better build all the packages taking part in the loop (not counting
the virtual packages), so we become less reliant on the package build
ordering. It is going to take slightly more time as we build a couple
of packages more.
2021-02-09 07:44:22 +01:00
Krzesimir Nowak
d575ef441a build_packages: Build multiple packages in one go when breaking loops
Instead of rebuilding just one package and maybe rebuilding others as
a fallout, force rebuilding all the mentioned packages. This makes the
build process a bit more robust against package build ordering
changes.

May be useful when breaking multiple dep loops that have some common
packages, so we build them all once.
2021-02-09 07:44:22 +01:00
Krzesimir Nowak
85d6f05b1b
Merge pull request #117 from kinvolk/krnowak/bootstrap-sdk-refactor
bootstrap_sdk: Put image, contents and digests paths into variables
2021-02-05 14:02:26 +01:00
Krzesimir Nowak
11d1e10e3f bootstrap_sdk: Put image, contents and digests paths into variables
It makes it a bit easier to read and clearer what the script is doing
without all that repetition.
2021-02-05 08:27:34 +01:00