From 98dd7d77373ca34dbeaf2af63c04b0b43d4b8bfa Mon Sep 17 00:00:00 2001 From: Martin Sehnoutka Date: Fri, 9 Apr 2021 15:50:25 +0200 Subject: [PATCH] rhel84: remove excluded package if explicitly specified in the bp When a users wants to install a package that itself is excluded or its dependency is excluded, it fails the build. There is no known workaround for this shorcoming of our current design. Therefore, remove a package from the list of excluded if it is explicitly mentioned in a blueprint. This will not solve the issue with dependencies, but it will create a possibility of a workaround. Also, introduce regression test to verify the bug fix and hook it into CentOS CI (this issue was reported against RHEL, but CentOS runs on AWS so it is better to verify the fix there). --- internal/distro/rhel84/distro.go | 13 +++++++- schutzbot/Jenkinsfile | 4 +++ test/cases/regression.sh | 53 ++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 test/cases/regression.sh diff --git a/internal/distro/rhel84/distro.go b/internal/distro/rhel84/distro.go index f4e1e017d..76ecbd88c 100644 --- a/internal/distro/rhel84/distro.go +++ b/internal/distro/rhel84/distro.go @@ -217,7 +217,18 @@ func (t *imageType) Packages(bp blueprint.Blueprint) ([]string, []string) { packages = removePackage(packages, "insights-client") } - return packages, t.excludedPackages + // copy the list of excluded packages from the image type + // and subtract any packages found in the blueprint (this + // will not handle the issue with dependencies present in + // the list of excluded packages, but it will create a + // possibility of a workaround at least) + excludedPackages := append([]string(nil), t.excludedPackages...) + for _, pkg := range bp.GetPackages() { + // removePackage is fine if the package doesn't exist + excludedPackages = removePackage(excludedPackages, pkg) + } + + return packages, excludedPackages } func (t *imageType) BuildPackages() []string { diff --git a/schutzbot/Jenkinsfile b/schutzbot/Jenkinsfile index 62a87c67f..082f74324 100644 --- a/schutzbot/Jenkinsfile +++ b/schutzbot/Jenkinsfile @@ -651,6 +651,10 @@ pipeline { } steps { run_tests('base') + sh ( + label: "Regression tests", + script: "/usr/libexec/tests/osbuild-composer/regression.sh" + ) } post { always { diff --git a/test/cases/regression.sh b/test/cases/regression.sh new file mode 100644 index 000000000..40a54df51 --- /dev/null +++ b/test/cases/regression.sh @@ -0,0 +1,53 @@ +#!/bin/bash +set -xeuo pipefail + +# Provision the software under tet. +/usr/libexec/osbuild-composer-test/provision.sh + +BLUEPRINT_FILE=/tmp/blueprint.toml +COMPOSE_START=/tmp/compose-start.json +COMPOSE_INFO=/tmp/compose-info.json + +# Write a basic blueprint for our image. +tee "$BLUEPRINT_FILE" > /dev/null << EOF +name = "redhat-lsb-core" +description = "A base system with redhat-lsb-core" +version = "0.0.1" + +[[packages]] +name = "redhat-lsb-core" + +[[packages]] +# The nss package is excluded in the RHEL8.4 image type, but it is required by the +# redhat-lsb-core package. This test verifies it can be added again when explicitly +# mentioned in the blueprint. +name = "nss" +EOF + +sudo composer-cli blueprints push "$BLUEPRINT_FILE" +sudo composer-cli blueprints depsolve redhat-lsb-core +sudo composer-cli --json compose start redhat-lsb-core qcow2 | tee "${COMPOSE_START}" +COMPOSE_ID=$(jq -r '.build_id' "$COMPOSE_START") + +# Wait for the compose to finish. +echo "⏱ Waiting for compose to finish: ${COMPOSE_ID}" +while true; do + sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null + COMPOSE_STATUS=$(jq -r '.queue_status' "$COMPOSE_INFO") + + # Is the compose finished? + if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then + break + fi + + # Wait 30 seconds and try again. + sleep 30 +done + +jq . "${COMPOSE_INFO}" + +# Did the compose finish with success? +if [[ $COMPOSE_STATUS != FINISHED ]]; then + echo "Something went wrong with the compose. 😢" + exit 1 +fi