|
| 1 | +# Debugging executors |
| 2 | + |
| 3 | +This documents how to debug firecracker executors using GCP VMs since that doesn't work on Mac. |
| 4 | + |
| 5 | +First, create a VM in GCP that allows nested virtualization: |
| 6 | + |
| 7 | +```bash |
| 8 | +gcloud compute instances create \ |
| 9 | + executors-test \ |
| 10 | + --enable-nested-virtualization \ |
| 11 | + --zone=us-central1-a \ |
| 12 | + --min-cpu-platform="Intel Haswell" \ |
| 13 | + --project <YOUR_PROJECT> \ |
| 14 | + --boot-disk-size=50GB |
| 15 | +``` |
| 16 | + |
| 17 | +Then, connect to the instance via ssh: |
| 18 | + |
| 19 | +```bash |
| 20 | +gcloud compute ssh \ |
| 21 | + --zone "us-central1-a" \ |
| 22 | + --tunnel-through-iap \ |
| 23 | + --project <YOUR_PROJECT> \ |
| 24 | + executors-test |
| 25 | +``` |
| 26 | + |
| 27 | +Configure go to cross-compile a binary for linux amd64: |
| 28 | + |
| 29 | +```bash |
| 30 | +export GO111MODULE=on |
| 31 | +export GOARCH=amd64 |
| 32 | +export GOOS=linux |
| 33 | +export CGO_ENABLED=0 |
| 34 | +``` |
| 35 | + |
| 36 | +Build a go binary of executor for linux: |
| 37 | + |
| 38 | +```bash |
| 39 | +cd cmd/executor \ |
| 40 | + && go build \ |
| 41 | + -trimpath \ |
| 42 | + -buildmode exe \ |
| 43 | + -tags dist \ |
| 44 | + -o executor github.com/sourcegraph/sourcegraph/cmd/executor |
| 45 | +``` |
| 46 | + |
| 47 | +Copy the binary onto our new VM: |
| 48 | + |
| 49 | +```bash |
| 50 | +gcloud compute scp |
| 51 | + --tunnel-through-iap \ |
| 52 | + --project <YOUR_PROJECT> \ |
| 53 | + --zone us-central1-a \ |
| 54 | + executor <YOUR_USER>@executors-test:~/executor |
| 55 | +``` |
| 56 | + |
| 57 | +There is some more general info on how to set up a generic VM with the executor binary in linux, |
| 58 | +using firecracker [here](https://docs.sourcegraph.com/admin/executors/deploy_executors_binary), |
| 59 | +but it can be summarized as: |
| 60 | +- Install docker, git, and binutils |
| 61 | +- Set env vars `EXECUTOR_FRONTEND_URL`, `EXECUTOR_FRONTEND_PASSWORD`, `EXECUTOR_QUEUE_NAME`, `EXECUTOR_USE_FIRECRACKER` |
| 62 | +- Run `executor install all` (until here, everything only needs to happen once, unless you change the setup) |
| 63 | +- Run executor with `executor run` |
| 64 | + |
| 65 | +At this point, if you go to the sourcegraph instance that it’s connected to, |
| 66 | +you should see it appear in the executors site admin page, and also see it |
| 67 | +successfully pick up jobs with firecracker VMs enabled. |
| 68 | + |
| 69 | +Pro tip: `executor test-vm` spins up a long lived firecracker VM for you the same way (networking, |
| 70 | +disk, etc) it would during the job so you can inspect it, ssh into it and try |
| 71 | +things out. Warning: they get pruned when the actual executor is running, as it |
| 72 | +finds them as oprhaned VMs. |
| 73 | + |
| 74 | +Finally, to clean up after yourself when done: |
| 75 | + |
| 76 | +```bash |
| 77 | +gcloud compute instances delete \ |
| 78 | + --zone=us-central1-a \ |
| 79 | + --project sourcegraph-dogfood \ |
| 80 | + executors-test |
| 81 | +``` |
0 commit comments