sourcegraph/cmd/executor
sourcegraph-release-bot 3458e82e36
[Backport 5.4.5099] release: never use build number in image family (#63178)
the executor image and docker mirror image should now follow the
following naming convention:

Image family:
`sourcegraph-executors-[nightly|internal|'']-<MAJOR>-<MINOR>`
Image name:
`sourcegraph-executor-[nightly|internal|'']-<MAJOR>-<MINOR>-<BUILD_NUMBER>`

example:
Image family: `sourcegraph-executors-5-4`
Image name: `sourcegraph-executor-5-4-277666`

## What happens during releases and _not_ releases?
#### Nightly
**`nightly` suffix**
Image family:
`sourcegraph-executors-nightly-<MAJOR>-<MINOR>`
Image name:
`sourcegraph-executor-nightly-<MAJOR>-<MINOR>-<BUILD_NUMBER>`
#### Internal
**`internal` suffix**
Image family:
`sourcegraph-executors-internal-<MAJOR>-<MINOR>`
Image name:
`sourcegraph-executor-internal-<MAJOR>-<MINOR>-<BUILD_NUMBER>`
#### Public / Promote to public

** No suffix **

Image family: `sourcegraph-executors-<MAJOR>-<MINOR>`
Image name:
`sourcegraph-executor-<MAJOR>-<MINOR>-<BUILD_NUMBER>`

>  [!IMPORTANT]
> Should we keep the imagine name stable at
`sourcegraph-executor-<MAJOR>-<MINOR>-<BUILD_NUMBER>`
> and only change the family name? 
>
> **Why?**
>
> The Image family dictates the collection of images and that changes
each major minor and or release phase so there is really no use in
changing the image name too, except at a glance you can see from the
name what image family it belongs to?
## Test plan




## Changelog




 <br> Backport 8bb0ab54eb from #63157

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2024-06-10 09:29:06 +01:00
..
docker-mirror [Backport 5.4.5099] release: never use build number in image family (#63178) 2024-06-10 09:29:06 +01:00
internal lib/background: upgrade Routine interface with context and errors (#62136) 2024-05-24 10:04:55 -04:00
kubernetes Move executor-kubernetes out of enterprise (#56449) 2023-09-08 16:24:05 +02:00
vm-image [Backport 5.4.5099] release: never use build number in image family (#63178) 2024-06-10 09:29:06 +01:00
_binary.push.sh rfc795: new release process foundations (#60962) 2024-03-12 17:12:22 +01:00
BUILD.bazel bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
ci-should-rebuild.sh ci: fix incorrect usage of target determinator (#59171) 2023-12-21 15:50:29 +00:00
image_test.yaml
main.go Docs: update links to point to new site (#60381) 2024-02-13 00:23:47 +00:00
README.md Port executors building/pushing scripts to use Bazel (#58892) 2023-12-20 18:33:49 +00:00

Executor

The executor service polls the public frontend API for work to perform. The executor will pull a job from a particular queue (configured via the envvar EXECUTOR_QUEUE_NAME), then performs the job by running a sequence of docker and src-cli commands. This service is horizontally scalable.

Since executors and Sourcegraph are separate deployments, our agreement is to support 1 minor version divergence for now. See this example for more details:

Sourcegraph version Executor version Ok
3.43.0 3.43.*
3.43.3 3.43.*
3.43.0 3.44.*
3.43.0 3.42.*
3.43.0 3.41.* 🚫
3.43.0 3.45.* 🚫

See the executor queue for a complete list of queues.

Building and releasing

Building and releasing is handled automatically by the CI pipeline.

Binary

The executor binary is simply built with bazel build //cmd/executor:executor.

For publishing it, see bazel run //cmd/executor:binary.push:

  • In every scenario, the binary will be uploaded to gcs://sourcegraph-artifacts/executors/$GIT_COMMIT/.
  • If the current branch is main when this target is run, it will also be copied over to gcs://sourcegraph-artifacts/executors/latest.
  • If the env var EXECUTOR_IS_TAGGED_RELEASE is set to true, it will also be copied over to gcs://sourcegraph-artifacts/executors/$BUILDKITE_TAG.

VM image

The VM Image is built with packer, but it also uses an OCI image as a base for Firecracker, //docker-images/executor-vm:image_tarball which it depends on. That OCI image is a legacy image, see docker-images/executor-vm/README.md.

Because we're producing an AMI for both AWS and GCP, there are two steps involved:

  • bazel run //cmd/executor/vm-image:ami.build creates the AMI and names it according to the CI runtype.
  • bazel run //cmd/executor/vm-image:ami.push takes the AMIs from above and publish them (adjust perms, naming).

While gcloud is provided by Bazel, AWS cli is expected to be available on the host running Bazel.

Building AMIs on GCP is rather quick, but it's notoriously slow on AWS (about 20m) so we use target-determinator to detect when to rebuild the image. See ci-should-rebuild.sh, which is used by the pipeline generator to skip building it if we detect that nothing changed since the parent commit.

Docker Mirror

As with the VM image, we're producing an AMI for both AWS and GCP, there are two steps involved:

  • bazel run //cmd/executor/docker-mirror:ami.build creates the AMI and names it according to the CI runtype.
  • bazel run //cmd/executor/docker-mirror:ami.push takes the AMIs from above and publish them (adjust perms, naming).

While gcloud is provided by Bazel, AWS cli is expected to be available on the host running Bazel.