Skip to content

Commit

Permalink
release: fix bincheck failures
Browse files Browse the repository at this point in the history
Previously,  the bincheck test started failing after upgrading the linux
build system to a newer GLIBC and after we changed the way we stop the
server.

The linux bincheck test was relying on running the cockroach binary in a
qemu-based VM, using a custom kernel.

Now that, we don't use rocksdb and don't have SSE issues (see cockroachdb#15589),
we can simplify the test and run the binary without the VM layer.

This PR also fixes the issue, where the busybox `kill` command can only
handle positional arguments.

We try our best to kill the server, but in some cases the PID changes
and the whole test fail. Ignore the kill exit code and let the build
agent to kill the process.

Epic: none
Fixes: RE-271
Release note: None
  • Loading branch information
rail committed Jan 10, 2023
1 parent b5cffc0 commit a035256
Show file tree
Hide file tree
Showing 14 changed files with 3 additions and 208 deletions.
1 change: 0 additions & 1 deletion .github/workflows/bincheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: sudo apt-get update && sudo apt-get install -y qemu-system-x86
- run: cd build/release/bincheck && ./test-linux ${{ github.ref_name }} ${{ github.sha }}

darwin:
Expand Down
55 changes: 0 additions & 55 deletions build/release/bincheck/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,3 @@ sanity checks are:

bincheck action is triggered when a new tag with `v` prefix is created. Check
https://github.com/cockroachdb/cockroach/actions after a release is published.


## The nitty-gritty

### Overview

For the MacOS and Windows binaries, the mechanics involved are simple. We ask
GitHub Actions to spin us up a MacOS or Windows runner, download the
appropriate pre-built `cockroach` binary, and run our sanity checks.

Linux is more complicated, not out of necessity, but out of ambition. We co-opt
the Linux verification step to additionally test support for pre-SSE4.2
CPUs<sup>†</sup>. This requires emulating such a CPU, and Linux is the only
operating system that is feasible to run under emulation. Windows and MacOS have
prohibitively slow boot times, and, perhaps more importantly, Windows and MacOS
install media are not freely available.

So, with the help of [Buildroot], an embedded Linux build manager, this
repository ships an [8.7MB Linux distribution][linux-image] that's capable of
running under [QEMU] and launching our pre-built CockroachDB binaries. To verify
the Linux binaries, we first boot this Linux distribution on an emulated
pre-SSE4.2 CPU (`qemu-system-x86_64 -cpu qemu64,-sse4.2`), then run our sanity
checks from inside this VM.

<sup>†</sup><small>SSE4.2 support is particularly important in CockroachDB,
since RocksDB internally uses a [CRC32C checksum][crc32c] to protect against
data corruption. SSE4.2 includes hardware support for computing CRC32C
checksums, but is only available on CPUs released after November 2008. Producing
a binary that can dynamically switch between the SSE4.2 and non-SSE4.2
implementations at runtime [has proven difficult][issue-15589].
</small>

### Updating the Linux image

After [installing Buildroot][buildroot-install]:

```shell
$ make qemu_x86_64_glibc_defconfig BR2_EXTERNAL=buildroot
$ make menuconfig # Only if configuration changes are necessary.
$ make
$ cp output/images/bzImage images/qemu_x86_64_glibc_bzImage
```

At the time of writing, `qemu_x86_64_glibc_defconfig` instructed Buildroot to
build a Linux 4.9 kernel, install Bash and OpenSSH into userland, and configure
sshd to boot at startup and allow passwordless `root` authentication.
`/etc/fstab` is modified to mount the first hard drive at `/bincheck`, assuming
it's a FAT volume.

[buildroot-install]: https://buildroot.org/download.html
[issue-15589]: https://github.com/cockroachdb/cockroach/issues/15589
[linux-image]: ./images/qemu_x86_64_glibc_bzImage
[Buildroot]: https://buildroot.org
[CRC32C]: http://www.evanjones.ca/crc32c.html
[QEMU]: http://qemu.org
4 changes: 2 additions & 2 deletions build/release/bincheck/bincheck
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ echo ""
# Start node with encryption enabled.
"$cockroach" start-single-node --insecure --listening-url-file="$urlfile" --enterprise-encryption=path=cockroach-data,key=aes-128.key,old-key=plain --pid-file="$pidfile" &

trap "kill -9 $! &> /dev/null" EXIT
trap "kill -9 $! || true" EXIT
for i in {0..3}
do
[[ -f "$urlfile" ]] && break
Expand All @@ -58,7 +58,7 @@ diff -u expected actual

# Attempt a clean shutdown for good measure. We'll force-kill in the atexit
# handler if this fails.
cat "$pidfile" | xargs kill -TERM
kill -TERM $(cat "$pidfile") || true
trap - EXIT

# Verify reported version matches expected version.
Expand Down
35 changes: 0 additions & 35 deletions build/release/bincheck/buildroot.patch

This file was deleted.

Empty file.
Empty file.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions build/release/bincheck/buildroot/external.desc

This file was deleted.

Empty file.
Binary file not shown.
26 changes: 1 addition & 25 deletions build/release/bincheck/test-linux
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,4 @@ COCKROACH_VERSION=$1
COCKROACH_SHA=$2

download_and_extract "$COCKROACH_VERSION" "linux-amd64.tgz"

ssh() {
command ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
root@localhost -p 2222 "$@"
}

qemu-system-x86_64 \
-cpu qemu64,-sse4.2 \
-m 1G \
-kernel images/qemu_x86_64_glibc_bzImage \
-net nic,model=virtio -net user,hostfwd=tcp::2222-:22 \
-drive file=fat:rw:mnt,format=raw \
-nographic &

trap "kill -9 $! &> /dev/null" EXIT

for i in {0..4}
do
ssh true && break
backoff=$((2 ** i))
echo "VM not yet available; sleeping for $backoff seconds"
sleep $backoff
done

ssh /bin/bash -s /bincheck/cockroach "$COCKROACH_VERSION" "$COCKROACH_SHA" < bincheck
./bincheck ./mnt/cockroach "$COCKROACH_VERSION" "$COCKROACH_SHA"

0 comments on commit a035256

Please sign in to comment.