CI: Allow a GitHub container registry mirror to be specified
PATCH 1/2 CI: Allow a GitHub container registry mirror to be specified
From: Peter Hoyes <[email protected]>
To make the pipeline slightly more resilient to external networking issues, allow a local container registry mirror to be specified in the GitLab settings. If not specified, the upstream container registry is used automatically.
--- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
.gitlab-ci.yml +2 -1
@@ -1,9 +1,10 @@ -image: ghcr.io/siemens/kas/kas:3.3 +image: ${MIRROR_GHCR}/siemens/kas/kas:3.3 variables: CPU_REQUEST: "" DEFAULT_TAG: "" CACHE_DIR: $CI_BUILDS_DIR/persist + MIRROR_GHCR: ghcr.io # These are needed as the k8s executor doesn't respect the container entrypoint # by default FF_KUBERNETES_HONOR_ENTRYPOINT: 1
Signature · 1 line
2.34.1
PATCH 2/2 CI: Make update-repos more resilient to network issues
From: Peter Hoyes <[email protected]>
The update-repos script currently exits immediately if one of the underlying Git commands fails (e.g. because of a network issue). If the repo already exists, then catch this error inside the loop and carrying on attempting to update other repos, as the network error may be upstream.
KAS_REPO_REF_DIR is ultimately an optimization and subsequent build stages should be able to continue if one of the updates fail. Therefore, ensure the script returns a special error code if at least of the Git commands fail, and use this to set the allow_failure property of the job.
If a repo does not exist, fail immediately as before.
--- .gitlab-ci.yml | 2 ++ ci/update-repos | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-)
.gitlab-ci.yml +2 -0
@@ -77,6 +77,8 @@ stages: update-repos: extends: .setup stage: prep + allow_failure: + exit_codes: 128 script: - | flock --verbose --timeout 60 $KAS_REPO_REF_DIR ./ci/update-repos
ci/update-repos +10 -2
@@ -32,6 +32,7 @@ if __name__ == "__main__": sys.exit(1) base_repodir = pathlib.Path(os.environ["KAS_REPO_REF_DIR"]) + failed = False for repo in repositories: repodir = base_repodir / repo_shortname(repo)
@@ -41,8 +42,15 @@ if __name__ == "__main__": shutil.rmtree(repodir, ignore_errors=True) if repodir.exists(): - print("Updating %s..." % repo) - subprocess.run(["git", "-C", repodir, "-c", "gc.autoDetach=false", "fetch"], check=True) + try: + print("Updating %s..." % repo) + subprocess.run(["git", "-C", repodir, "-c", "gc.autoDetach=false", "fetch"], check=True) + except subprocess.CalledProcessError as e: + print(e) + failed = True else: print("Cloning %s..." % repo) subprocess.run(["git", "clone", "--bare", repo, repodir], check=True) + + if failed: + sys.exit(128)
Signature · 1 line
2.34.1
Jon Mason
AppliedQuoted 6 lines · Peter Hoyes
To make the pipeline slightly more resilient to external networking issues, allow a local container registry mirror to be specified in the GitLab settings. If not specified, the upstream container registry is used automatically.
Applied, thanks!
[1/2] CI: Allow a GitHub container registry mirror to be specified
commit: b6668069b8364f910fe6da06bfb58b96fff2c276
[2/2] CI: Make update-repos more resilient to network issues
commit: df01b29f3f54a82886a2852dcdd9c0359ecfee81Best regards,
Signature · 1 line
Jon Mason <[email protected]>