Commit Graph

4611 Commits

Author SHA1 Message Date
Krzesimir Nowak
4ca7027365
Merge pull request #145 from kinvolk/krnowak/drop-unused-stuff
Remove unused scripts
2021-08-30 17:53:05 +02:00
Thilo Fromm
1570708e40
Merge pull request #148 from kinvolk/t-lo/disk-util-use-bytearray
build_library/disk_util: use byte array for conversion, not chr()
2021-08-30 09:16:16 +02:00
Thilo Fromm
e4c22ef6c7 build_library/disk_util: use byte array for conversion
disk_util sometimes bails out during build with an ASCII conversion
error:

Traceback (most recent call last):
  File "/mnt/host/source/src/scripts/build_library/disk_util", line 1114, in <module>
    main(sys.argv)
  File "/mnt/host/source/src/scripts/build_library/disk_util", line 1110, in main
    options.func(options)
  File "/mnt/host/source/src/scripts/build_library/disk_util", line 779, in Verity
    Tune2fsReadWrite(options, part, disable_rw=True)
  File "/mnt/host/source/src/scripts/build_library/disk_util", line 716, in Tune2fsReadWrite
    image.write(chr(flag_value))
UnicodeEncodeError: 'ascii' codec can't encode character '\xff' in position 0: ordinal not in range(128)

Curiously, the error does not reproduce every time (though the code
leading to the error is straightforward).

This change converts the integer to be written to a byte array (of size
1) instead of using chr(). Also, the file to be written is explicitly
opened in binary mode.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-08-27 17:25:34 +02:00
Krzesimir Nowak
ef0dfe5c5c Move cros_vm_constants to build_library
This file used to be imported by scripts coreos-base/cros-devutils,
which we have dropped. Now it is imported only from some other script
in build library so move it there. This leaves lib as a directory
where we keep shflags library.
2021-08-27 14:20:54 +02:00
Krzesimir Nowak
421de42db5 Drop unused scripts
The scripts were imported by some scripts from
coreos-base/cros-devutils, which we have dropped already. So the
scripts in the lib directory are currently an unused baggage.
2021-08-27 14:20:54 +02:00
Krzesimir Nowak
d67a8f04dc
Merge pull request #143 from kinvolk/krnowak/use-internal-cros-workon
*: Use the internal copy of cros_workon
2021-08-27 14:18:59 +02:00
Jeremi Piotrowski
5138697cc9
Merge pull request #146 from kinvolk/jepio/azure-gen2-jenkins
add support for running tests on Azure Gen2 VMs
2021-08-27 11:42:09 +02:00
Jeremi Piotrowski
a2b3950ac2 jenkins: add support for running tests on Azure Gen2 VMs
This requires passing the --azure-hyper-v-generation=V2 argument to kola. The
vhd/image is the same as for azure gen1 vms, the azure_gen2 specifier is only
for jenkins usage.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2021-08-26 19:14:10 +02:00
Krzesimir Nowak
344afd98f2
Merge pull request #142 from kinvolk/krnowak/python3-porting
Port some stuff to python3
2021-08-24 16:10:08 +02:00
Krzesimir Nowak
f143645215 generate_au_zip: Remove useless line 2021-08-24 16:08:15 +02:00
Krzesimir Nowak
cea18c41c3 *: Use the internal copy of cros_workon
The scripts that invoked `cros_workon` without specifying a path to
the script were not calling the internal `cros_workon` directly, but
rather a copy installed in `/usr/bin/cros_workon`.
`/usr/bin/cros_workon` comes from the `coreos-base/cros-devutil` and
is a wrapper script that sources `common.sh` file to figure the
location of the `scripts` and finally invokes the internal
`cros_workon`. Curious thing is that the sourced `common.sh` comes
from the `/usr/lib/crosutils` directory and contents of the directory
come from the `dev-util/crosutils` package. And that `common.sh` is
different from the one in the scripts directory, but fortunately the
part that detects the path to the `scripts` directory is the same. I'm
not sure where where exactly the copy of `common.sh` in
`/usr/lib/crosutils` comes from - likely from somewhere in
`https://chromium.googlesource.com/chromiumos/platform/crosutils`.

Just cut the middle layers and call the internal copy of `cros_workon`
directly.
2021-08-19 12:58:42 +02:00
Krzesimir Nowak
3f9c073b4b build_library: Fix some typos 2021-08-18 19:03:11 +02:00
Krzesimir Nowak
a314348a38 build_library: Fix getting integer from string
`string.atoi` was deprecated since at least the first release of
python2, and looks like it was dropped in python3.
2021-08-18 19:01:51 +02:00
Krzesimir Nowak
ea0f478cfa build_library: Fix some string vs bytes issues
This is some fallout from converting scripts from python2 to
python3. Output received from the functions in subprocess module now
return bytearrays, but we operate on them as if they were a text. So
decode the bytearrays to strings. Otherwise we are either getting some
junk values passed to the command line utilities (for example:
`b'/dev/loop2'` instead of `/dev/loop2`), or exceptions are thrown,
because a function expected a string.
2021-08-18 18:58:16 +02:00
Krzesimir Nowak
b6c6a05404 build_library: Fix python script extension
It's not a shell script. It never was a shell script. Must have been a
mistake to name it as such.
2021-08-18 18:57:04 +02:00
Krzesimir Nowak
336a967941 build_library: Convert python2 scripts to python3
This is just a conversion done by 2to3 with a manual updates of
shebangs to mention python3 explicitly. The fixups for bytearray vs
string issues will follow up.
2021-08-18 18:56:48 +02:00
Krzesimir Nowak
df63498a91 common: Replace the use of python2 with python3
We want to move to python3 eventually so update the script snippet. We
can be sure that python3 is installed, because portage already
requires it.
2021-08-18 18:56:35 +02:00
Krzesimir Nowak
bd5c0c6a0e check_out_of_date.py: Drop unused script
The script is potentially useful, but it seems to be unused anyway. We
can bring it back later if there's a need. Note that this will need
updating it to python3 first. Which is why I'm dropping it currently -
it's one python2 script less to port.
2021-08-18 18:52:46 +02:00
Dongsu Park
a091274a76
Merge pull request #141 from kinvolk/dongsu/generate-au-multi-arch
build_library: support multi-arch in generate_au_zip
2021-08-16 16:16:00 +02:00
Dongsu Park
04d9fea0c1 build_library: fix docstring issues
Fix several docstring issues, so that the docstrings could match with
the actual code.
2021-08-16 10:39:26 +02:00
Dongsu Park
34cb6d305a build_library: support multi-arch in generate_au_zip
To be able to support arm64 native SDK without cross builds, we should
make generate_au_zip support both architectures, amd64 and arm64.
Without doing that, `build_image` fails with `ERROR : Required
WHITE_LIST items ld-linux-x86-64.so.2 not found!!!`, because the
script recognizes only amd64 libs in WHITE_LIST.

We should first determine the architecture in build_image, before
running generate_au_zip, and pass the architecture, either amd64 or
arm64. Also add allow_list and ld_linux parameters to necessary
functions.
2021-08-13 10:03:33 +02:00
Dongsu Park
a7f251da44 build_library: use proper vocabulary in generate_au_zip
Replace black list with deny list, white list with allow list.
2021-08-13 09:30:53 +02:00
Jeremi Piotrowski
baa09b07dc
Merge pull request #129 from kinvolk/jepio/docker-20
Switch default torcx build to Docker 20.10.
2021-08-12 17:33:34 +02:00
Dongsu Park
30f4bde417
Merge pull request #140 from kinvolk/dongsu/skip-upload-rust-sdk
bootstrap_sdk: skip uploading non-existent directory to fix Rust builds
2021-08-11 09:59:19 +02:00
Dongsu Park
4d59b8715b bootstrap_sdk: skip uploading non-existent directory to fix Rust builds
Previously before https://github.com/kinvolk/flatcar-scripts/pull/134,
`bootstrap_sdk` was looking at the wrong path
(/usr/lib/rust-*/rustlib/aarch64-unknown-linux-gnu instead of
/usr/lib/rustlib/aarch64-unknown-linux-gnu). As a result, Rust got always
removed and rebuilt in `install_cross_rust`, which resulted in
`flatcar-sdk/crossdev/dev-lang/rust/rust-1.54.0-1.xpak` being created.

Now legitimate changes of https://github.com/kinvolk/flatcar-scripts/pull/134
prevent the rebuild from happening. The path already exists in a stage4
SDK build, because the seed stage already has cross-compilers so the
Rust upgrade has all the right cross-paths.

That's why SDK builds with only stage4 failed when it tries uploading Rust
packages like the following. On the other hand, full SDK builds with stage1
to 4 worked well, because in that case Rust is rebuilt anyway.

```
INFO    bootstrap_sdk: Uploading cross toolchain packages to
gs://flatcar-jenkins/developer/sdk/amd64/2021.08.04+dev-flatcar-master-3209
CommandException: No URLs matched:
/mnt/host/source/src/build/catalyst/packages/flatcar-sdk/crossdev/*
CommandException: No URLs matched:
/tmp/tmp.xyjXbCFhUc//mnt/host/source/src/build/catalyst/packages/flatcar-sdk/crossdev/*.sig
CommandException: 2 files/objects could not be transferred.
```

To fix that, we have to skip uploading packages when the crossdev
directory does not exist.

Debugged and suggested by @jepio
2021-08-10 12:18:58 +02:00
Jeremi Piotrowski
d6c75eb0d9 torcx: Bump the default Docker to 20.10 and drop older
We are enabling CgroupV2 support globally, which requires Docker 20.10.
It is possible to return to CgroupV1 locally via kernel commandline, but
that will still work with Docker 20. If someone really needs older
Docker versions we will recommend to also fetch torcx packages from
older releases or rely on upstream binaries.
2021-08-06 16:30:23 +00:00
Jeremi Piotrowski
a8a57c733b
Merge pull request #134 from kinvolk/jepio/arm64-sdk-support
bootstrap_sdk: enable arm64 sdk bootstrap
2021-08-03 12:18:01 +02:00
Kai Lüke
25dc4d4259
Merge pull request #139 from kinvolk/kai/switch-oem-to-btrfs
Revert "Revert "disk_layout: use btrfs for the OEM partition""
2021-08-03 11:07:46 +02:00
Kai Lüke
4321b2ab83 Revert "Revert "disk_layout: use btrfs for the OEM partition""
This reverts commit bb9ddfb08a,
meaning that the planned change is now done and we switch the OEM
partition to btrfs. The reason for the revert is resolved in
https://github.com/kinvolk/ignition/pull/22
2021-08-03 10:50:06 +02:00
Kai Lüke
832917d09e
Merge pull request #138 from kinvolk/kai/revert-oem-to-ext4
Revert "disk_layout: use btrfs for the OEM partition"
2021-08-02 12:00:51 +02:00
Kai Lüke
bb9ddfb08a Revert "disk_layout: use btrfs for the OEM partition"
This reverts commit bc97e15c3c.
2021-07-30 20:44:36 +02:00
Kai Lüke
6c13e2c3a7
Merge pull request #137 from kinvolk/kai/remove-kernel-from-usr
build_image_util.sh: delete vmlinuz file from /usr partition
2021-07-30 15:18:41 +02:00
Kai Lüke
c1b2d88aa2 build_image_util.sh: delete vmlinuz file from /usr partition
The vmlinuz kernel image gets installed to /usr/boot/ but isn't usable
for dm-verity until it gets copied over to /boot/flatcar/ and the hash
gets embedded at a particular offset. The file in /usr/boot/ uses space
while it's not having a real purpose as long as dm-verity is used.

Delete the vmlinuz file under /usr/boot/ to free up space. When
generating the ISO image we use the vmlinuz file from /boot/flatcar/
which also has the advantage that we only distribute a single vmlinuz
file with one particular checksum.
2021-07-28 20:59:16 +02:00
Jeremi Piotrowski
6ce5d3165f
build_library/toolchain_util: check CBUILD+CHOST for rust warning
For consistency with code further down in the file: aarch64 cross compilation only applies when CBUILD is x86,
for native aarch64 builds rust is guaranteed to have aarch64 rustlibs.
2021-07-28 16:47:13 +02:00
Kai Lüke
b892315775
Merge pull request #131 from kinvolk/kai/btrfs-usr-oem
disk_util: support compressed btrfs filesystems, use btrfs for the OEM partition
2021-07-28 13:34:50 +02:00
Jeremi Piotrowski
cfbc81ee59
Merge pull request #136 from kinvolk/jepio/boostrap-use-stage1-properly
bootstrap_sdk: override seed path after building stage1
2021-07-28 12:15:34 +02:00
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