Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use copr rpms for the community workers #4129

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions templates/packer/ansible/roles/common/tasks/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- name: Add osbuild-composer repository
tags:
- rpmrepo
- rpmrepo_composer
yum_repository:
name: "composer"
description: "osbuild-composer commit {{ COMPOSER_COMMIT }}"
Expand All @@ -13,7 +13,8 @@

- name: Add osbuild repository
tags:
- rpmrepo
- rpmrepo_osbuild
- rpmcopr
yum_repository:
name: "osbuild"
description: "osbuild commit {{ osbuild_commit }}"
Expand Down Expand Up @@ -104,11 +105,28 @@
priority=1

- name: Install worker rpm
tags:
- rpmcopy
- rpmrepo_osbuild
package:
name:
- osbuild-composer-worker
state: present

- name: Install worker rpm from copr
tags:
- rpmcopr
shell: |
dnf copr enable -y @osbuild/osbuild-composer
COMPOSER_COMMIT_SHORT=$(echo {{ COMPOSER_COMMIT }} | head -c 9)
COMPOSER_RPMS=$(dnf search -q --showduplicates osbuild-composer | grep -E "osbuild-composer-worker-[0-9]+.*g$COMPOSER_COMMIT_SHORT.*{{ ansible_architecture }}" | cut -f 1 -d ':')
if [ -z $COMPOSER_RPMS ]; then
echo $COMPOSER_COMMIT_SHORT worker rpms not available for on @osbuild/osbuild-composer copr
exit 1
fi
echo "installing rpms $COMPOSER_RPMS"
dnf install -y $COMPOSER_RPMS

schuellerf marked this conversation as resolved.
Show resolved Hide resolved
- name: Cleanup rpmbuild dir
file:
path: "{{ item }}"
Expand Down
78 changes: 67 additions & 11 deletions tools/appsre-build-fedora-worker-packer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,80 @@ set -exv
export SKIP_CREATE_AMI=false
# Use prebuilt rpms for the fedora images
export BUILD_RPMS=false
export SKIP_TAGS="rpmcopy,subscribe"
# Fedora community workers use osbuild form rpmrepo + composer from
# copr, as the osbuild rpms from copr disappear too quickly.
export SKIP_TAGS="rpmrepo_composer,rpmcopy,subscribe"
FEDORA=fedora-38
export PACKER_ONLY_EXCEPT=--only=amazon-ebs."$FEDORA"-x86_64,amazon-ebs."$FEDORA"-aarch64

# wait until the rpms are built upstream
COMMIT_SHA="${COMMIT_SHA:-$(git rev-parse HEAD)}"
while true; do
RET=$(curl -w "%{http_code}" -s -o /dev/null http://osbuild-composer-repos.s3.amazonaws.com/osbuild-composer/"$FEDORA"/x86_64/"$COMMIT_SHA"/state.log)
if [ "$RET" != 200 ]; then
sleep 30
continue
# wait up to 10 minutes for the packit-as-a-service app (app id being 29076)
for RETRY in {1..11}; do
if [ "$RETRY" = 11 ]; then
echo Waiting for the packit-as-a-service suite failed after 10 minutes
exit 1
fi
RET=$(curl -w "%{http_code}" -s -o /dev/null http://osbuild-composer-repos.s3.amazonaws.com/osbuild-composer/"$FEDORA"/aarch64/"$COMMIT_SHA"/state.log)
if [ "$RET" != 200 ]; then
sleep 30

CHECK_SUITES=$(curl --request GET --url "https://api.github.com/repos/osbuild/osbuild-composer/commits/$COMMIT_SHA/check-suites?app_id=29076")
CHECK_SUITES_COUNT=$(echo "$CHECK_SUITES" | jq -r .total_count)
if [ "$CHECK_SUITES_COUNT" != 1 ]; then
echo Waiting for the packit-as-a-service suite upstream
sleep 60
continue
fi

echo Packit-as-a-service suite present \(total_count "$CHECK_SUITES_COUNT"\)
break
done

CHECK_RUNS_URL=$(echo "$CHECK_SUITES" | jq -r .check_suites[0].check_runs_url)
if [ "$CHECK_RUNS_URL" = null ]; then
echo CHECK_RUNS_URL not found in "$CHECK_SUITES"
exit 1
fi

# wait up to 30 minutes for the rpms to be built
for RETRY in {1..31}; do
if [ "$RETRY" = 31 ]; then
echo Waiting for the packit-as-a-service results failed after 30 minutes
exit 1
fi

CHECK_RUNS_RESULT=$(curl "$CHECK_RUNS_URL")
CHECK_RUNS_RESULT_COUNT=$(echo "$CHECK_RUNS_RESULT" | jq -r .total_count)
if [ "$CHECK_RUNS_RESULT_COUNT" = 0 ] || [ "$CHECK_RUNS_RESULT_COUNT" = null ]; then
echo No results in "$CHECK_RUNS_RESULT", waiting
sleep 60
continue
fi

X86_RPMS_STATUS=$(echo "$CHECK_RUNS_RESULT" | jq -r ".check_runs[] | select (.name | contains(\"$FEDORA-x86_64\"))" | jq -r .status)
if [ "$X86_RPMS_STATUS" != completed ]; then
echo waiting on "$FEDORA"-x86_64 rpms, status is "$X86_RPMS_STATUS"
sleep 60
continue
fi
AARCH64_RPMS_STATUS=$(echo "$CHECK_RUNS_RESULT" | jq -r ".check_runs[] | select (.name | contains(\"$FEDORA-aarch64\"))" | jq -r .status)
if [ "$AARCH64_RPMS_STATUS" != completed ]; then
echo waiting on "$FEDORA"-aarch64 rpms, status is "$AARCH64_RPMS_STATUS"
sleep 60
continue
fi

X86_RPMS_CONCLUSION=$(echo "$CHECK_RUNS_RESULT" | jq -r ".check_runs[] | select (.name | contains(\"$FEDORA-x86_64\"))" | jq -r .conclusion)
if [ "$X86_RPMS_CONCLUSION" = success ]; then
echo "$FEDORA"-x86_64 rpms ready!
else
echo "$FEDORA"-x86_64 rpms failed to build :\(
exit 1
fi
AARCH64_RPMS_CONCLUSION=$(echo "$CHECK_RUNS_RESULT" | jq -r ".check_runs[] | select (.name | contains(\"$FEDORA-aarch64\"))" | jq -r .conclusion)
if [ "$AARCH64_RPMS_CONCLUSION" = success ]; then
echo "$FEDORA"-aarch64 rpms ready!
break
else
echo "$FEDORA"-aarch64 rpms failed to build :\(
exit 1
fi
done

tools/appsre-build-worker-packer.sh
5 changes: 3 additions & 2 deletions tools/appsre-build-worker-packer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ COMMIT_SHA="${COMMIT_SHA:-$(git rev-parse HEAD)}"
COMMIT_BRANCH="${COMMIT_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}"
SKIP_CREATE_AMI="${SKIP_CREATE_AMI:-false}"
BUILD_RPMS="${BUILD_RPMS:-true}"
SKIP_TAGS="${SKIP_TAGS:-rpmrepo}"
# RHEL workers build their own rpms.
SKIP_TAGS="${SKIP_TAGS:-rpmrepo_composer,rpmrepo_osbuild,rpmcopr}"
# Build rhel only
PACKER_ONLY_EXCEPT="${PACKER_ONLY_EXCEPT:---only=amazon-ebs.rhel-9-x86_64,amazon-ebs.rhel-9-aarch64}"

Expand Down Expand Up @@ -67,7 +68,7 @@ EOF
# write osbuild_commit variable if defined in Schutzfile
# if it's not defined, osbuild will be installed from distribution repositories
if [[ $osbuild_commit != "null" ]]; then
tee -a "$item/group_vars/all.yml" null >dev <<EOF
tee -a "$item/group_vars/all.yml" <<EOF
schuellerf marked this conversation as resolved.
Show resolved Hide resolved
osbuild_commit: $osbuild_commit
EOF
fi
Expand Down
2 changes: 1 addition & 1 deletion tools/ci-build-worker-packer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ COMMIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
SKIP_CREATE_AMI=false
BUILD_RPMS=false
# Use prebuilt rpms on CI
SKIP_TAGS="rpmcopy,subscribe"
SKIP_TAGS="rpmcopy,rpmcopr,subscribe"

if [ -n "$CI_COMMIT_SHA" ]; then
COMMIT_SHA="$CI_COMMIT_SHA"
Expand Down
Loading