Repository navigation
ci(checks): a job that builds or runs an image of Docker Hub has the mirror as a second source - #448
Merged
Merged
Conversation
…mirror as a second source Docker Hub refused pulls for its limit and its token service did not answer, and three pull requests left the merge queue for it. 14 jobs build or run an image of Docker Hub; five of them are required checks. One step gives the Docker service of the runner a mirror and pulls the images that a job runs by the mirror's own name. A runner is logged in to Docker Hub, and for docker run the service sends that login to the mirror, which refuses it; by the mirror's own name no login goes. A builder job sets its builder up from the mirror first and from Docker Hub second. A test reads the workflow files: every such job has the step before its first docker command, and the step is given the very images that the job runs.
…one settings file only The script took the path of the settings file from its caller and wrote there. It is now a filter: the text of the settings goes in, the text with the mirror comes out. The step reads the one file and puts the new one in its place, with the mode it had. It refuses every other name: only its tests name a file of their own, and that one has to lie in the folder for temporary files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A job that builds or runs an image of Docker Hub gets a second source for it, a mirror, so that a limit or a fault of Docker Hub does not turn the checks red.
This changes three workflow files, and adds one shared step, its script and a test file. No Dockerfile changes, no secret is used, and no setting of the repository changes. What starts being checked is below. Nothing stops being checked.
What users will notice
Nothing.
Why
auth.docker.io). Docker's status page showed no incident.What changes
One step,
.github/actions/docker-hub-mirror, at the start of each of the 14 jobs, right after the checkout. It does two things:registry-mirrorsin the settings file of the runner's Docker service, tohttps://mirror.gcr.io, and starts the service again. A build then asks the mirror first and Docker Hub second. When the service does not come back, or does not name the mirror, the step is red with its fix and no later step runs. The step writes that one settings file and no other: the scriptscripts/docker_hub_mirror.pyopens no file, it reads the text of the settings and prints the text with the mirror.docker runby the mirror's own name, and gives them the name of Docker Hub. When the mirror does not give an image, the step says so and the job pulls it from Docker Hub, as before.The four
PR build checkjobs have a builder of their own. They set it up in two steps: the first names the builder's own image at the mirror and may fail without failing the job; the second is the step of before and runs only when the first failed. Both give the builder the mirror for its base images.sandbox smokejobs andsandbox tests (containerized)PR build checkjobsWhy the mirror in the settings is not enough: the runs by hand
The first design was the setting alone. A try showed that it does not carry
docker run. Each run is on the branchtry/docker-hub-mirror, which is not part of this pull request, with the addresses of Docker Hub pointed to nowhere in the runner's hosts file.docker run ubuntu:22.04still failedHead "https://mirror.gcr.io/v2/library/ubuntu/manifests/22.04": unauthorized: authentication failed. A runner is logged in to Docker Hub. Fordocker runanddocker pullthe service sends that login to the mirror, the mirror refuses it, and the service goes on to Docker Hub. With no login a pull of the same kind passed. A plaindocker buildpassed with the login and withoutdocker runof two given images passed.docker build ./sandboxpassed and the sandbox answered.docker compose build sandboxpassed. A builder whose image was only on the machine under the name of Docker Hub failed: its setup step always pullsOne thing is for the tries alone: the builder had the runner's own network there, because that is how the block reaches the builder's container.
What starts being checked
tests/infrastructure/test_docker_hub_mirror.pyreads the workflow files:docker runcommands name, with the values of the matrix. An image that is run and not given would have Docker Hub as its one source again, with no sign.container:orservices:image of Docker Hub. GitHub pulls such an image before the first step, so no step can help it.sudothat runs nothing, so a broken refusal makes a test red and still touches no file.Proof
continue-on-errorof the first setup step, and four files that configure the checks.What changed after the first push
tests/infrastructure/test_dev_results.pyholds that thetestsworkflow uses two actions of this repository, the two that send results. The mirror step is a third one and sends nothing; the test now names it. The local runs of the first push had not run that file.Cost and limits
codeqljobs were red that evening too, and for another cause: they ended after their entry had left the merge queue, and their upload found no branch. That is not changed here.