batch_exec: inject docker container registry as a prefix#945
batch_exec: inject docker container registry as a prefix#945danieldides wants to merge 2 commits intomainfrom
Conversation
| environ[pair[0]] = pair[1] | ||
| } | ||
|
|
||
| dockerPrefix, ok := environ["DOCKER_PREFIX_REGISTRY_URL"] |
There was a problem hiding this comment.
could we instead make this a flag that the server passes? Or do we want to configure this per-executor?
That way we wouldn't need to parse the env here.
| if ok { | ||
| for i := 0; i < len(task.Steps); i++ { | ||
| step := &task.Steps[i] | ||
| step.Container = fmt.Sprintf("%s/%s", dockerPrefix, step.Container) |
There was a problem hiding this comment.
Changing the step might change the cache key, which which would case a mismatch between backend and src-cli 🤔 I'd need to validate that, but if that's the case we should only change it when we actually use the images, not on the step element itself.
There was a problem hiding this comment.
If you want to validate that yourself, you'd want to run a spec with 2 steps, execute, change the 2nd step command or whatever, and see if a re-execution would hit a cache result for step1 and then if src-cli correctly sees it and skips step 1 in execution.
Part of https://github.com/sourcegraph/customer/issues/1872
Depends on: https://github.com/sourcegraph/sourcegraph/pull/48499
This checks for the presence of an optional environment variable passed to the
src batch execdirective that contains a docker registry URL. If it's present, it prefixes the container name with the registry information to create a fully-qualified domain name for all subsequent docker commands.Test plan
Batch spec:
Add
before the
docker.NewImageCache()function call.Execute a batch change without the environment variable set (default):
Note the container name is just
1.35.0.Execute a batch change with the environment variable set:
Restart
sg start batchessetting:Or similar in

sg.config.yaml. Restart the batch change (you may need to make a small change to it to prevent cached results from showing):Note the container name is now fully prefixed.