#11120 Preparatory cleanup bits for work on https://pagure.io/releng/issue/11047
Merged a year ago by kevin. Opened a year ago by walters.
walters/releng sync-script-cleanups  into  main

@@ -64,6 +64,7 @@ 

  #   Need fXX-updates-canddiate to get actual latest nightly

  #

  build_name=$(koji -q latest-build --type=image f${1}-updates-candidate Fedora-Container-Base | awk '{print $1}')

+ minimal_build_name=$(koji -q latest-build --type=image f${1}-updates-candidate Fedora-Container-Minimal-Base | awk '{print $1}')

  

  if [[ ${1} -eq "$current_stable" ]]; then

      tagname="latest"
@@ -71,6 +72,42 @@ 

  if [[ ${1} -eq "$current_rawhide" ]]; then

      tagname="rawhide"

  fi

+ if [[ -z "$stage" ]]; then

+     registries=("registry.fedoraproject.org" "candidate-registry.fedoraproject.org" "quay.io/fedora")

+ else

+     registries=("registry.stg.fedoraproject.org" "candidate-registry.stg.fedoraproject.org")

+ fi

+ 

+ # Copy a local image to all necessary remote registries

+ copy_image() {

+     local src=$1; shift

+     local name=$1; shift

+     for registry in ${registries[@]}; do

+         skopeo copy $src docker://${registry}/${name}

+     done

+ }

+ 

+ # From already uploaded architecture-specific images, generate a manifest listed image

+ # on all registries

+ generate_manifest_list() {

+     local name=$1; shift

+     for registry in "${registries[@]}"

+     do

+         printf "Push manifest to ${registry}\n"

+         if [ -n "$tagname" ]

+         then

+             printf "tag is set: ${tagname}\n"

+             buildah rmi "${registry}/${name}:${tagname}" || true

+             buildah manifest create "${registry}/${name}:${tagname}" "${ARCHES[@]/#/docker://${registry}/${name}:${1}-}"

+             buildah manifest push "${registry}/${name}:${tagname}" "docker://${registry}/${name}:${tagname}" --all

+ 

+         fi

+         buildah rmi "${registry}/${name}:${1}" || true

+         buildah manifest create "${registry}/${name}:${1}" "${ARCHES[@]/#/docker://${registry}/fedora:${1}-}"

+         buildah manifest push "${registry}/${name}:${1}" "docker://${registry}/${name}:${1}" --all

+     done

+ }

+ 

  #

  # Version should not be higher than rawhide

  # Either there is a mistake or script is out of date
@@ -80,46 +117,20 @@ 

      exit 1

  fi

  

- minimal_build_name=$(koji -q latest-build --type=image f${1}-updates-candidate Fedora-Container-Minimal-Base | awk '{print $1}')

  if [[ -n ${build_name} ]]; then

      # Download the image

      work_dir=$(mktemp -d)

      pushd ${work_dir} &> /dev/null

      koji download-build --type=image  ${build_name}

      # Import the image

-     for arch in "${ARCHES[@]}"

-     do

+     for arch in "${ARCHES[@]}"; do

          xz -d ${build_name}.${arch}.tar.xz

-         # If ${stage} is a non-zero length string, then perform staging

-         if [[ -z "$stage" ]]; then

-             registries=("registry.fedoraproject.org" "candidate-registry.fedoraproject.org" "quay.io/fedora")

-             skopeo copy docker-archive:${build_name}.${arch}.tar docker://registry.fedoraproject.org/fedora:${1}-${arch}

-             skopeo copy docker-archive:${build_name}.${arch}.tar docker://candidate-registry.fedoraproject.org/fedora:${1}-${arch}

-             skopeo copy docker-archive:${build_name}.${arch}.tar docker://quay.io/fedora/fedora:${1}-${arch}

-         else

-             registries=("registry.stg.fedoraproject.org" "candidate-registry.stg.fedoraproject.org")

-             skopeo copy docker-archive:${build_name}.${arch}.tar docker://registry.stg.fedoraproject.org/fedora:${1}-${arch}

-             skopeo copy docker-archive:${build_name}.${arch}.tar docker://candidate-registry.stg.fedoraproject.org/fedora:${1}-${arch}

-         fi

+         copy_image docker-archive:${build_name}.${arch}.tar fedora:${1}-${arch}

      done

  

      popd &> /dev/null

  

-     for registry in "${registries[@]}"

-     do

-         printf "Push manifest to ${registry}\n"

-         if [ -n "$tagname" ]

-         then

-             printf "tag is set: ${tagname}\n"

-             buildah rmi "${registry}/fedora:${tagname}" || true

-             buildah manifest create "${registry}/fedora:${tagname}" "${ARCHES[@]/#/docker://${registry}/fedora:${1}-}"

-             buildah manifest push "${registry}/fedora:${tagname}" "docker://${registry}/fedora:${tagname}" --all

- 

-         fi

-         buildah rmi "${registry}/fedora:${1}" || true

-         buildah manifest create "${registry}/fedora:${1}" "${ARCHES[@]/#/docker://${registry}/fedora:${1}-}"

-         buildah manifest push "${registry}/fedora:${1}" "docker://${registry}/fedora:${1}" --all

-     done

+     generate_manifest_list fedora

      printf "Removing temporary directory\n"

      rm -rf $work_dir

  fi
@@ -129,41 +140,14 @@ 

      pushd ${work_dir} &> /dev/null

      koji download-build --type=image  ${minimal_build_name}

      # Import the image

-     for arch in "${ARCHES[@]}"

-     do

+     for arch in "${ARCHES[@]}"; do

          xz -d ${minimal_build_name}.${arch}.tar.xz

-         # If ${stage} is a non-zero length string, then perform staging

-         if [[ -z "$stage" ]]; then

-             registries=("registry.fedoraproject.org" "candidate-registry.fedoraproject.org" "quay.io/fedora")

-             skopeo copy docker-archive:${minimal_build_name}.${arch}.tar docker://registry.fedoraproject.org/fedora-minimal:${1}-${arch}

-             skopeo copy docker-archive:${minimal_build_name}.${arch}.tar docker://candidate-registry.fedoraproject.org/fedora-minimal:${1}-${arch}

-             skopeo copy docker-archive:${minimal_build_name}.${arch}.tar docker://quay.io/fedora/fedora-minimal:${1}-${arch}

- 

-         else

-             registries=("registry.stg.fedoraproject.org" "candidate-registry.stg.fedoraproject.org")

-             skopeo copy docker-archive:${minimal_build_name}.${arch}.tar docker://registry.stg.fedoraproject.org/fedora-minimal:${1}-${arch}

-             skopeo copy docker-archive:${minimal_build_name}.${arch}.tar docker://candidate-registry.stg.fedoraproject.org/fedora-minimal:${1}-${arch}

-             skopeo copy docker-archive:${minimal_build_name}.${arch}.tar docker://quay.io/fedora/fedora-minimal:${1}-${arch}

-         fi

-      done

-      popd &> /dev/null

- 

-      for registry in "${registries[@]}"

-      do

-          printf "Push manifest to ${registry}\n"

-          if [ -n "$tagname" ]

-          then

-              printf "tag is set: ${tagname}\n"

-              buildah rmi "${registry}/fedora-minimal:${tagname}" || true

-              buildah manifest create "${registry}/fedora-minimal:${tagname}" "${ARCHES[@]/#/docker://${registry}/fedora-minimal:${1}-}"

-              buildah manifest push "${registry}/fedora-minimal:${tagname}" "docker://${registry}/fedora-minimal:${tagname}" --all

-          fi

-          buildah rmi "${registry}/fedora-minimal:${1}" || true

-          buildah manifest create "${registry}/fedora-minimal:${1}" "${ARCHES[@]/#/docker://${registry}/fedora-minimal:${1}-}"

-          buildah manifest push "${registry}/fedora-minimal:${1}" "docker://${registry}/fedora-minimal:${1}" --all

-      done

+         copy_image docker-archive:${minimal_build_name}.${arch}.tar fedora-minimal:${1}-${arch}

+     done

+     popd &> /dev/null

  

-      printf "Removing temporary directory\n"

-      rm -rf $work_dir

+     generate_manifest_list fedora-minimal

  

+     printf "Removing temporary directory\n"

+     rm -rf $work_dir

  fi

scripts/sync-container: Deduplicate assignment of registries

Prep for further work.

Signed-off-by: Colin Walters walters@verbum.org


scripts/sync-container: Consolidate assignments

Having the minimal_build_name = right before the comparison
for build_name was just confusing.

Signed-off-by: Colin Walters walters@verbum.org


scripts/sync-container: Dedup copy code

Prep for further work

Signed-off-by: Colin Walters walters@verbum.org


scripts/sync-container: Deduplicate manifest list code

Prep for further work.

Signed-off-by: Colin Walters walters@verbum.org


(The first two commits here are least risky and could be peeled off separately even)

I don't have commit access here, but the changes look well contained and good to me.

@cverna you've merged things in this repo before, could you have a look?

rebased onto db0cc00

a year ago

It looks ok to me too. Lets merge.

Pull-Request has been merged by kevin

a year ago

Thanks! Is there a place I can see the logs from this process?

Yep. Should be at the end of the output from the rawhide compose in the 'releng-cron' mailing list.

Here's todays:

https://lists.fedoraproject.org/archives/list/releng-cron@lists.fedoraproject.org/thread/G5RPFEQR4XKSCKDVEM5PGY7HGHRF2ANL/

OK...I think it worked?

That said one major problem with this script today is that it doesn't use set -e and so will happily plow forward on errors...and it looks to me like we may kind of be relying on that in the case where some container images aren't built on some architectures.

One odd thing... the 'rawhide' tag seems to have gone missing. ;( Could it be related to this change?

From the logs:

xz: Fedora-Container-Base-Rawhide-20221130.n.0.ppc64le.tar.xz: No such file or directory
time="2022-12-05T12:17:30Z" level=fatal msg="initializing source
docker-archive:Fedora-Container-Base-Rawhide-20221130.n.0.ppc64le.tar: opening file
\"Fedora-Container-Base-Rawhide-20221130.n.0.ppc64le.tar\": open
Fedora-Container-Base-Rawhide-20221130.n.0.ppc64le.tar: no such file or directory"
time="2022-12-05T12:17:30Z" level=fatal msg="initializing source
docker-archive:Fedora-Container-Base-Rawhide-20221130.n.0.ppc64le.tar: opening file
\"Fedora-Container-Base-Rawhide-20221130.n.0.ppc64le.tar\": open
Fedora-Container-Base-Rawhide-20221130.n.0.ppc64le.tar: no such file or directory"
time="2022-12-05T12:17:30Z" level=fatal msg="initializing source
docker-archive:Fedora-Container-Base-Rawhide-20221130.n.0.ppc64le.tar: opening file
\"Fedora-Container-Base-Rawhide-20221130.n.0.ppc64le.tar\": open
Fedora-Container-Base-Rawhide-20221130.n.0.ppc64le.tar: no such file or directory"
xz: Fedora-Container-Base-Rawhide-20221130.n.0.s390x.tar.xz: No such file or directory
time="2022-12-05T12:17:30Z" level=fatal msg="initializing source
docker-archive:Fedora-Container-Base-Rawhide-20221130.n.0.s390x.tar: opening file
\"Fedora-Container-Base-Rawhide-20221130.n.0.s390x.tar\": open
Fedora-Container-Base-Rawhide-20221130.n.0.s390x.tar: no such file or directory"
time="2022-12-05T12:17:30Z" level=fatal msg="initializing source
docker-archive:Fedora-Container-Base-Rawhide-20221130.n.0.s390x.tar: opening file
\"Fedora-Container-Base-Rawhide-20221130.n.0.s390x.tar\": open
Fedora-Container-Base-Rawhide-20221130.n.0.s390x.tar: no such file or directory"
time="2022-12-05T12:17:30Z" level=fatal msg="initializing source
docker-archive:Fedora-Container-Base-Rawhide-20221130.n.0.s390x.tar: opening file
\"Fedora-Container-Base-Rawhide-20221130.n.0.s390x.tar\": open
Fedora-Container-Base-Rawhide-20221130.n.0.s390x.tar: no such file or directory"
xz: Fedora-Container-Base-Rawhide-20221130.n.0.x86_64.tar.xz: No such file or directory
time="2022-12-05T12:17:30Z" level=fatal msg="initializing source
docker-archive:Fedora-Container-Base-Rawhide-20221130.n.0.x86_64.tar: opening file
\"Fedora-Container-Base-Rawhide-20221130.n.0.x86_64.tar\": open
Fedora-Container-Base-Rawhide-20221130.n.0.x86_64.tar: no such file or directory"
time="2022-12-05T12:17:30Z" level=fatal msg="initializing source
docker-archive:Fedora-Container-Base-Rawhide-20221130.n.0.x86_64.tar: opening file
\"Fedora-Container-Base-Rawhide-20221130.n.0.x86_64.tar\": open
Fedora-Container-Base-Rawhide-20221130.n.0.x86_64.tar: no such file or directory"
time="2022-12-05T12:17:30Z" level=fatal msg="initializing source
docker-archive:Fedora-Container-Base-Rawhide-20221130.n.0.x86_64.tar: opening file
\"Fedora-Container-Base-Rawhide-20221130.n.0.x86_64.tar\": open
Fedora-Container-Base-Rawhide-20221130.n.0.x86_64.tar: no such file or directory"

So yes, possibly. Please feel free to revert for now. As I've been working on adding the ostree-container stuff into this script I am just thinking that it will make more sense to have a separate script.

That said one major problem with this script today is that it doesn't use set -e and so will happily plow forward on errors...and it looks to me like we may kind of be relying on that in the case where some container images aren't built on some architectures.

koji latest-build will download the latest successful build which for all releases except rawhide means having all the architectures. But yeah we should definitely add set -e to exit on errors.

One odd thing... the 'rawhide' tag seems to have gone missing. ;( Could it be related to this change?

rawhide builds don't fail if an architecture fails so we had a build with only aarch64 and this was pushed to the rawhide tag and since we use a manifest list we don't have any matching images for x86 or other architecture.
Maybe we should require rawhide builds to have all architecture to be successful to avoid this in the future?

I did a manual run to push the rawhide and I had the following failures, i reverted the commits locally and I can try to look at this into more details tomorrow.

Push manifest to registry.fedoraproject.org
tag is set: rawhide
untagged: registry.fedoraproject.org/fedora:rawhide
99fe2a27cbc66b55069b5336f61234daa780391d7208f27e3e780920be02d877
Error: invalid reference format
Getting image list signatures
Copying 0 of 0 images in list
Writing manifest list to image destination
Storing list signatures
Error: 1 error occurred:
    * invalid reference format


Error: encountered while expanding image name "registry.fedoraproject.org/fedora:": parsing name "registry.fedoraproject.org/fedora:": cannot parse input: "registry.fedoraproject.org/fedora:": invalid reference format
Error: invalid reference format
Push manifest to candidate-registry.fedoraproject.org
tag is set: rawhide
untagged: candidate-registry.fedoraproject.org/fedora:rawhide
0470d7d675e313d61eba59b58ff44947d4eb7dd09f9c44f25570c87ab76878dd
Error: invalid reference format
Getting image list signatures
Copying 0 of 0 images in list
Writing manifest list to image destination
Storing list signatures
Error: 1 error occurred:
    * invalid reference format


Error: encountered while expanding image name "candidate-registry.fedoraproject.org/fedora:": parsing name "candidate-registry.fedoraproject.org/fedora:": cannot parse input: "candidate-registry.fedoraproject.org/fedora:": invalid reference format
Error: invalid reference format
Push manifest to quay.io/fedora
tag is set: rawhide
untagged: quay.io/fedora/fedora:rawhide
27db992635fb71d81c578ee782443976ae956d7060e3771e446ed94bb2ae316d
Error: invalid reference format
Getting image list signatures
Copying 0 of 0 images in list
Writing manifest list to image destination
Storing list signatures
Error: 1 error occurred:
    * invalid reference format


Error: encountered while expanding image name "quay.io/fedora/fedora:": parsing name "quay.io/fedora/fedora:": cannot parse input: "quay.io/fedora/fedora:": invalid reference format
Error: invalid reference format
Removing temporary directory

Needed a small fix https://pagure.io/releng/pull-request/11179# but it is now in production and working

Metadata