Skip to content

Commit 94de12e

Browse files
committed
Fix registry mirroring race condition
1 parent af2a59a commit 94de12e

3 files changed

Lines changed: 34 additions & 31 deletions

File tree

test/bin/ci_phase_iso_build.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ update_build_cache() {
7878
$(dry_run) bash -x ./bin/build_bootc_images.sh -g ./image-blueprints-bootc/templates
7979
$(dry_run) bash -x ./bin/mirror_registry.sh
8080

81-
# Build the bootc layers in parallel
82-
$(dry_run) bash -xc './bin/build_bootc_images.sh -l ./image-blueprints-bootc/el9/layer1-base -l ./image-blueprints-bootc/el9/layer4-release' &
81+
# Build the bootc layers in parallel, skipping extraction and mirroring (-E)
82+
# as they were already done by the templates build above
83+
$(dry_run) bash -xc './bin/build_bootc_images.sh -E -l ./image-blueprints-bootc/el9/layer1-base -l ./image-blueprints-bootc/el9/layer4-release' &
8384
pid_bootc9=$!
84-
$(dry_run) bash -xc './bin/build_bootc_images.sh -l ./image-blueprints-bootc/el10/layer1-base -l ./image-blueprints-bootc/el10/layer4-release' &
85+
$(dry_run) bash -xc './bin/build_bootc_images.sh -E -l ./image-blueprints-bootc/el10/layer1-base -l ./image-blueprints-bootc/el10/layer4-release' &
8586
pid_bootc10=$!
8687

8788
# Wait for all the build processes to complete, exit early and clean up if any command fails

test/bin/mirror_registry.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ QUAY_STORAGE_DIR="${MIRROR_REGISTRY_DIR}/storage"
1414
PULL_SECRET=${PULL_SECRET:-${HOME}/.pull-secret.json}
1515
QUAY_PULL_SECRET="${QUAY_CONFIG_DIR}/pull_secret.json"
1616

17+
registry_is_running() {
18+
[ -n "$(sudo podman ps -q --filter "name=microshift-postgres" --filter "status=running")" ] &&
19+
[ -n "$(sudo podman ps -q --filter "name=microshift-redis" --filter "status=running")" ] &&
20+
[ -n "$(sudo podman ps -q --filter "name=microshift-quay" --filter "status=running")" ]
21+
}
22+
1723
reset_storage_permissions() {
1824
# Ensure that the current user owns the mirror registry directories and files
1925
if [ -d "${MIRROR_REGISTRY_DIR}" ] ; then
@@ -145,14 +151,6 @@ setup_registry() {
145151
local redis_ip
146152
local new_db=false
147153

148-
# No setup is necessary if ALL the containers are already running
149-
if [ -n "$(sudo podman ps -q --filter "name=microshift-postgres" --filter "status=running")" ] &&
150-
[ -n "$(sudo podman ps -q --filter "name=microshift-redis" --filter "status=running")" ] &&
151-
[ -n "$(sudo podman ps -q --filter "name=microshift-quay" --filter "status=running")" ] ; then
152-
echo "All containers are running - skipping mirror registry setup"
153-
return
154-
fi
155-
156154
# Delete running containers if any
157155
for n in postgres redis quay ; do
158156
local cn="microshift-${n}"
@@ -428,8 +426,12 @@ if [ -n "${release_info_dir}" ] && [ ! -d "${release_info_dir}" ]; then
428426
exit 1
429427
fi
430428

431-
setup_prereqs
432-
setup_registry
429+
if registry_is_running; then
430+
echo "Mirror registry is already running - skipping setup"
431+
else
432+
setup_prereqs
433+
setup_registry
434+
fi
433435
mirror_images "${image_list_file}" "${release_info_dir}"
434436
finalize_registry
435437
echo "OK"

test/bin/pyutils/build_bootc_images.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ def main():
660660
parser = argparse.ArgumentParser(description="Build image layers using Bootc Image Builder and Podman.")
661661
parser.add_argument("-d", "--dry-run", action="store_true", help="Dry run: skip executing build commands.")
662662
parser.add_argument("-f", "--force-rebuild", action="store_true", help="Force rebuilding images that already exist.")
663-
parser.add_argument("-E", "--no-extract-images", action="store_true", help="Skip container image extraction.")
663+
parser.add_argument("-E", "--no-extract-images", action="store_true", help="Skip container image extraction, template processing, and registry mirroring.")
664664
parser.add_argument("-X", "--skip-all-builds", action="store_true", help="Skip all image builds.")
665665
parser.add_argument("-b", "--build-type",
666666
choices=["image-bootc", "image-installer", "containerfile", "container-encapsulate"],
@@ -715,11 +715,11 @@ def main():
715715

716716
# Determine versions of RPM packages
717717
set_rpm_version_info_vars()
718-
# Prepare container images list for mirroring registries
719-
common.delete_file(CONTAINER_LIST)
720718
if args.no_extract_images:
721-
common.print_msg("Skipping container image extraction")
719+
common.print_msg("Skipping container image extraction and mirroring")
722720
else:
721+
# Prepare container images list for mirroring registries
722+
common.delete_file(CONTAINER_LIST)
723723
extract_container_images(SOURCE_VERSION, LOCAL_REPO, CONTAINER_LIST, args.dry_run)
724724
# The following images are specific to layers that use fake rpms built from source
725725
extract_container_images(f"4.{FAKE_NEXT_MINOR_VERSION}.*", NEXT_REPO, CONTAINER_LIST, args.dry_run)
@@ -738,20 +738,20 @@ def main():
738738
extract_container_images(BREW_EC_RELEASE_VERSION, BREW_REPO, CONTAINER_LIST, args.dry_run)
739739
if BREW_NIGHTLY_RELEASE_VERSION:
740740
extract_container_images(BREW_NIGHTLY_RELEASE_VERSION, BREW_REPO, CONTAINER_LIST, args.dry_run)
741-
# Sort the images list, only leaving unique entries
742-
common.sort_uniq_file(CONTAINER_LIST)
743-
# Process package source templates
744-
ipkgdir = f"{SCRIPTDIR}/../package-sources-bootc"
745-
for ifile in os.listdir(ipkgdir):
746-
# Create full path for output and input file names
747-
ofile = os.path.join(BOOTC_IMAGE_DIR, ifile)
748-
ifile = os.path.join(ipkgdir, ifile)
749-
run_template_cmd(ifile, ofile, args.dry_run)
750-
751-
tpldir = os.path.join(SCRIPTDIR, "..", "image-blueprints-bootc", "templates")
752-
process_template_files(tpldir, args.dry_run)
753-
# Run the mirror registry
754-
common.run_command([f"{SCRIPTDIR}/mirror_registry.sh"], args.dry_run)
741+
# Sort the images list, only leaving unique entries
742+
common.sort_uniq_file(CONTAINER_LIST)
743+
# Process package source templates
744+
ipkgdir = f"{SCRIPTDIR}/../package-sources-bootc"
745+
for ifile in os.listdir(ipkgdir):
746+
# Create full path for output and input file names
747+
ofile = os.path.join(BOOTC_IMAGE_DIR, ifile)
748+
ifile = os.path.join(ipkgdir, ifile)
749+
run_template_cmd(ifile, ofile, args.dry_run)
750+
751+
tpldir = os.path.join(SCRIPTDIR, "..", "image-blueprints-bootc", "templates")
752+
process_template_files(tpldir, args.dry_run)
753+
# Run the mirror registry
754+
common.run_command([f"{SCRIPTDIR}/mirror_registry.sh"], args.dry_run)
755755
# Skip all image builds
756756
if args.skip_all_builds:
757757
common.print_msg("Skipping all image builds")

0 commit comments

Comments
 (0)