diff --git a/test/agent/microshift-test-agent.sh b/test/agent/microshift-test-agent.sh index 0d6a573f83..656d644615 100755 --- a/test/agent/microshift-test-agent.sh +++ b/test/agent/microshift-test-agent.sh @@ -1,7 +1,6 @@ #!/usr/bin/bash set -xeuo pipefail -GREENBOOT_CONFIGURATION_FILE=/etc/greenboot/greenboot.conf AGENT_CFG=/var/lib/microshift-test-agent.json SYSTEMD_NOTIFIED=false @@ -58,32 +57,6 @@ _debug_info() { cat "${AGENT_CFG}" || true } -_get_current_boot_number() { - if ! /usr/bin/grub2-editenv list | grep -q boot_counter; then - echo "boot_counter is missing - script only for newly staged deployments" - exit 0 - fi - - local -r boot_counter=$(/usr/bin/grub2-editenv list | grep boot_counter | sed 's,boot_counter=,,') - local max_boot_attempts - - if test -f "${GREENBOOT_CONFIGURATION_FILE}"; then - # shellcheck source=/dev/null - source "${GREENBOOT_CONFIGURATION_FILE}" - fi - - if [ -v GREENBOOT_MAX_BOOT_ATTEMPTS ]; then - max_boot_attempts="${GREENBOOT_MAX_BOOT_ATTEMPTS}" - else - max_boot_attempts=3 - fi - - # When deployment is staged, greenboot sets boot_counter to 3 - # and this variable gets decremented on each boot. - # First boot of new deployment will have it set to 2. - echo "$((max_boot_attempts - boot_counter))" -} - _get_current_deployment_id() { local -r id="$(rpm-ostree status --booted --json | jq -r ".deployments[0].id")" echo "${id}" @@ -147,7 +120,6 @@ if [ ! -f "${AGENT_CFG}" ] ; then exit 0 fi -current_boot="$(_get_current_boot_number)" current_deployment_id="$(_get_current_deployment_id)" deploy=$(jq -c ".\"${current_deployment_id}\"" "${AGENT_CFG}") @@ -155,10 +127,27 @@ if [[ "${deploy}" == "null" ]]; then exit 0 fi -every_boot_actions=$(echo "${deploy}" | jq -c ".\"every\"") -current_boot_actions=$(echo "${deploy}" | jq -c ".\"${current_boot}\"") +current_boot_actions=$(echo "${deploy}" | jq -c "[.[]] | flatten") + +# greenboot-rs takes a different approach compared to bash greenboot implementation. +# bash greenboot: when deployment is staged, boot_counter is set immediately, +# when host boots again, the variable is present on 1st boot of new deployment. +# greenboot-rs: boot_counter is set only when the healthchecks fail for the new deployment. +# +# Therefore, test-agent cannot depend on boot_counter anymore to do +# actions on first boot of the new deployment. +# For this reason, the way how the test agent config is interpreted changed: +# the .deployment.number is no longer the "ordinal boot number" (i.e. 1st, 2nd, 3rd boot of the deployment) +# but "how many boots this action should be active". +# +# After collecting actions for the current boot, numbers are decremented, and if reach 0, +# removed from the config. +jq \ + --arg key "${current_deployment_id}" \ + '.[$key] |= (with_entries(if (.key | test("^[0-9]+$")) then .key |= (tonumber - 1 | tostring) else . end) | with_entries(select(.key != "0")))' \ + "${AGENT_CFG}" > "${AGENT_CFG}.tmp" && \ + mv "${AGENT_CFG}.tmp" "${AGENT_CFG}" -_run_actions "${every_boot_actions}" _run_actions "${current_boot_actions}" # If running under systemd, notify systemd that the service is ready so that diff --git a/test/bin/ci_phase_iso_build.sh b/test/bin/ci_phase_iso_build.sh index 922e94cb71..02c5447e1d 100755 --- a/test/bin/ci_phase_iso_build.sh +++ b/test/bin/ci_phase_iso_build.sh @@ -188,11 +188,11 @@ if [ $# -gt 0 ] && [ "$1" = "-update_cache" ] ; then fi else GOT_CACHED_DATA=false - if ${HAS_CACHE_ACCESS} ; then - if download_build_cache ; then - GOT_CACHED_DATA=true - fi - fi + # if ${HAS_CACHE_ACCESS} ; then + # if download_build_cache ; then + # GOT_CACHED_DATA=true + # fi + # fi if ! ${GOT_CACHED_DATA} ; then echo "WARNING: Build cache is not available, rebuilding all the artifacts" fi diff --git a/test/scenarios/periodics/el96-prel@el98-src@upgrade-fails-and-rolls-back.sh.disabled b/test/scenarios/periodics/el96-prel@el98-src@upgrade-fails-and-rolls-back.sh similarity index 100% rename from test/scenarios/periodics/el96-prel@el98-src@upgrade-fails-and-rolls-back.sh.disabled rename to test/scenarios/periodics/el96-prel@el98-src@upgrade-fails-and-rolls-back.sh diff --git a/test/scenarios/periodics/el98-src@upgrade-fails-cannot-backup.sh.disabled b/test/scenarios/periodics/el98-src@upgrade-fails-cannot-backup.sh similarity index 100% rename from test/scenarios/periodics/el98-src@upgrade-fails-cannot-backup.sh.disabled rename to test/scenarios/periodics/el98-src@upgrade-fails-cannot-backup.sh diff --git a/test/scenarios/presubmits/el98-src@downgrade-block.sh.disabled b/test/scenarios/presubmits/el98-src@downgrade-block.sh similarity index 100% rename from test/scenarios/presubmits/el98-src@downgrade-block.sh.disabled rename to test/scenarios/presubmits/el98-src@downgrade-block.sh diff --git a/test/scenarios/presubmits/el98-src@upgrade-fails.sh.disabled b/test/scenarios/presubmits/el98-src@upgrade-fails.sh similarity index 100% rename from test/scenarios/presubmits/el98-src@upgrade-fails.sh.disabled rename to test/scenarios/presubmits/el98-src@upgrade-fails.sh