lava-dispatcher docker images - part 3

18 Jun 2018
Posted by stylesen

This is part 3 of the three part blog post series on lava-dispatcher only docker images. If you haven't read part 2 already, then read it on - https://www.stylesen.org/lavadispatcher_docker_images_part_2

Docker based LAVA Worker running Nexus 4 job with LXC protocol

This is the second use case in which we will look at starting a docker based LAVA worker and running a job that requests a Nexus 4 device type with LXC protocol. The following command is used to start a docker based LAVA worker,

stylesen@hanshu:~$ sudo docker run \
-v /home/stylesen/docker-slave-files:/fileshare \
-v /var/run/docker.sock:/var/run/docker.sock -v /dev:/dev -itd --privileged \ -e HOSTNAME='docker-slave-1' -e MASTER='tcp://lava.codehelp.co.uk:5556' \ -e SOCKET_ADDR='tcp://lava.codehelp.co.uk:5555' -e LOG_LEVEL='DEBUG' \
-e ENCRYPT=1 -e MASTER_CERT='/fileshare/master.key' \
-e SLAVE_CERT='/fileshare/docker-slave-1.key_secret' -p 2222:22 \
--name ld-latest linaro/lava-dispatcher-staging-stretch-amd64:latest

76e820c1df7e5f4a7fe45bf130052674f2489f4d0ce7bb5f5a70c21a32696ff4
stylesen@hanshu:~$

There is not much difference in the above command from what we used in use case one, except for couple of new options.

'-v /dev:/dev' - mounts the host machine's /dev directory inside the docker container at the location /dev This is required when we deal with actual (physical) devices in order to access these devices from within the docker container.

'--privileged' - this option is required to allow seamless passthrough and device access from within the container.

Once we have the docker based LAVA worker up and running with the new options in place, we can add a new nexus4 device to it. The name of the nexus4 device we will add to docker-slave-1 is 'nexus4-docker-slave-01'. Create a jinja2 template file for nexus4-docker-slave-01 and copy it to /etc/lava-server/dispatcher-config/devices/ on the LAVA master instance,

stylesen@codehelp:~$ sudo cat \
/etc/lava-server/dispatcher-config/devices/nexus4-docker-slave-01.jinja2

{% extends 'nexus4.jinja2' %}
{% set adb_serial_number = '04f228d1d9c76f39' %}
{% set fastboot_serial_number = '04f228d1d9c76f39' %}
{% set device_info = [{'board_id': '04f228d1d9c76f39'}] %}
{% set fastboot_options = ['-u'] %}
{% set flash_cmds_order = ['update', 'ptable', 'partition', 'cache', \
'userdata', 'system', 'vendor'] %}

{% set exclusive = 'True' %}
stylesen@codehelp:~$ sudo ls -alh \
/etc/lava-server/dispatcher-config/devices/nexus4-docker-slave-01.jinja2

-rw-r--r-- 1 lavaserver lavaserver 361 Jun 18 01:32 \
/etc/lava-server/dispatcher-config/devices/nexus4-docker-slave-01.jinja2

stylesen@codehelp:~$

In order to add the above device nexus4-docker-slave-01 to the LAVA master database and associate it with our docker based LAVA worker docker-slave-1, login to the LAVA master instance and issue the following command:

stylesen@codehelp:~$ sudo lava-server manage devices add \
--device-type nexus4 --worker docker-slave-1 nexus4-docker-slave-01

stylesen@codehelp:~$

The device will now be listed as part of the worker docker-slave-1 and could be seen in the link - https://lava.codehelp.co.uk/scheduler/worker/docker-slave-1

The job definition we will submit to the above device will be https://git.linaro.org/lava-team/refactoring.git/tree/health-checks/nexus4.yaml which is a normal job requesting a Nexus4 device type and runs a simple test on the device using LXC protocol.

stylesen@harshu:/tmp$ lavacli -i lava.codehelp jobs submit nexus4.yaml 
2491
stylesen@harshu:/tmp$

Thus job 2491 has been submitted successfully to LAVA instance lava.codehelp.co.uk and it ran successfully as seen in https://lava.codehelp.co.uk/scheduler/job/2491

Docker based LAVA Worker running Nexus 4 job without LXC protocol

This is the third use case in which we will look at starting a docker based LAVA worker and running a job that requests a Nexus 4 device type without LXC protocol. The following command is used to start a docker based LAVA worker, which is exactly same as use case two.

stylesen@hanshu:~$ sudo docker run \
-v /home/stylesen/docker-slave-files:/fileshare \
-v /var/run/docker.sock:/var/run/docker.sock -v /dev:/dev -itd --privileged \
-e HOSTNAME='docker-slave-1' -e MASTER='tcp://lava.codehelp.co.uk:5556' \
-e SOCKET_ADDR='tcp://lava.codehelp.co.uk:5555' -e LOG_LEVEL='DEBUG' \
-e ENCRYPT=1 -e MASTER_CERT='/fileshare/master.key' \
-e SLAVE_CERT='/fileshare/docker-slave-1.key_secret' -p 2222:22 \
--name ld-latest linaro/lava-dispatcher-staging-stretch-amd64:latest

76e820c1df7e5f4a7fe45bf130052674f2489f4d0ce7bb5f5a70c21a32696ff4
stylesen@hanshu:~$

We will use the same device added for use case two i.e., 'nexus4-docker-slave-01' in order to execute this job.

The job we will submit to the above device will be https://git.linaro.org/lava-team/refactoring.git/tree/minus-lxc/nexus4.yaml which is a normal job requesting a Nexus4 device type and runs a simple test on the device, without calling any LXC protocol.

stylesen@harshu:/tmp$ lavacli -i lava.codehelp jobs submit nexus4-minus-lxc.yaml 
2492
stylesen@harshu:/tmp$

Thus job 2492 has been submitted successfully to LAVA instance lava.codehelp.co.uk and it ran successfully as seen in https://lava.codehelp.co.uk/scheduler/job/2492

Hope this blog series helps to get started with using lava-dispatcher only docker images and running your own docker based LAVA workers. If you have any doubts, questions or comments, feel free to email the LAVA team at lava-users [@] lists [dot] linaro [dot] org

Read part 2 ...

Read all parts of this blog post series from below links:

  1. lava-dispatcher docker images - part 1 - Introduction, Details and Preparation
  2. lava-dispatcher docker images - part 2 - Docker based LAVA Worker running pure LXC job
  3. lava-dispatcher docker images - part 3 - Docker based LAVA Worker running Nexus 4 job with and without LXC Protocol