Continuous integration/Qemu

From mediawiki.org

Runbook[edit]

Agent[edit]

To provision a new agent, follow Nova Resource:Integration/Setup to set up an agent for Jenkins.

Qemu[edit]

To setup Qemu and the VM images, apply the Puppet role `role::ci::agent::qemu` via Horizon. It will: - generate a ssh key pair - create an image based on the Debian official cloud images - customize the image to enable ssh and add extra Debian packages

Puppet invokes ci-build-images /srv/vm-images. It is provisioned by Puppet from modules/profile/files/ci/ci-build-images.sh.


The image can be manually booted using:

 qemu-system-x86_64 -nographic -m 4G -snapshot /srv/vm-images/debian-11-ci.qcow2

Wait for the bootloader to pass, then once "img login:" appears, enter "root".

Use Ctrl-A X to exit from Qemu.

Launch for remote control[edit]

This is how Jenkins jobs launch the VM, rather than getting an interactive shell directly from Qemu, we we launch the Qemu with an SSH port exposed, and login that way:

# Terminal 1 (launch guest VM)
you@agent$ qemu-system-x86_64 -device virtio-net,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::4293-:22 -smp 4 -m 4096 -nographic -snapshot /srv/vm-images/debian-11-ci.qcow2
…

# Terminal 2 (create copy of key, then open shell via ssh)
you@agent$ install -m 600 /srv/vm-images/sshkey_qemu_root_v1 root.key 
you@agent$ ssh -i ./root.key -p 4293 root@localhost
…
root@img# …
root@img# exit

Jenkins Jobs[edit]

The Jenkins jobs currently use https://gerrit.wikimedia.org/g/integration/config/+/master/jjb/qemu-run.bash

After publishing a new image, update this script to point to the new image version.

When making changes to this script, you will need to regenerate the Jenkins jobs that embed this script for the changes to take effect. (see Continuous integration/Jenkins job builder).