diff --git a/ci-operator/config/openshift-kni/eco-ci-cd/openshift-kni-eco-ci-cd-main__cnf-ran-ibi-4.20.yaml b/ci-operator/config/openshift-kni/eco-ci-cd/openshift-kni-eco-ci-cd-main__cnf-ran-ibi-4.20.yaml index 1f3801263f64..b39c43751fd2 100644 --- a/ci-operator/config/openshift-kni/eco-ci-cd/openshift-kni-eco-ci-cd-main__cnf-ran-ibi-4.20.yaml +++ b/ci-operator/config/openshift-kni/eco-ci-cd/openshift-kni-eco-ci-cd-main__cnf-ran-ibi-4.20.yaml @@ -16,8 +16,8 @@ resources: limits: memory: 4Gi requests: - cpu: 100m - memory: 200Mi + cpu: 200m + memory: 300Mi tests: - as: cnf-ran-ibi-tests capabilities: @@ -27,7 +27,10 @@ tests: env: CLUSTER_NAME: kni-qe-127 DISABLE_INSIGHTS: "true" - GITLAB_REPO_URL: https://gitlab.cee.redhat.com/telcov10n/ztp-site-configs-ci.git + ECO_CI_CD_FORK_BRANCH: report-portal-cnfran-reporting + ECO_CI_CD_FORK_REPO: https://github.com/klaskosk/eco-ci-cd + ECO_CI_CD_FORK_REVISION: d20ff2835b5657191ef93448915bbc06b82f3aa1 + GITLAB_REPO_URL: https://gitlab.cee.redhat.com/tmamyshe/ztp-site-configs-ci.git HUB_OPERATORS: | [ {"name":"local-storage-operator","catalog":"redhat-operators","nsname":"openshift-local-storage","channel":"stable","og_name":"local-operator-group","subscription_name":"local-storage-operator","deploy_default_config":false,"ns_annotations":{"workload.openshift.io/allowed":"management"}}, @@ -36,8 +39,40 @@ tests: {"name":"multicluster-engine","catalog":"redhat-operators","nsname":"multicluster-engine","channel":"stable-2.10","og_name":"multicluster-engine","subscription_name":"multicluster-engine","deploy_default_config":true,"og_spec":{}}, {"name":"topology-aware-lifecycle-manager","catalog":"topology-aware-lifecycle-manager-fbc","og_name":"global-operators","nsname":"openshift-operators","fbc_iib_repo":"latest","channel":"stable","deploy_default_config":false,"ocp_operator_mirror_fbc_image_base":"quay.io/redhat-user-workloads/telco-5g-tenant/topology-aware-lifecycle-manager-fbc-4-20"} ] + IBI_IBBF_ENABLED: "true" + IBI_IBBF_ORIGINAL_BMC_HOST: 10.6.134.24 + IBI_IBBF_REPLACEMENT_BMC_HOST: 10.6.134.23 + IBI_IBBF_REPLACEMENT_POLICY_PATH: 4.20/ibi-target/policygentemplate/ztp-test/ibbf-test + IBI_IBBF_TARGET_IP: 2620:52:9:1684:ca4b:d6ff:fea2:da72 + IBI_MIRROR_SEED_DEPENDENCIES: "true" + IBI_REPLACEMENT_HOST: helix81.telcoqe.eng.rdu2.dc.redhat.com + IBI_REPLACEMENT_IP: 2620:52:9:1684:aa3c:a5ff:fe36:363a + IBI_REPLACEMENT_MAC: a8:3c:a5:36:36:3a + IBI_REPLACEMENT_PREINSTALL_ENABLED: "true" + JUNIT_INVENTORY_PREFIX: target- + JUNIT_REPORT_DIR_FILE: ibi-deploymenttypes-report-dir + JUNIT_REQUIRED_RESULT_FILES: ibi-deploymenttypes-exit-code ibi-ibbf-exit-code + MULTISTAGE_PARAM_OVERRIDE_RELEASE_AGE_MAX_DAYS: "30" + SEED_SPOKE_CLUSTER: ibi-seed + SPOKE_CLUSTER: '[''ibi-seed'']' + SPOKE_OPERATORS: | + [ + {"name":"sriov-fec","catalog":"certified-operators","nsname":"vran-acceleration-operators","channel":"stable"}, + {"name":"ptp-operator","catalog":"redhat-operators-ptp-art","fbc_iib_repo":"ose-ptp-rhel9-operator","nsname":"openshift-ptp","channel":"stable","ns_labels":{"workload.openshift.io/allowed":"management","name":"openshift-ptp"}}, + {"name":"sriov-network-operator","catalog":"redhat-operators-sriov-art","fbc_iib_repo":"ose-sriov-network-rhel9-operator","nsname":"openshift-sriov-network-operator","channel":"stable","og_name":"sriov-network-operators","subscription_name":"sriov-network-operator-subscription"}, + {"name":"cluster-logging","catalog":"redhat-operators","catalog_version_override":"4.20","nsname":"openshift-logging","channel":"stable-6.2","og_name":"cluster-logging","subscription_name":"cluster-logging","og_spec":{"targetNamespaces":[]}}, + {"name":"local-storage-operator","fbc_iib_repo":"ose-local-storage-rhel9-operator","catalog":"redhat-operators-storage-art","nsname":"openshift-local-storage","channel":"stable","og_name":"local-operator-group","subscription_name":"local-storage-operator","deploy_default_config":false,"ns_labels":{"workload.openshift.io/allowed":"management"}}, + {"name":"lifecycle-agent","catalog":"lifecycle-agent-fbc","og_name":"global-operators","nsname":"openshift-operators","fbc_iib_repo":"latest","channel":"stable","deploy_default_config":false,"ocp_operator_mirror_fbc_image_base":"quay.io/redhat-user-workloads/telco-5g-tenant/lifecycle-agent-fbc-4-20"}, + {"name":"redhat-oadp-operator","catalog":"oadp-fbc","fbc_iib_repo":"oadp-1.5__v4.20__oadp-rhel9-operator","art_fbc":false,"ocp_operator_mirror_fbc_image_base":"quay.io/redhat-user-workloads/ocp-art-tenant/art-fbc","nsname":"openshift-adp","channel":"stable","og_name":"openshift-adp","subscription_name":"redhat-oadp-operator","deploy_default_config":false,"og_spec":{"targetNamespaces":["openshift-adp"]}} + ] + TARGET_CLUSTER_NAME: kni-qe-128 + TARGET_REGISTRY_HOST: bastion.kni-qe-128.telcov10n.eng.rdu2.dc.redhat.com + TARGET_SPOKE_CLUSTER: '[''ibi-target'']' + TARGET_SPOKE_VERSION: "4.20" VERSION: "4.20" - workflow: telcov10n-functional-cnf-ran-ibi + ZTP_GIT_BRANCH: ibi + ZTP_GIT_REPO: https://gitlab.cee.redhat.com/tmamyshe/ztp-site-configs-ci.git + workflow: telcov10n-functional-cnf-ran-ibi-workflow zz_generated_metadata: branch: main org: openshift-kni diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/hub-deploy/telcov10n-functional-cnf-ran-hub-deploy-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/hub-deploy/telcov10n-functional-cnf-ran-hub-deploy-commands.sh index a1dfcfd127cb..03292459732a 100644 --- a/ci-operator/step-registry/telcov10n/functional/cnf-ran/hub-deploy/telcov10n-functional-cnf-ran-hub-deploy-commands.sh +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/hub-deploy/telcov10n-functional-cnf-ran-hub-deploy-commands.sh @@ -64,6 +64,14 @@ if [ "${CLUSTER_NAME}" = "kni-qe-106" ] || [ "${CLUSTER_NAME}" = "kni-qe-110" ]; /eco-ci-cd/inventories/ocp-deployment/host_vars/hypervisor fi +# kni-qe-127 is on helix118 (its own dedicated hypervisor mount) +if [ "${CLUSTER_NAME}" = "kni-qe-127" ] || [ "${CLUSTER_NAME}" = "kni-qe-130" ]; then + echo "Processing hypervisor inventory for ${CLUSTER_NAME} from helix118 mount" + process_inventory "${MOUNTED_HOST_INVENTORY}/kni-qe-130/hypervisor" \ + /eco-ci-cd/inventories/ocp-deployment/host_vars/hypervisor +fi + + # kni-qe-111 and kni-qe-129 use helix89 (same as kni-qe-108), ci-operator cannot mount the same secret twice. if [ "${CLUSTER_NAME}" = "kni-qe-111" ] || [ "${CLUSTER_NAME}" = "kni-qe-129" ]; then echo "Processing shared hypervisor inventory for ${CLUSTER_NAME} from kni-qe-108 mount" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-deploymenttypes/OWNERS b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-deploymenttypes/OWNERS new file mode 100644 index 000000000000..730ec412add2 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-deploymenttypes/OWNERS @@ -0,0 +1 @@ +# Inherit approvers from ../OWNERS. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-deploymenttypes/telcov10n-functional-cnf-ran-ibi-deploymenttypes-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-deploymenttypes/telcov10n-functional-cnf-ran-ibi-deploymenttypes-commands.sh new file mode 100644 index 000000000000..f751c836d54d --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-deploymenttypes/telcov10n-functional-cnf-ran-ibi-deploymenttypes-commands.sh @@ -0,0 +1,237 @@ +#!/bin/bash +set +x +set -euo pipefail +umask 077 + +TEMP_DIR= +SSH_READY=false +REPORTS_COLLECTED=false +RUN_RC=1 +TEST_RESULT=1 + +record_result() { + printf '%s\n' "$1" > "${RESULT_FILE}" +} + +finish() { + local result=$1 copy_rc=0 save_rc=0 + trap - EXIT + set +e + + if [[ "${SSH_READY}" == true && "${REPORTS_COLLECTED}" == false ]]; then + collect_reports + copy_rc=$? + if (( result == 0 )); then + result=${copy_rc} + fi + fi + + if (( result == 0 )); then + record_result "${TEST_RESULT}" + else + record_result "${result}" + fi + save_rc=$? + [[ -z "${TEMP_DIR}" ]] || rm -rf -- "${TEMP_DIR}" + if (( save_rc != 0 )); then + echo "Could not save the Deployment Types result." >&2 + exit "${save_rc}" + fi + + echo "Deployment Types step status: ${result}; test result: ${TEST_RESULT}; report-copy status: ${copy_rc}." + if (( result == 0 )); then + echo "Tests completed; later stages may continue. Final verification will enforce the saved test result." + else + echo "Deployment Types setup, execution, or report collection failed; stopping the workflow." >&2 + fi + exit "${result}" +} + +validate_inputs() { + : "${TARGET_CLUSTER_NAME:?TARGET_CLUSTER_NAME is required}" + : "${TARGET_SPOKE_CLUSTER:?TARGET_SPOKE_CLUSTER is required}" + TARGET_SPOKE_NAME=$(printf '%s' "${TARGET_SPOKE_CLUSTER}" | tr -d "[]'\" ") + [[ "${TARGET_CLUSTER_NAME}" =~ ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ]] + [[ "${TARGET_SPOKE_NAME}" =~ ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ]] + HUB_CONFIG_DIR="/home/telcov10n/project/generated/${TARGET_CLUSTER_NAME}" +} + +restore_target_inventory() { + local name + INVENTORY_PATH=/eco-ci-cd/inventories/ocp-deployment + mkdir -p "${INVENTORY_PATH}/group_vars" "${INVENTORY_PATH}/host_vars" + for name in all bastions; do + cp "${SHARED_DIR}/target-${name}" "${INVENTORY_PATH}/group_vars/${name}" + done + cp "${SHARED_DIR}/target-bastion" "${INVENTORY_PATH}/host_vars/bastion" +} + +create_work_directories() { + TEMP_DIR=$(mktemp -d /tmp/ibi-deploymenttypes.XXXXXX) + WORK_DIR="/tmp/eco_gotests_ibi_deploymenttypes/${TEMP_DIR##*/}" + # The preparation playbook deletes WORK_DIR, so keep the kubeconfig outside it. + SPOKE_KUBECONFIG="/tmp/${TEMP_DIR##*/}-kubeconfig" + REPORT_DIR="${ARTIFACT_DIR}/ibi-deploymenttypes" + mkdir -p "${REPORT_DIR}" + printf '%s\n' "${WORK_DIR}/report" > "${SHARED_DIR}/ibi-rp-ibi-dir" + printf '%s\n' "${WORK_DIR}/junit" > "${SHARED_DIR}/ibi-deploymenttypes-report-dir" +} + +configure_ssh() { + cp /var/group_variables/common/all/ansible_ssh_private_key "${TEMP_DIR}/ssh-key" + chmod 600 "${TEMP_DIR}/ssh-key" + # Match hub deployment: read connection fields from the generated inventory. + if ! BASTION_IP=$(grep -oP '(?<=ansible_host: ).*' "${INVENTORY_PATH}/host_vars/bastion" | sed "s/'//g") || + ! BASTION_USER=$(grep -oP '(?<=ansible_user: ).*' "${INVENTORY_PATH}/group_vars/all" | sed "s/'//g"); then + echo "Could not read target bastion address and user from inventory." >&2 + return 1 + fi + if [[ ! "${BASTION_IP} ${BASTION_USER}" =~ ^[^[:space:]]+[[:blank:]][^[:space:]]+$ ]]; then + echo "Target bastion inventory must provide one address and one user." >&2 + return 1 + fi + SSH_OPTS=( + -i "${TEMP_DIR}/ssh-key" + -o BatchMode=yes + -o ConnectTimeout=30 + -o ServerAliveInterval=30 + -o ServerAliveCountMax=6 + -o StrictHostKeyChecking=no + -o UserKnownHostsFile=/dev/null + ) + SSH_READY=true +} + +redact_bastion() { + local line + while IFS= read -r line || [[ -n "${line}" ]]; do + line="${line//${BASTION_USER}@${BASTION_IP}/}" + line="${line//${BASTION_IP}/}" + printf '%s\n' "${line}" + done +} + +fetch_target_kubeconfig() { + ssh "${SSH_OPTS[@]}" "${BASTION_USER}@${BASTION_IP}" \ + "set -euo pipefail; umask 077 + oc --kubeconfig='${HUB_CONFIG_DIR}/auth/kubeconfig' -n '${TARGET_SPOKE_NAME}' \ + get secret '${TARGET_SPOKE_NAME}-admin-kubeconfig' \ + -o jsonpath='{.data.kubeconfig}' | base64 -d > '${SPOKE_KUBECONFIG}' + test -s '${SPOKE_KUBECONFIG}'" \ + 2>&1 | redact_bastion +} + +prepare_launcher() { + cd /eco-ci-cd + ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook ./playbooks/deploy-run-eco-gotests.yaml \ + -i "${INVENTORY_PATH}/build-inventory.py" \ + --private-key "${TEMP_DIR}/ssh-key" \ + --extra-vars "kubeconfig=${SPOKE_KUBECONFIG}" \ + --extra-vars "hub_clusterconfigs_path=${HUB_CONFIG_DIR}" \ + --extra-vars "eco_gotest_dir=${WORK_DIR}" \ + --extra-vars '{ + "features": "deploymenttypes", + "labels": "!no-container", + "eco_gotests_tag": "latest", + "test_timeout": "3h", + "eco_worker_label": "", + "eco_cnf_core_net_switch_user": "", + "eco_cnf_core_net_switch_pass": "", + "eco_cnf_core_net_switch_ip": "", + "eco_cnf_core_net_mlb_addr_list": "", + "switch_lag_names": "", + "report_test_case_tag": "test_id", + "report_parameter_tag": "parameters", + "report_tc_prefix": "ibi", + "additional_test_env_variables": "-e ECO_CNF_RAN_SKIP_TLS_VERIFY=true -e ECO_CNF_RAN_ACM_OPERATOR_NAMESPACE=open-cluster-management -e ECO_TEST_TRACE=true -e ECO_VERBOSE_SCRIPT=true" + }' \ + 2>&1 | redact_bastion | tee "${REPORT_DIR}/setup.log" +} + +run_tests() { + local -a status + set +e + ssh "${SSH_OPTS[@]}" "${BASTION_USER}@${BASTION_IP}" \ + "cd '${WORK_DIR}' && + sed -i 's/^podman run -it /podman run -i /' eco-gotests-run.sh && + exec ./eco-gotests-run.sh" \ + 2>&1 | redact_bastion | tee "${REPORT_DIR}/runner.log" + status=("${PIPESTATUS[@]}") + set -e + echo "Test execution status: ${status[0]}; log-write status: ${status[2]}." + RUN_RC=${status[0]} + (( status[1] == 0 )) || return "${status[1]}" + (( status[2] == 0 )) || return "${status[2]}" + # Exit 1 is provisional: only a completed JUnit failure may be deferred. + case "${RUN_RC}" in + 0|1) return 0 ;; + *) return "${RUN_RC}" ;; + esac +} + +verify_test_result() { + python3 - "${REPORT_DIR}/report/deployment_suite_test_junit.xml" "${RUN_RC}" <<'PYTEST' +import sys +import xml.etree.ElementTree as ET + +root = ET.parse(sys.argv[1]).getroot() +cases = list(root.iter("testcase")) +tests = [case for case in cases if case.get("name", "").startswith("[It] ")] +if root.tag not in ("testsuite", "testsuites") or not any(case.find("skipped") is None for case in tests): + sys.exit("Deployment Types did not execute any test cases.") +if (any(prop.get("name") == "SpecialSuiteFailureReason" and prop.get("value") for prop in root.iter("property")) or + any(case.find("error") is not None or + any(failure.get("type") == "aborted" for failure in case.findall("failure")) or + (case not in tests and case.find("failure") is not None) for case in cases)): + sys.exit("Deployment Types reported an execution or suite setup/teardown error.") +failed = any(case.find("failure") is not None for case in tests) +if int(sys.argv[2]) != 0 and not failed: + sys.exit("Deployment Types runner failed without a matching JUnit test failure.") +print(int(failed)) +PYTEST +} + +collect_reports() { + local copy_rc=0 junit_rc=0 scp_host="${BASTION_IP}" + if [[ "${scp_host}" == *:* ]]; then scp_host="[${scp_host}]"; fi + scp -q -r "${SSH_OPTS[@]}" \ + "${BASTION_USER}@${scp_host}:${WORK_DIR}/report" "${REPORT_DIR}/" \ + 2>&1 | redact_bastion || copy_rc=$? + + # Keep all artifacts, but give the verifier only the Ginkgo JUnit report. + ssh "${SSH_OPTS[@]}" "${BASTION_USER}@${BASTION_IP}" \ + "set -e + test -s '${WORK_DIR}/report/deployment_suite_test_junit.xml' + mkdir -p '${WORK_DIR}/junit' + cp '${WORK_DIR}/report/deployment_suite_test_junit.xml' \ + '${WORK_DIR}/junit/deploymenttypes.xml'" \ + 2>&1 | redact_bastion || junit_rc=$? + + (( copy_rc == 0 )) || return "${copy_rc}" + return "${junit_rc}" +} + +main() { + if [[ -f "${SHARED_DIR}/skip.txt" ]]; then + echo "Skipping IBI Deployment Types tests." + return 0 + fi + + RESULT_FILE="${SHARED_DIR}/ibi-deploymenttypes-exit-code" + record_result 1 + trap 'finish "$?"' EXIT + + cd /eco-ci-cd + validate_inputs + restore_target_inventory + create_work_directories + configure_ssh + fetch_target_kubeconfig + prepare_launcher + run_tests + collect_reports + REPORTS_COLLECTED=true + TEST_RESULT=$(verify_test_result) +} + +main "$@" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-deploymenttypes/telcov10n-functional-cnf-ran-ibi-deploymenttypes-ref.metadata.json b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-deploymenttypes/telcov10n-functional-cnf-ran-ibi-deploymenttypes-ref.metadata.json new file mode 100644 index 000000000000..89d5f97be39c --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-deploymenttypes/telcov10n-functional-cnf-ran-ibi-deploymenttypes-ref.metadata.json @@ -0,0 +1,4 @@ +{ + "path": "telcov10n/functional/cnf-ran/ibi-deploymenttypes/telcov10n-functional-cnf-ran-ibi-deploymenttypes-ref.yaml", + "owners": {} +} \ No newline at end of file diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-deploymenttypes/telcov10n-functional-cnf-ran-ibi-deploymenttypes-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-deploymenttypes/telcov10n-functional-cnf-ran-ibi-deploymenttypes-ref.yaml new file mode 100644 index 000000000000..9d7f0801d279 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-deploymenttypes/telcov10n-functional-cnf-ran-ibi-deploymenttypes-ref.yaml @@ -0,0 +1,36 @@ +ref: + as: telcov10n-functional-cnf-ran-ibi-deploymenttypes + from_image: + namespace: telcov10n-ci + name: eco-ci-cd + tag: eco-ci-cd + commands: telcov10n-functional-cnf-ran-ibi-deploymenttypes-commands.sh + timeout: 4h + grace_period: 5m + resources: + requests: + cpu: 100m + memory: 200Mi + env: + - name: TARGET_CLUSTER_NAME + default: "" + documentation: Target hub name used to locate its kubeconfig on the target bastion. + - name: TARGET_SPOKE_CLUSTER + default: "['ibi-target']" + documentation: Single target spoke name in the existing list format. + credentials: + - namespace: test-credentials + name: telcov10n-ansible-group-all + mount_path: /var/group_variables/common/all + documentation: |- + Restore target inventory, retrieve the target spoke kubeconfig, and prepare + deploymenttypes with the existing deploy-run-eco-gotests.yaml playbook. + Run the generated launcher without a TTY and collect console logs and reports. + Setup, execution, and report collection errors stop the workflow. + Require an executed test and a valid JUnit report before deferring test failures. + Save the test result in SHARED_DIR/ibi-deploymenttypes-exit-code and allow + later stages to continue after completed tests, including failed assertions. + Save the current run's JUnit-only directory in + SHARED_DIR/ibi-deploymenttypes-report-dir for the shared bastion verifier. + Use telcov10n-verify-junit-reports-bastion after reporting as the final step to check + both the recorded exit code and the JUnit report. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/OWNERS b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/OWNERS new file mode 100644 index 000000000000..b63f3e998249 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/OWNERS @@ -0,0 +1,9 @@ +approvers: +- ccardenosa +- eifrach +- kononovn +- mkochanowski +- rdiazcam +- rdiscala +- shaior +- timurmp diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/telcov10n-functional-cnf-ran-ibi-eco-gotests-seed-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/telcov10n-functional-cnf-ran-ibi-eco-gotests-seed-commands.sh new file mode 100644 index 000000000000..d9a4e56f9e68 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/telcov10n-functional-cnf-ran-ibi-eco-gotests-seed-commands.sh @@ -0,0 +1,167 @@ +#!/bin/bash +set +x +set -e +set -o pipefail + +OCP_DEPLOYMENT_INVENTORY_PATH="/eco-ci-cd/inventories/ocp-deployment" +CNF_INVENTORY_PATH="/eco-ci-cd/inventories/cnf" + +cleanup() { + local status=$? cleanup_rc=0 + rm -rf -- "$ARTIFACT_WORK" || cleanup_rc=$? + if (( cleanup_rc != 0 )); then + echo "Failed to remove private seed artifact files." >&2 + (( status != 0 )) || status=$cleanup_rc + fi + exit "$status" +} + +restore_seed_inventory() { + # Copy inventory from SHARED_DIR (processed by earlier hub-deploy step) + echo "=== Copying inventory for seed hub ${CLUSTER_NAME} from SHARED_DIR ===" + + mkdir -p "${OCP_DEPLOYMENT_INVENTORY_PATH}/group_vars" + mkdir -p "${OCP_DEPLOYMENT_INVENTORY_PATH}/host_vars" + + cp "${SHARED_DIR}/all" "${OCP_DEPLOYMENT_INVENTORY_PATH}/group_vars/all" + cp "${SHARED_DIR}/bastions" "${OCP_DEPLOYMENT_INVENTORY_PATH}/group_vars/bastions" + cp "${SHARED_DIR}/nodes" "${OCP_DEPLOYMENT_INVENTORY_PATH}/group_vars/nodes" + cp "${SHARED_DIR}/masters" "${OCP_DEPLOYMENT_INVENTORY_PATH}/group_vars/masters" + cp "${SHARED_DIR}/bastion" "${OCP_DEPLOYMENT_INVENTORY_PATH}/host_vars/bastion" + + mkdir -p "${CNF_INVENTORY_PATH}/group_vars" + mkdir -p "${CNF_INVENTORY_PATH}/host_vars" + + cp "${SHARED_DIR}/bastions" "${CNF_INVENTORY_PATH}/group_vars/bastions.yaml" + cp "${SHARED_DIR}/all" "${CNF_INVENTORY_PATH}/group_vars/all.yaml" + cp "${SHARED_DIR}/bastion" "${CNF_INVENTORY_PATH}/host_vars/bastion.yaml" + + echo "Inventory copied from SHARED_DIR" +} + +check_seed_kubeconfig() { + echo "=== Step 1: Check saved seed kubeconfig on the seed bastion ===" + cd /eco-ci-cd + SEED_SPOKE_KUBECONFIG="/tmp/${SEED_SPOKE_CLUSTER}-kubeconfig" + # Preparation must run before ACM detachment. Do not fetch the hub Secret here. + if ! ansible bastion \ + -i "${CNF_INVENTORY_PATH}/switch-config.yaml" \ + -m ansible.builtin.shell \ + -a "test -r '${SEED_SPOKE_KUBECONFIG}' && test -s '${SEED_SPOKE_KUBECONFIG}'"; then + echo "Seed kubeconfig is missing, empty, or unreadable on the seed bastion. Run ibi-seed-prepare before ibu-prune-argocd-apps." >&2 + exit 1 + fi +} + +prepare_seedgeneration() { + echo "=== Step 2: Generate eco-gotests IBI seedgeneration script ===" + + ECO_GOTESTS_ENV_VARS="-e ECO_CNF_RAN_SKIP_TLS_VERIFY=true" + ECO_GOTESTS_ENV_VARS+=" -e ECO_LCA_IBGU_SEED_IMAGE=${MIRROR_REGISTRY}/ibu/seed:${VERSION}" + ECO_GOTESTS_ENV_VARS+=" -e ECO_LCA_IBU_CNF_KUBECONFIG_TARGET_SNO=/kubeconfig/kubeconfig" + + ansible-playbook playbooks/deploy-run-eco-gotests.yaml \ + -i "${CNF_INVENTORY_PATH}/switch-config.yaml" \ + --extra-vars "kubeconfig=${SEED_SPOKE_KUBECONFIG}" \ + --extra-vars "features=${ECO_GOTESTS_FEATURES}" \ + --extra-vars 'labels=!no-container' \ + --extra-vars 'eco_worker_label=""' \ + --extra-vars 'eco_cnf_core_net_switch_user=""' \ + --extra-vars 'eco_cnf_core_net_switch_pass=""' \ + --extra-vars 'eco_gotests_tag=latest' \ + --extra-vars "additional_test_env_variables=\"${ECO_GOTESTS_ENV_VARS}\"" + + # Preparation above removes the old test directory before creating this launcher. + printf '%s\n' /tmp/eco_gotests/report > "${SHARED_DIR}/ibi-rp-seedgen-dir" +} + +prepare_capture_access() { + ARTIFACT_WORK=$(mktemp -d /tmp/ibi-seed-artifacts.XXXXXX) + trap cleanup EXIT + cp /var/group_variables/common/all/ansible_ssh_private_key "$ARTIFACT_WORK/ssh-key" + chmod 600 "$ARTIFACT_WORK/ssh-key" + + # Match hub deployment: read connection fields from the generated inventory. + if ! BASTION_IP=$(grep -oP '(?<=ansible_host: ).*' "${CNF_INVENTORY_PATH}/host_vars/bastion.yaml" | sed "s/'//g") || + ! BASTION_USER=$(grep -oP '(?<=ansible_user: ).*' "${CNF_INVENTORY_PATH}/group_vars/all.yaml" | sed "s/'//g"); then + echo "Could not read seed bastion address and user from inventory." >&2 + return 1 + fi + if [[ ! "${BASTION_IP} ${BASTION_USER}" =~ ^[^[:space:]]+[[:blank:]][^[:space:]]+$ ]]; then + echo "Seed bastion inventory must provide one address and one user." >&2 + return 1 + fi + [[ "$CLUSTER_NAME" =~ ^[a-z0-9-]+$ && "$SEED_SPOKE_CLUSTER" =~ ^[a-z0-9-]+$ ]] +} + +capture_catalogs() { + # Capture floating catalog identities before seed generation changes the seed. + rm -f -- "${SHARED_DIR}/ibi-seed-catalogs.json" + SEED_VERSION=$(<"${SHARED_DIR}/ibi-seed-version") + ansible-playbook playbooks/ran/ibi-seed-images.yml \ + -i "${CNF_INVENTORY_PATH}/switch-config.yaml" \ + --extra-vars "ibi_seed_phase=capture" \ + --extra-vars "ibi_seed_kubeconfig=${SEED_SPOKE_KUBECONFIG}" \ + --extra-vars "ibi_hub_kubeconfig=/home/telcov10n/project/generated/${CLUSTER_NAME}/auth/kubeconfig" \ + --extra-vars "ibi_mirror_registry=${MIRROR_REGISTRY}" \ + --extra-vars "ibi_seed_version=${SEED_VERSION}" \ + --extra-vars "ibi_catalogs_output=${SHARED_DIR}/ibi-seed-catalogs.json" \ + --extra-vars "ansible_private_key_file=${ARTIFACT_WORK}/ssh-key" \ + --extra-vars 'ansible_ssh_common_args="-o BatchMode=yes -o ConnectTimeout=30 -o ServerAliveInterval=30 -o ServerAliveCountMax=6 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"' +} + +run_seedgeneration() { + echo "=== Step 2b: Run seedgeneration ===" + ansible-playbook playbooks/ran/ibu-run-seedgeneration.yml \ + -i "${CNF_INVENTORY_PATH}/switch-config.yaml" \ + --extra-vars "spoke_cluster=${SEED_SPOKE_CLUSTER}" \ + --extra-vars "kubeconfig=${SEED_SPOKE_KUBECONFIG}" +} + +collect_reports() { + local bastion_address="$BASTION_IP" + echo "Gather artifacts from bastion" + mkdir -p "${ARTIFACT_DIR}/junit_eco_gotests" || return $? + if [[ "$bastion_address" == *:* && "$bastion_address" != \[*\] ]]; then + bastion_address="[$bastion_address]" + fi + scp -r -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -i "$ARTIFACT_WORK/ssh-key" \ + "${BASTION_USER}@${bastion_address}:/tmp/eco_gotests/report/*.xml" \ + "${ARTIFACT_DIR}/junit_eco_gotests/" +} + +main() { + local run_rc=0 report_rc=0 + echo "Checking if the job should be skipped..." + if [ -f "${SHARED_DIR}/skip.txt" ]; then + echo "Detected skip.txt file — skipping the job" + return 0 + fi + + export ANSIBLE_REMOTE_TEMP=/tmp + + echo "=== IBI Seed eco-gotests Configuration ===" + echo "SEED_SPOKE_CLUSTER=${SEED_SPOKE_CLUSTER}" + echo "CLUSTER_NAME=${CLUSTER_NAME}" + echo "ECO_GOTESTS_FEATURES=${ECO_GOTESTS_FEATURES}" + echo "MIRROR_REGISTRY=${MIRROR_REGISTRY}" + echo "VERSION=${VERSION}" + echo "" + restore_seed_inventory + check_seed_kubeconfig + prepare_seedgeneration + prepare_capture_access + capture_catalogs + run_seedgeneration || run_rc=$? + collect_reports || report_rc=$? + printf 'Seed generation: %s; report collection: %s\n' "$run_rc" "$report_rc" + (( run_rc == 0 )) || return "$run_rc" + (( report_rc == 0 )) || return "$report_rc" + + echo "=== IBI Seed Eco-Gotests Complete ===" + echo "Seed image: ${MIRROR_REGISTRY}/ibu/seed:${VERSION}" + echo "Seed generation completed; the image is ready to mirror to the target registry." +} + +main "$@" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/telcov10n-functional-cnf-ran-ibi-eco-gotests-seed-ref.metadata.json b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/telcov10n-functional-cnf-ran-ibi-eco-gotests-seed-ref.metadata.json new file mode 100644 index 000000000000..35ebe4a2250a --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/telcov10n-functional-cnf-ran-ibi-eco-gotests-seed-ref.metadata.json @@ -0,0 +1,15 @@ +{ + "path": "telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/telcov10n-functional-cnf-ran-ibi-eco-gotests-seed-ref.yaml", + "owners": { + "approvers": [ + "ccardenosa", + "eifrach", + "kononovn", + "mkochanowski", + "rdiazcam", + "rdiscala", + "shaior", + "timurmp" + ] + } +} \ No newline at end of file diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/telcov10n-functional-cnf-ran-ibi-eco-gotests-seed-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/telcov10n-functional-cnf-ran-ibi-eco-gotests-seed-ref.yaml new file mode 100644 index 000000000000..ba6b733c24c7 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-eco-gotests-seed/telcov10n-functional-cnf-ran-ibi-eco-gotests-seed-ref.yaml @@ -0,0 +1,58 @@ +ref: + as: telcov10n-functional-cnf-ran-ibi-eco-gotests-seed + from_image: + namespace: telcov10n-ci + name: eco-ci-cd + tag: eco-ci-cd + commands: telcov10n-functional-cnf-ran-ibi-eco-gotests-seed-commands.sh + documentation: |- + Run the eco-gotests seedgeneration suite on the prepared IBI seed SNO + and collect its reports. No post-generation seed power-off is performed. + + Requires ibi-seed-prepare before ibu-prune-argocd-apps. Reuse the saved + /tmp/${SEED_SPOKE_CLUSTER}-kubeconfig on the seed bastion after detachment; + the spoke kubeconfig is not retrieved again from the hub. Read the seed + hub registry pull secret only to retain the seed catalog image digests. + + Flow: + 1. Check the saved seed kubeconfig on the seed bastion + 2. Generate eco-gotests run script (deploy-run-eco-gotests.yaml) + 3. Snapshot and retain catalogs via ibi-seed-images.yml (capture phase) before generation + 4. Run seedgeneration via ibu-run-seedgeneration.yml + 5. Collect junit artifacts + + The bare-metal seed storage is configured through ZTP policies. + timeout: 150m + grace_period: 1m + resources: + requests: + cpu: 100m + memory: 200Mi + + env: + - name: CLUSTER_NAME + default: "kni-qe-127" + documentation: Seed hub cluster name (manages the seed spoke via ACM) + - name: SEED_SPOKE_CLUSTER + default: "helix81" + documentation: Seed spoke SNO cluster name (where seed image is generated) + - name: ECO_GOTESTS_FEATURES + default: "seedgeneration" + documentation: Space-separated list of eco-gotests features + - name: MIRROR_REGISTRY + default: "disconnected.registry.local:5000" + documentation: Disconnected mirror registry address for seed image + - name: VERSION + default: "4.20" + documentation: OCP version used to tag the seed image + + credentials: + - namespace: test-credentials + name: telcov10n-ansible-group-all + mount_path: /var/group_variables/common/all + - namespace: test-credentials + name: telcov10n-ansible-group-bastions + mount_path: /var/group_variables/common/bastions + - namespace: test-credentials + name: telcov10n-ansible-kni-qe-127-bastion + mount_path: /var/host_variables/kni-qe-127/bastion diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-hub-prepare/OWNERS b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-hub-prepare/OWNERS new file mode 100644 index 000000000000..1787bab25ba7 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-hub-prepare/OWNERS @@ -0,0 +1,10 @@ +approvers: +- ccardenosa +- eifrach +- kononovn +- mkochanowski +- rdiazcam +- rdiscala +- shaior +- timurmp +- rileyfw diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-hub-prepare/telcov10n-functional-cnf-ran-ibi-hub-prepare-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-hub-prepare/telcov10n-functional-cnf-ran-ibi-hub-prepare-commands.sh new file mode 100644 index 000000000000..80425dc0aa25 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-hub-prepare/telcov10n-functional-cnf-ran-ibi-hub-prepare-commands.sh @@ -0,0 +1,38 @@ +#!/bin/bash +set +x +set -euo pipefail + +if [[ -f "${SHARED_DIR}/skip.txt" ]]; then + exit 0 +fi + +PROJECT_DIR="/tmp" +install -m 600 \ + /var/group_variables/common/all/ansible_ssh_private_key \ + "${PROJECT_DIR}/ansible_ssh_key" + +export ANSIBLE_PRIVATE_KEY_FILE="${PROJECT_DIR}/ansible_ssh_key" +export ANSIBLE_SSH_RETRIES=3 +export ANSIBLE_TIMEOUT=600 +export ANSIBLE_HOST_KEY_CHECKING=False + +cd /eco-ci-cd +INVENTORY_PATH=./inventories/ocp-deployment +mkdir -p "${INVENTORY_PATH}/group_vars" "${INVENTORY_PATH}/host_vars" + +for hub in seed target; do + cluster="${CLUSTER_NAME}" + if [[ "${hub}" == target ]]; then + cluster="${TARGET_CLUSTER_NAME}" + fi + for group in all bastions; do + cp "${SHARED_DIR}/${hub}-${group}" "${INVENTORY_PATH}/group_vars/${group}" + done + cp "${SHARED_DIR}/${hub}-bastion" "${INVENTORY_PATH}/host_vars/bastion" + + echo "Preparing ${hub} hub prerequisites" + ansible-playbook ./playbooks/ran/ibi-hub-prepare.yml \ + -i "${INVENTORY_PATH}/build-inventory.py" \ + --limit bastion \ + --extra-vars "kubeconfig=/home/telcov10n/project/generated/${cluster}/auth/kubeconfig ibi_hub_role=${hub}" +done diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-hub-prepare/telcov10n-functional-cnf-ran-ibi-hub-prepare-ref.metadata.json b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-hub-prepare/telcov10n-functional-cnf-ran-ibi-hub-prepare-ref.metadata.json new file mode 100644 index 000000000000..e15b1bb015d0 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-hub-prepare/telcov10n-functional-cnf-ran-ibi-hub-prepare-ref.metadata.json @@ -0,0 +1,16 @@ +{ + "path": "telcov10n/functional/cnf-ran/ibi-hub-prepare/telcov10n-functional-cnf-ran-ibi-hub-prepare-ref.yaml", + "owners": { + "approvers": [ + "ccardenosa", + "eifrach", + "kononovn", + "mkochanowski", + "rdiazcam", + "rdiscala", + "shaior", + "timurmp", + "rileyfw" + ] + } +} \ No newline at end of file diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-hub-prepare/telcov10n-functional-cnf-ran-ibi-hub-prepare-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-hub-prepare/telcov10n-functional-cnf-ran-ibi-hub-prepare-ref.yaml new file mode 100644 index 000000000000..696cd212d641 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-hub-prepare/telcov10n-functional-cnf-ran-ibi-hub-prepare-ref.yaml @@ -0,0 +1,32 @@ +ref: + as: telcov10n-functional-cnf-ran-ibi-hub-prepare + from_image: + namespace: telcov10n-ci + name: eco-ci-cd + tag: eco-ci-cd + commands: telcov10n-functional-cnf-ran-ibi-hub-prepare-commands.sh + timeout: 2h + grace_period: 1m + resources: + requests: + cpu: 100m + memory: 200Mi + env: + - name: CLUSTER_NAME + default: kni-qe-127 + documentation: Seed hub name used to locate its bastion kubeconfig. + - name: TARGET_CLUSTER_NAME + default: kni-qe-128 + documentation: Target hub name used to locate its bastion kubeconfig. + credentials: + - namespace: test-credentials + name: telcov10n-ansible-group-all + mount_path: /var/group_variables/common/all + documentation: |- + Run eco-ci-cd playbooks/ran/ibi-hub-prepare.yml once per hub using its saved inventory. + Enable SiteConfig and verify SiteConfig and TALM readiness on both IBI hubs. + Enable the image-based install operator on the target hub and wait for readiness. + Set the target hub import strategy to ImportAndSync so replaced spokes rejoin + automatically; preserve the seed hub import strategy and other ConfigMap keys. + Requires seed- and target-prefixed bastion, bastions and all inventories in + SHARED_DIR from hub deployment. Does not modify operator RBAC. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-ibbf/OWNERS b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-ibbf/OWNERS new file mode 100644 index 000000000000..730ec412add2 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-ibbf/OWNERS @@ -0,0 +1 @@ +# Inherit approvers from ../OWNERS. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-ibbf/telcov10n-functional-cnf-ran-ibi-ibbf-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-ibbf/telcov10n-functional-cnf-ran-ibi-ibbf-commands.sh new file mode 100755 index 000000000000..3c13380dcc3c --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-ibbf/telcov10n-functional-cnf-ran-ibi-ibbf-commands.sh @@ -0,0 +1,134 @@ +#!/bin/bash +set +x +set -euo pipefail +umask 077 + +finish() { + local rc=$? + trap - EXIT + rm -rf -- "${TEMP_DIR}" || rc=1 + if (( rc != 0 )); then + printf '%s\n' "${rc}" > "${RESULT_FILE}" || rc=1 + echo "IBBF setup, execution, logging, or cleanup failed; stopping the workflow." >&2 + fi + exit "${rc}" +} + +restore_target_inventory() { + local name + INVENTORY_PATH=/eco-ci-cd/inventories/ocp-deployment + mkdir -p "${INVENTORY_PATH}/group_vars" "${INVENTORY_PATH}/host_vars" + for name in all bastions; do + cp "${SHARED_DIR}/target-${name}" "${INVENTORY_PATH}/group_vars/${name}" + done + cp "${SHARED_DIR}/target-bastion" "${INVENTORY_PATH}/host_vars/bastion" +} + +prepare_inputs() { + [[ "${IBI_REPLACEMENT_PREINSTALL_ENABLED}" == true ]] + TARGET_SPOKE_NAME=$(printf '%s' "${TARGET_SPOKE_CLUSTER}" | tr -d "[]'\" ") + [[ "${TARGET_CLUSTER_NAME}" =~ ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ]] + [[ "${TARGET_SPOKE_NAME}" =~ ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ]] + POLICY_REVISION= + if [[ -n "${IBI_IBBF_REPLACEMENT_POLICY_PATH:-}" ]]; then + POLICY_REVISION=$(<"${SHARED_DIR}/ibi-seed-git-revision") + fi + + TEMP_DIR=$(mktemp -d /tmp/ibi-ibbf.XXXXXX) + trap finish EXIT + WORK_DIR="/tmp/eco_gotests_ibi_ibbf/${TEMP_DIR##*/}" + REPORT_DIR="${ARTIFACT_DIR}/ibi-ibbf" + mkdir -p "${REPORT_DIR}" + printf '%s\n' "${WORK_DIR}/report" > "${SHARED_DIR}/ibi-rp-ibbf-dir" +} + +configure_ansible() { + install -m 600 /var/group_variables/common/all/ansible_ssh_private_key "${TEMP_DIR}/ssh-key" + export ANSIBLE_PRIVATE_KEY_FILE="${TEMP_DIR}/ssh-key" + export ANSIBLE_HOST_KEY_CHECKING=False + export ANSIBLE_SSH_RETRIES=3 + export ANSIBLE_TIMEOUT=600 + export ANSIBLE_REMOTE_TEMP=/tmp + + # Match hub deployment: read connection fields from the generated inventory. + if ! BASTION_IP=$(grep -oP '(?<=ansible_host: ).*' "${INVENTORY_PATH}/host_vars/bastion" | sed "s/'//g") || + ! BASTION_USER=$(grep -oP '(?<=ansible_user: ).*' "${INVENTORY_PATH}/group_vars/all" | sed "s/'//g"); then + echo "Could not read target bastion address and user from inventory." >&2 + return 1 + fi + if [[ ! "${BASTION_IP} ${BASTION_USER}" =~ ^[^[:space:]]+[[:blank:]][^[:space:]]+$ ]]; then + echo "Target bastion inventory must provide one address and one user." >&2 + return 1 + fi +} + +redact_bastion() { + local line + while IFS= read -r line || [[ -n "${line}" ]]; do + line="${line//"${BASTION_USER}@${BASTION_IP}"/}" + line="${line//"${BASTION_IP}"/}" + printf '%s\n' "${line}" + done +} + +print_execution_logs() { + local log + for log in policy-fixture preflight setup runner policy-gate; do + if [[ -f "${REPORT_DIR}/${log}.log" ]]; then + echo "=== IBBF ${log} ===" + cat -- "${REPORT_DIR}/${log}.log" || return "$?" + fi + done +} + +run_ibbf() { + local -a status + local logs_rc=0 test_result + set +e + ansible-playbook ./playbooks/ran/ibi-ibbf.yml \ + -i "${INVENTORY_PATH}/build-inventory.py" \ + --extra-vars "ibi_ibbf_inventory=${INVENTORY_PATH}/build-inventory.py" \ + --extra-vars "ibi_ibbf_hub_kubeconfig=/home/telcov10n/project/generated/${TARGET_CLUSTER_NAME}/auth/kubeconfig" \ + --extra-vars "ibi_ibbf_spoke=${TARGET_SPOKE_NAME} ibi_ibbf_version=${VERSION}" \ + --extra-vars "ibi_ibbf_original_bmc=${IBI_IBBF_ORIGINAL_BMC_HOST}" \ + --extra-vars "ibi_ibbf_replacement_bmc=${IBI_IBBF_REPLACEMENT_BMC_HOST}" \ + --extra-vars "ibi_ibbf_target_ip=${IBI_IBBF_TARGET_IP}" \ + --extra-vars "ibi_ibbf_policy_path=${IBI_IBBF_REPLACEMENT_POLICY_PATH:-}" \ + --extra-vars "ibi_ibbf_policy_repo=${ZTP_GIT_REPO:-}" \ + --extra-vars "ibi_ibbf_policy_revision=${POLICY_REVISION}" \ + --extra-vars "ibi_ibbf_work_dir=${WORK_DIR} ibi_ibbf_report_dir=${REPORT_DIR}" \ + --extra-vars "ibi_ibbf_result_file=${RESULT_FILE}" \ + 2>&1 | redact_bastion | tee "${REPORT_DIR}/playbook.log" + status=("${PIPESTATUS[@]}") + set -e + + print_execution_logs || logs_rc=$? + (( status[0] == 0 )) || return "${status[0]}" + (( status[1] == 0 )) || return "${status[1]}" + (( status[2] == 0 )) || return "${status[2]}" + (( logs_rc == 0 )) || return "${logs_rc}" + test -s "${REPORT_DIR}/ibbf-status.json" + test_result=$(<"${RESULT_FILE}") + [[ "${test_result}" == 0 || "${test_result}" == 1 ]] + cp -- "${REPORT_DIR}/ibbf-status.json" "${SHARED_DIR}/ibi-ibbf-status.json" + echo "IBBF step completed; saved test result: ${test_result}. Final verification will enforce it after reporting." +} + +main() { + RESULT_FILE="${SHARED_DIR}/ibi-ibbf-exit-code" + printf '1\n' > "${RESULT_FILE}" + if [[ -f "${SHARED_DIR}/skip.txt" || "${IBI_IBBF_ENABLED:-false}" == false ]]; then + printf '0\n' > "${RESULT_FILE}" + echo "Skipping IBI IBBF tests." + return 0 + fi + [[ "${IBI_IBBF_ENABLED}" == true ]] + + cd /eco-ci-cd + restore_target_inventory + prepare_inputs + configure_ansible + run_ibbf +} + +main "$@" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-ibbf/telcov10n-functional-cnf-ran-ibi-ibbf-ref.metadata.json b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-ibbf/telcov10n-functional-cnf-ran-ibi-ibbf-ref.metadata.json new file mode 100644 index 000000000000..ed960617ada4 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-ibbf/telcov10n-functional-cnf-ran-ibi-ibbf-ref.metadata.json @@ -0,0 +1,4 @@ +{ + "path": "telcov10n/functional/cnf-ran/ibi-ibbf/telcov10n-functional-cnf-ran-ibi-ibbf-ref.yaml", + "owners": {} +} \ No newline at end of file diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-ibbf/telcov10n-functional-cnf-ran-ibi-ibbf-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-ibbf/telcov10n-functional-cnf-ran-ibi-ibbf-ref.yaml new file mode 100644 index 000000000000..bebaf2628f5c --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-ibbf/telcov10n-functional-cnf-ran-ibi-ibbf-ref.yaml @@ -0,0 +1,61 @@ +ref: + as: telcov10n-functional-cnf-ran-ibi-ibbf + from_image: + namespace: telcov10n-ci + name: eco-ci-cd + tag: eco-ci-cd + commands: telcov10n-functional-cnf-ran-ibi-ibbf-commands.sh + timeout: 6h + grace_period: 5m + resources: + requests: + cpu: 100m + memory: 200Mi + env: + - name: IBI_IBBF_ENABLED + default: "false" + documentation: Enable hardware replacement tests after replacement preinstall. Runner exit 1 is enforced after reporting; playbook setup, transport and collection errors remain blocking. + - name: IBI_REPLACEMENT_PREINSTALL_ENABLED + default: "false" + documentation: Must be enabled so replacement hardware is preinstalled before IBBF. + - name: IBI_IBBF_ORIGINAL_BMC_HOST + default: "" + documentation: Expected original target BMC IPv4 address. The test powers this server off. + - name: IBI_IBBF_REPLACEMENT_BMC_HOST + default: "" + documentation: Replacement BMC IPv4 address, authenticated with the retained target BMC secret. + - name: IBI_IBBF_TARGET_IP + default: "" + documentation: Reserved static target IPv4 or IPv6 address retained by the replacement hardware. + - name: IBI_IBBF_REPLACEMENT_POLICY_PATH + default: "" + documentation: Optional replacement policy fixture under VERSION/SPOKE/policygentemplate/ztp-test/ibbf-test. Activate after hardware replacement and remediate common, group and site policies. Empty retains the current policy path. + - name: ZTP_GIT_REPO + default: "https://gitlab.cee.redhat.com/telcov10n/ztp-site-configs-ci.git" + documentation: Repository of the recorded seed Git revision; must match both target Applications when replacement policies are enabled. + - name: TARGET_CLUSTER_NAME + default: "" + documentation: Target hub name used to locate its kubeconfig on the target bastion. + - name: TARGET_SPOKE_CLUSTER + default: "['ibi-target']" + documentation: Single target spoke name in the existing list format. + - name: VERSION + default: "4.20" + documentation: Release family used for the original target Argo application paths. + credentials: + - namespace: test-credentials + name: telcov10n-ansible-group-all + mount_path: /var/group_variables/common/all + documentation: |- + Invoke playbooks/ran/ibi-ibbf.yml to validate prerequisites before power-off, + run eco-gotests hardware test 78333, collect reports and clean up private files. + After runner exit 0, optionally activate replacement policies pinned to the + recorded seed Git revision and run target-only TALM remediation. Require fresh + policy compliance within 50 minutes, or 75 minutes when switching policies. + Retain hardware and policy JUnit reports and print collected execution logs. + Playbook setup, transport, cleanup, collection errors and missing reports + stop the workflow. Runner exit 1, including suite setup/teardown failures, is saved in + SHARED_DIR/ibi-ibbf-exit-code for final verification after reporting. + Share ibbf-status.json so reporting collects the policy report only when recovery ran. + The step timeout includes additional time for preparation and report collection. + Leave hardware and Argo in their resulting state for investigation. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-replacement-preinstall/OWNERS b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-replacement-preinstall/OWNERS new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-replacement-preinstall/telcov10n-functional-cnf-ran-ibi-replacement-preinstall-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-replacement-preinstall/telcov10n-functional-cnf-ran-ibi-replacement-preinstall-commands.sh new file mode 100755 index 000000000000..794b84f08686 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-replacement-preinstall/telcov10n-functional-cnf-ran-ibi-replacement-preinstall-commands.sh @@ -0,0 +1,131 @@ +#!/bin/bash +set +x +set -euo pipefail +umask 077 + +cleanup() { + local rc=$? + trap - EXIT + rm -rf -- "${TEMP_DIR}" || rc=1 + exit "${rc}" +} + +restore_seed_inventory() { + local name + INVENTORY_PATH=/eco-ci-cd/inventories/ocp-deployment + mkdir -p "${INVENTORY_PATH}/group_vars" "${INVENTORY_PATH}/host_vars" + for name in all bastions; do + cp "${SHARED_DIR}/seed-${name}" "${INVENTORY_PATH}/group_vars/${name}" + done + cp "${SHARED_DIR}/seed-bastion" "${INVENTORY_PATH}/host_vars/bastion" +} + +create_work_directories() { + TEMP_DIR=$(mktemp -d /tmp/ibi-replacement-preinstall.XXXXXX) + trap cleanup EXIT + local subdir="${TEMP_DIR##*/}" + WORK_DIR="/tmp/eco_gotests_ibi_preinstall/${subdir}" + REPORT_DIR="${ARTIFACT_DIR}/ibi-replacement-preinstall" + HTTP_SUBDIR="${subdir}" + mkdir -p "${REPORT_DIR}" + printf '%s\n' "${WORK_DIR}/report" > "${SHARED_DIR}/ibi-rp-preinstall_replacement-dir" +} + +read_seed_inputs() { + SEED_VERSION=$(<"${SHARED_DIR}/ibi-seed-version") + SEED_DIGEST=$(<"${SHARED_DIR}/ibi-seed-digest") + GIT_REVISION=$(<"${SHARED_DIR}/ibi-seed-git-revision") +} + +configure_ansible() { + install -m 600 /var/group_variables/common/all/ansible_ssh_private_key "${TEMP_DIR}/ssh-key" + export ANSIBLE_PRIVATE_KEY_FILE="${TEMP_DIR}/ssh-key" + export ANSIBLE_HOST_KEY_CHECKING=False + export ANSIBLE_SSH_RETRIES=3 + export ANSIBLE_TIMEOUT=600 + export ANSIBLE_REMOTE_TEMP=/tmp + + # Match hub deployment: read connection fields from the generated inventory. + if ! BASTION_IP=$(grep -oP '(?<=ansible_host: ).*' "${INVENTORY_PATH}/host_vars/bastion" | sed "s/'//g") || + ! BASTION_USER=$(grep -oP '(?<=ansible_user: ).*' "${INVENTORY_PATH}/group_vars/all" | sed "s/'//g"); then + echo "Could not read seed bastion address and user from inventory." >&2 + return 1 + fi + if [[ ! "${BASTION_IP} ${BASTION_USER}" =~ ^[^[:space:]]+[[:blank:]][^[:space:]]+$ ]]; then + echo "Seed bastion inventory must provide one address and one user." >&2 + return 1 + fi +} + +redact_bastion() { + local line + while IFS= read -r line || [[ -n "${line}" ]]; do + line="${line//"${BASTION_USER}@${BASTION_IP}"/}" + line="${line//"${BASTION_IP}"/}" + printf '%s\n' "${line}" + done +} + +run_preinstall() { + local -a status + local console_rc=0 test_rc + local console_log="${REPORT_DIR}/report/console.log" + set +e + ansible-playbook ./playbooks/ran/ibi-replacement-preinstall.yml \ + -i "${INVENTORY_PATH}/build-inventory.py" \ + --extra-vars ibi_replacement_preinstall_phase=run \ + --extra-vars "ibi_hub_kubeconfig=/home/telcov10n/project/generated/${CLUSTER_NAME}/auth/kubeconfig" \ + --extra-vars "ibi_seed_version=${SEED_VERSION}" \ + --extra-vars "ibi_seed_digest=${SEED_DIGEST}" \ + --extra-vars "ibi_git_revision=${GIT_REVISION}" \ + --extra-vars "ibi_git_repo=${ZTP_GIT_REPO}" \ + --extra-vars "ibi_release_version=${VERSION} ibi_seed_cluster=${SEED_SPOKE_CLUSTER}" \ + --extra-vars "ibi_preinstall_registry=${MIRROR_REGISTRY}" \ + --extra-vars "ibi_replacement_host=${IBI_REPLACEMENT_HOST}" \ + --extra-vars "ibi_replacement_mac=${IBI_REPLACEMENT_MAC}" \ + --extra-vars "ibi_replacement_ip=${IBI_REPLACEMENT_IP}" \ + --extra-vars "ibi_work_dir=${WORK_DIR} ibi_http_subdir=${HTTP_SUBDIR}" \ + --extra-vars "ibi_report_dir=${REPORT_DIR}" \ + --extra-vars '{"ibi_skip_tls_verify":true}' \ + 2>&1 | redact_bastion | tee "${REPORT_DIR}/execution.log" + status=("${PIPESTATUS[@]}") + set -e + + # The playbook retains the launcher status and reports even when execution fails. + if [[ ! -f "${console_log}" ]]; then console_log="${REPORT_DIR}/runner.log"; fi + if [[ -f "${console_log}" ]]; then + redact_bastion < "${console_log}" || console_rc=$? + fi + if [[ -s "${REPORT_DIR}/execution-exit-code" ]]; then + test_rc=$(<"${REPORT_DIR}/execution-exit-code") + [[ "${test_rc}" =~ ^(0|[1-9][0-9]{0,2})$ ]] && (( test_rc <= 255 )) || return 1 + if (( test_rc != 0 )); then return "${test_rc}"; fi + fi + (( status[0] == 0 )) || return "${status[0]}" + (( status[1] == 0 )) || return "${status[1]}" + (( status[2] == 0 )) || return "${status[2]}" + if [[ ! -s "${REPORT_DIR}/execution-exit-code" ]]; then + echo "Replacement preinstall did not retain its execution status." >&2 + return 1 + fi + return "${console_rc}" +} + +main() { + if [[ -f "${SHARED_DIR}/skip.txt" || "${IBI_REPLACEMENT_PREINSTALL_ENABLED:-false}" == false ]]; then + echo "Skipping IBI replacement preinstall." + return 0 + fi + [[ "${IBI_REPLACEMENT_PREINSTALL_ENABLED}" == true ]] + + cd /eco-ci-cd + restore_seed_inventory + create_work_directories + read_seed_inputs + configure_ansible + run_preinstall + + echo "IBI replacement preinstall execution and report collection completed." +} + +main "$@" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-replacement-preinstall/telcov10n-functional-cnf-ran-ibi-replacement-preinstall-ref.metadata.json b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-replacement-preinstall/telcov10n-functional-cnf-ran-ibi-replacement-preinstall-ref.metadata.json new file mode 100644 index 000000000000..a86c7daed55d --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-replacement-preinstall/telcov10n-functional-cnf-ran-ibi-replacement-preinstall-ref.metadata.json @@ -0,0 +1,4 @@ +{ + "path": "telcov10n/functional/cnf-ran/ibi-replacement-preinstall/telcov10n-functional-cnf-ran-ibi-replacement-preinstall-ref.yaml", + "owners": {} +} \ No newline at end of file diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-replacement-preinstall/telcov10n-functional-cnf-ran-ibi-replacement-preinstall-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-replacement-preinstall/telcov10n-functional-cnf-ran-ibi-replacement-preinstall-ref.yaml new file mode 100644 index 000000000000..4a2bf1ce538b --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-replacement-preinstall/telcov10n-functional-cnf-ran-ibi-replacement-preinstall-ref.yaml @@ -0,0 +1,58 @@ +ref: + as: telcov10n-functional-cnf-ran-ibi-replacement-preinstall + from_image: + namespace: telcov10n-ci + name: eco-ci-cd + tag: eco-ci-cd + commands: telcov10n-functional-cnf-ran-ibi-replacement-preinstall-commands.sh + timeout: 5h + grace_period: 5m + resources: + requests: + cpu: 100m + memory: 200Mi + env: + - name: IBI_REPLACEMENT_PREINSTALL_ENABLED + default: "false" + documentation: Enable replacement preinstall after Deployment Types. Failure blocks subsequent tests. + - name: IBI_REPLACEMENT_HOST + default: "" + documentation: Expected replacement hostname; must match both seed ClusterInstances before cleanup. + - name: IBI_REPLACEMENT_MAC + default: "" + documentation: Expected replacement boot MAC; restricts old seed hardware cleanup. + - name: IBI_REPLACEMENT_IP + default: "" + documentation: Expected IPv4 or IPv6 address resolved by the test container before cleanup; compared using canonical address values. + - name: CLUSTER_NAME + default: "kni-qe-127" + documentation: Seed hub whose bastion prepares the replacement hardware. + - name: SEED_SPOKE_CLUSTER + default: "helix81" + documentation: Former seed spoke name; must match the seed-generation steps. + - name: VERSION + default: "4.20" + documentation: Release family used for Git paths and locating the generated seed image. + - name: MIRROR_REGISTRY + default: "disconnected.registry.local:5000" + documentation: Seed bastion registry containing the generated seed image. + - name: ZTP_GIT_REPO + default: "https://gitlab.cee.redhat.com/telcov10n/ztp-site-configs-ci.git" + documentation: GitLab repository containing the seed ClusterInstance and replacement preinstall template. + credentials: + - namespace: test-credentials + name: telcov10n-ansible-group-all + mount_path: /var/group_variables/common/all + documentation: |- + Prepare the former seed server as replacement hardware before IBBF. + Restore seed inventory and invoke playbooks/ran/ibi-replacement-preinstall.yml. + The playbook verifies the pinned seed image, installer, replacement inputs, + installation disk WWN or NVMe EUI path, container DNS and HTTP access before + releasing old seed resources. It prepares an isolated launcher and HTTP + directory, deletes the seed ClusterInstance normally, waits for hardware + release, then runs preinstall and collects reports even on test failure. + Preserve the launcher exit code and existing Report Portal paths. + Print the console after collection; Ansible reports progress during tests. + Preinstall inputs use the seed digest and Git commit recorded by mirroring. + Use the original quay.io/ocp-edge-qe/eco-gotests:latest image, matching + target preinstall. No service timeout or polling changes are applied. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-report/OWNERS b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-report/OWNERS new file mode 100644 index 000000000000..089e0d506cee --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-report/OWNERS @@ -0,0 +1 @@ +# Inherit approvers from parent OWNERS files. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-report/telcov10n-functional-cnf-ran-ibi-report-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-report/telcov10n-functional-cnf-ran-ibi-report-commands.sh new file mode 100644 index 000000000000..5f37b636d9dc --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-report/telcov10n-functional-cnf-ran-ibi-report-commands.sh @@ -0,0 +1,126 @@ +#!/bin/bash +set +x +set -euo pipefail +umask 077 + +cleanup() { + local rc=$? + trap - EXIT + rm -rf -- "${TEMP_DIR}" || rc=1 + exit "${rc}" +} + +prepare_reporting_checkout() { + ECO_CI_CD_DIR=/eco-ci-cd + [[ -n "${ECO_CI_CD_FORK_REPO:-}" ]] || return 0 + + if [[ ! "${ECO_CI_CD_FORK_REVISION:-}" =~ ^[a-f0-9]{40}$ ]]; then + echo "A reviewed full commit SHA is required for the reporting fork." >&2 + return 1 + fi + ECO_CI_CD_DIR="${TEMP_DIR}/eco-ci-cd" + git clone --quiet --depth 1 --branch "${ECO_CI_CD_FORK_BRANCH:-main}" -- \ + "${ECO_CI_CD_FORK_REPO}" "${ECO_CI_CD_DIR}" + if [[ "$(git -C "${ECO_CI_CD_DIR}" rev-parse HEAD)" != "${ECO_CI_CD_FORK_REVISION}" ]]; then + echo "The reporting fork branch changed. Review its revision before uploading." >&2 + return 1 + fi + # Keep the collections installed in the CI image when using the fork checkout. + export ANSIBLE_COLLECTIONS_PATH=/eco-ci-cd/collections + printf 'IBI reporting revision: %s\n' "${ECO_CI_CD_FORK_REVISION}" +} + +prepare_inventory() { + local side host suffix index + mkdir -p "${TEMP_DIR}/inventory/host_vars" + printf '%s\n' '{"all":{"hosts":{"bastion":{},"ibi_report_seed":{}}}}' > "${TEMP_DIR}/inventory/hosts.yml" + for side in seed target; do + if [[ "$side" == seed ]]; then + [[ -f "${SHARED_DIR}/ibi-rp-seedgen-dir" || -f "${SHARED_DIR}/ibi-rp-preinstall_replacement-dir" ]] || continue + host=ibi_report_seed + else + host=bastion + fi + mkdir -p "${TEMP_DIR}/inventory/host_vars/${host}" + # Ansible loads these files in order: all < bastions < bastion. + index=0 + for suffix in all bastions bastion; do + cp "${SHARED_DIR}/${side}-${suffix}" "${TEMP_DIR}/inventory/host_vars/${host}/${index}-${suffix}.yml" + index=$((index + 1)) + done + done +} + +configure_ansible() { + install -m 600 /var/group_variables/common/all/ansible_ssh_private_key "${TEMP_DIR}/ssh-key" + export ANSIBLE_PRIVATE_KEY_FILE="${TEMP_DIR}/ssh-key" + export ANSIBLE_HOST_KEY_CHECKING=False + export ANSIBLE_REMOTE_TEMP=/tmp + export ANSIBLE_TIMEOUT=600 + # Upload requests must never be resubmitted after a transport failure. + export ANSIBLE_SSH_RETRIES=0 +} + +run_report() { + : "${TARGET_CLUSTER_NAME:?TARGET_CLUSTER_NAME is required for the shared uploader}" + echo "Collecting IBI stage reports and uploading to Report Portal." + # Inventory and upload diagnostics may contain credentials; publish only + # the playbook's reporting-status.json and launch link. + local status=0 + # Environment lookups preserve exact strings without shell or JSON value escaping. + IBI_REPORT_SHARED_DIR="$SHARED_DIR" \ + IBI_REPORT_OUTPUT_DIR="${ARTIFACT_DIR}/reportportal" \ + IBI_REPORT_WORK_DIR="${TEMP_DIR}/reports" \ + IBI_REPORT_VERSION="$VERSION" \ + IBI_REPORT_LAUNCH_NAME="$IBI_REPORTPORTAL_LAUNCH_NAME" \ + IBI_REPORT_BUILD_ID="${BUILD_ID:-unknown}" \ + IBI_REPORT_HUB_KUBECONFIG="/home/telcov10n/project/generated/${TARGET_CLUSTER_NAME}/auth/kubeconfig" \ + ansible-playbook ./playbooks/ran/ibi-report.yml \ + -i "${TEMP_DIR}/inventory/hosts.yml" --extra-vars '{ + "ibi_report_shared_dir": "{{ lookup(\"ansible.builtin.env\", \"IBI_REPORT_SHARED_DIR\") }}", + "ibi_report_output_dir": "{{ lookup(\"ansible.builtin.env\", \"IBI_REPORT_OUTPUT_DIR\") }}", + "ibi_report_work_dir": "{{ lookup(\"ansible.builtin.env\", \"IBI_REPORT_WORK_DIR\") }}", + "ibi_report_version": "{{ lookup(\"ansible.builtin.env\", \"IBI_REPORT_VERSION\") }}", + "ibi_report_launch_name": "{{ lookup(\"ansible.builtin.env\", \"IBI_REPORT_LAUNCH_NAME\") }}", + "reporter_launch_name": "{{ lookup(\"ansible.builtin.env\", \"IBI_REPORT_LAUNCH_NAME\") }}-{{ lookup(\"ansible.builtin.env\", \"IBI_REPORT_VERSION\") }}", + "ibi_report_build_id": "{{ lookup(\"ansible.builtin.env\", \"IBI_REPORT_BUILD_ID\") }}", + "ibi_report_hub_kubeconfig": "{{ lookup(\"ansible.builtin.env\", \"IBI_REPORT_HUB_KUBECONFIG\") }}" + }' \ + > "${TEMP_DIR}/reporting.log" 2>&1 || status=$? + printf 'IBI reporting status: %s. See reportportal artifacts for details.\n' "$status" + if [[ -s "${ARTIFACT_DIR}/reportportal/reportportal-url.txt" ]]; then + printf 'Report Portal: %s\n' "$(<"${ARTIFACT_DIR}/reportportal/reportportal-url.txt")" + fi + return "$status" +} + +main() { + local lane registered=false + if [[ -f "${SHARED_DIR}/skip.txt" ]]; then + echo "Skipping IBI Report Portal upload." + return 0 + fi + mkdir -p "${ARTIFACT_DIR}/reportportal" + rm -f -- "${SHARED_DIR}/ibi-reportportal-url" \ + "${ARTIFACT_DIR}/reportportal/reportportal-url.txt" + for lane in seedgen preinstall ibi preinstall_replacement ibbf; do + if [[ -f "${SHARED_DIR}/ibi-rp-${lane}-dir" ]]; then registered=true; fi + done + if ! "$registered"; then + printf '%s\n' '{"stages":{},"upload":"skipped: no test stage registered a report directory"}' \ + > "${ARTIFACT_DIR}/reportportal/reporting-status.json" + echo "No IBI stage reports registered; skipping upload." + return 0 + fi + printf '%s\n' '{"phase":"controller preparation","upload":"not attempted"}' \ + > "${ARTIFACT_DIR}/reportportal/reporting-status.json" + TEMP_DIR=$(mktemp -d /tmp/ibi-reportportal.XXXXXX) + trap cleanup EXIT + prepare_reporting_checkout + cd "${ECO_CI_CD_DIR}" + prepare_inventory + configure_ansible + run_report +} + +main "$@" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-report/telcov10n-functional-cnf-ran-ibi-report-ref.metadata.json b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-report/telcov10n-functional-cnf-ran-ibi-report-ref.metadata.json new file mode 100644 index 000000000000..8b7f947f622b --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-report/telcov10n-functional-cnf-ran-ibi-report-ref.metadata.json @@ -0,0 +1,4 @@ +{ + "path": "telcov10n/functional/cnf-ran/ibi-report/telcov10n-functional-cnf-ran-ibi-report-ref.yaml", + "owners": {} +} \ No newline at end of file diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-report/telcov10n-functional-cnf-ran-ibi-report-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-report/telcov10n-functional-cnf-ran-ibi-report-ref.yaml new file mode 100644 index 000000000000..1dff781cfb6c --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-report/telcov10n-functional-cnf-ran-ibi-report-ref.yaml @@ -0,0 +1,45 @@ +ref: + as: telcov10n-functional-cnf-ran-ibi-report + from_image: + namespace: telcov10n-ci + name: eco-ci-cd + tag: eco-ci-cd + commands: telcov10n-functional-cnf-ran-ibi-report-commands.sh + timeout: 30m + grace_period: 1m + resources: + requests: + cpu: 100m + memory: 512Mi + env: + - name: ECO_CI_CD_FORK_REPO + default: "" + documentation: Optional HTTPS eco-ci-cd fork for IBI reporting only. Empty uses the CI image checkout. + - name: ECO_CI_CD_FORK_BRANCH + default: main + documentation: Branch to clone when ECO_CI_CD_FORK_REPO is set. + - name: ECO_CI_CD_FORK_REVISION + default: "" + documentation: Reviewed full commit SHA that the reporting fork branch must match before execution. + - name: TARGET_CLUSTER_NAME + default: "" + documentation: Target hub whose kubeconfig provides metadata to the shared uploader. + - name: VERSION + default: "4.20" + documentation: OpenShift release family used in the ReportPortal launch name. + - name: IBI_REPORTPORTAL_LAUNCH_NAME + default: telco-ft-ran-ibi + documentation: Launch prefix; the reporter appends the OpenShift release family. + credentials: + - namespace: test-credentials + name: telcov10n-ansible-group-all + mount_path: /var/group_variables/common/all + documentation: |- + Collect current-run raw JUnit reports from the seed and target bastions. + Prefix suites by IBI stage and upload them together to ReportPortal using + ibi-report.yml and its shared upload-report.yaml from the selected checkout. + Include the independent IBBF policy gate and retain the versioned launch name. + The temporary reporting fork uses the direct Report Portal uploader. + Collection or upload errors fail the step; incomplete bundles are not uploaded. + Completed test failures remain reportable. Keep the shared final verifier + responsible for deferred Deployment Types and IBBF test failures. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi/OWNERS b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-seed-prepare/OWNERS similarity index 100% rename from ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi/OWNERS rename to ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-seed-prepare/OWNERS diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-seed-prepare/telcov10n-functional-cnf-ran-ibi-seed-prepare-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-seed-prepare/telcov10n-functional-cnf-ran-ibi-seed-prepare-commands.sh new file mode 100755 index 000000000000..7715bf7308f8 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-seed-prepare/telcov10n-functional-cnf-ran-ibi-seed-prepare-commands.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set +x +set -euo pipefail +umask 077 + +if [ -f "${SHARED_DIR}/skip.txt" ]; then + echo "Detected skip.txt file — skipping seed preparation" + exit 0 +fi + +# Tasks delegated to localhost also need writable module staging in Prow. +export ANSIBLE_REMOTE_TEMP=/tmp + +INVENTORY_PATH="/eco-ci-cd/inventories/ocp-deployment" + +# Load the seed inventory restored by ibu-restore-seed-inventory. +mkdir -p "${INVENTORY_PATH}/group_vars" "${INVENTORY_PATH}/host_vars" +for key in all bastions nodes masters; do + cp "${SHARED_DIR}/${key}" "${INVENTORY_PATH}/group_vars/${key}" +done +cp "${SHARED_DIR}/bastion" "${INVENTORY_PATH}/host_vars/bastion" + +# Prepare the seed while it is still managed by ACM and record its completed +# OpenShift version on the controller for subsequent IBI steps. +cd /eco-ci-cd +rm -f -- "${SHARED_DIR}/ibi-seed-version" +ansible-playbook playbooks/ran/ibi-seed-prepare.yml \ + -i "${INVENTORY_PATH}/build-inventory.py" \ + --limit bastion \ + --extra-vars "hub_cluster=${CLUSTER_NAME}" \ + --extra-vars "spoke_cluster=${SEED_SPOKE_CLUSTER}" \ + --extra-vars "ibi_seed_version_file=${SHARED_DIR}/ibi-seed-version" \ + --extra-vars "ibi_seed_diagnostics_dir=${ARTIFACT_DIR}" + +# Ansible can exit successfully when the inventory matches no hosts. +test -s "${SHARED_DIR}/ibi-seed-version" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-seed-prepare/telcov10n-functional-cnf-ran-ibi-seed-prepare-ref.metadata.json b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-seed-prepare/telcov10n-functional-cnf-ran-ibi-seed-prepare-ref.metadata.json new file mode 100644 index 000000000000..e183a7a70d51 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-seed-prepare/telcov10n-functional-cnf-ran-ibi-seed-prepare-ref.metadata.json @@ -0,0 +1,16 @@ +{ + "path": "telcov10n/functional/cnf-ran/ibi-seed-prepare/telcov10n-functional-cnf-ran-ibi-seed-prepare-ref.yaml", + "owners": { + "approvers": [ + "ccardenosa", + "eifrach", + "kononovn", + "mkochanowski", + "rdiazcam", + "rdiscala", + "shaior", + "timurmp", + "rileyfw" + ] + } +} \ No newline at end of file diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-seed-prepare/telcov10n-functional-cnf-ran-ibi-seed-prepare-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-seed-prepare/telcov10n-functional-cnf-ran-ibi-seed-prepare-ref.yaml new file mode 100644 index 000000000000..39aa0d11acc0 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-seed-prepare/telcov10n-functional-cnf-ran-ibi-seed-prepare-ref.yaml @@ -0,0 +1,31 @@ +ref: + as: telcov10n-functional-cnf-ran-ibi-seed-prepare + from_image: + namespace: telcov10n-ci + name: eco-ci-cd + tag: eco-ci-cd + commands: telcov10n-functional-cnf-ran-ibi-seed-prepare-commands.sh + timeout: 60m + grace_period: 1m + resources: + requests: + cpu: 100m + memory: 200Mi + env: + - name: CLUSTER_NAME + default: "kni-qe-127" + documentation: Seed hub cluster name used to retrieve the spoke kubeconfig from ACM + - name: SEED_SPOKE_CLUSTER + default: "helix81" + documentation: Seed spoke cluster name; must match the seedgeneration step + documentation: |- + Prepare the IBI seed before detaching it from ACM. Load the restored seed + inventory from SHARED_DIR and run ran/ibi-seed-prepare.yml, which reuses + IBU preparation to retrieve the seed kubeconfig and prepare the CoreOS + extensions image, then validates the installed seed OpenShift version. + Run after seed deployment and before ibu-prune-argocd-apps. + The kubeconfig remains at /tmp/${SEED_SPOKE_CLUSTER}-kubeconfig on the seed + bastion for ibi-eco-gotests-seed to use after detachment. + The playbook writes the completed full version to SHARED_DIR/ibi-seed-version + on the controller for subsequent IBI steps. Metadata failures remain blocking + and save sanitized diagnostics to ARTIFACT_DIR/ibi-seed-version-error.json. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-config/OWNERS b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-config/OWNERS new file mode 100644 index 000000000000..b63f3e998249 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-config/OWNERS @@ -0,0 +1,9 @@ +approvers: +- ccardenosa +- eifrach +- kononovn +- mkochanowski +- rdiazcam +- rdiscala +- shaior +- timurmp diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-config/telcov10n-functional-cnf-ran-ibi-target-hub-config-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-config/telcov10n-functional-cnf-ran-ibi-target-hub-config-commands.sh new file mode 100644 index 000000000000..af26eb2dde03 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-config/telcov10n-functional-cnf-ran-ibi-target-hub-config-commands.sh @@ -0,0 +1,118 @@ +#!/bin/bash +set -e +set -o pipefail + +if [ -f "${SHARED_DIR}/skip.txt" ]; then + echo "Detected skip.txt — skipping" + exit 0 +fi + +process_inventory() { + local directory="$1" + local dest_file="$2" + + if [ -z "$directory" ]; then + echo "Usage: process_inventory " + return 1 + fi + + if [ ! -d "$directory" ]; then + echo "Error: '$directory' is not a valid directory" + return 1 + fi + + find "$directory" -type f | while IFS= read -r filename; do + if [[ $filename == *"secretsync-vault-source-path"* ]]; then + continue + fi + local content + content=$(cat "$filename") + local varname + varname=$(basename "${filename}") + if [[ "$content" == *$'\n'* ]]; then + printf '%s: |\n' "${varname}" + printf '%s\n' "$content" | sed 's/^/ /' + else + printf "%s: '%s'\n" "${varname}" "${content//\'/\'\'}" + fi + done > "${dest_file}" +} + +echo "Processing common group_vars" +mkdir -p /eco-ci-cd/inventories/ocp-deployment/group_vars + +find /var/group_variables/common/ -mindepth 1 -type d 2>/dev/null | while read -r dir; do + echo " group_var: $(basename "${dir}")" + process_inventory "$dir" /eco-ci-cd/inventories/ocp-deployment/group_vars/"$(basename "${dir}")" +done + +echo "Copying host_vars from SHARED_DIR" +mkdir -p /eco-ci-cd/inventories/ocp-deployment/host_vars + +cp "${SHARED_DIR}/bastion" /eco-ci-cd/inventories/ocp-deployment/host_vars/bastion +cp "${SHARED_DIR}/master0" /eco-ci-cd/inventories/ocp-deployment/host_vars/master0 + +if [[ -f "${SHARED_DIR}/cluster_name" ]]; then + CLUSTER_NAME=$(cat "${SHARED_DIR}/cluster_name") +fi +echo "CLUSTER_NAME=${CLUSTER_NAME}" + +KUBECONFIG_PATH="/home/telcov10n/project/generated/${CLUSTER_NAME}/auth/kubeconfig" + +PROJECT_DIR="/tmp" +cat /var/group_variables/common/all/ansible_ssh_private_key > "${PROJECT_DIR}/ansible_ssh_key" +chmod 600 "${PROJECT_DIR}/ansible_ssh_key" +export ANSIBLE_PRIVATE_KEY_FILE="${PROJECT_DIR}/ansible_ssh_key" + +export ANSIBLE_SSH_RETRIES=3 +export ANSIBLE_TIMEOUT=600 +export ANSIBLE_HOST_KEY_CHECKING=False + +VERSION_TAG=$(echo "${VERSION}" | tr '.' '-') +export VERSION_TAG +echo "VERSION_TAG=${VERSION_TAG}" + +HUB_OPERATORS=$(echo "${HUB_OPERATORS}" | sed "s/\${VERSION_TAG}/${VERSION_TAG}/g") +echo "HUB_OPERATORS=${HUB_OPERATORS}" + +cd /eco-ci-cd/ + +echo "Deploying hub operators (VERSION=${VERSION}, VERSION_TAG=${VERSION_TAG})" + +if [[ "$VERSION" == "4.14" ]]; then + echo "Applying ose-kube-rbac-proxy workaround for 4.14" + ansible-playbook playbooks/ran/mirror-ose-kube-rbac-proxy-wa.yml \ + -i inventories/ocp-deployment/build-inventory.py \ + --extra-vars "version=$VERSION" +fi + +SKIP_REGISTRY_CLEANUP="" +if [[ "$VERSION" == "4.14" ]]; then + SKIP_REGISTRY_CLEANUP="ocp_operator_mirror_skip_internal_registry_cleanup=true" +fi + +echo "Running deploy-ocp-operators" +ansible-playbook ./playbooks/deploy-ocp-operators.yml \ + -i ./inventories/ocp-deployment/build-inventory.py \ + --extra-vars "kubeconfig=${KUBECONFIG_PATH} version=$VERSION disconnected=$DISCONNECTED operators='$HUB_OPERATORS' $SKIP_REGISTRY_CLEANUP" + +echo "Configuring LVM storage" +ansible-playbook playbooks/ran/hub-sno-configure-lvm-storage.yml \ + -i ./inventories/ocp-deployment/build-inventory.py \ + --private-key="${PROJECT_DIR}/ansible_ssh_key" \ + --extra-vars "kubeconfig=${KUBECONFIG_PATH}" -vv + +echo "Configuring ACM" +ansible-playbook playbooks/ran/hub-sno-configure-acm.yml \ + -i ./inventories/ocp-deployment/build-inventory.py \ + --extra-vars "kubeconfig=${KUBECONFIG_PATH} ocp_version=$VERSION" -vv + +echo "Configuring kustomize plugin" +ansible-playbook playbooks/ran/hub-sno-configure-kustomize-plugin.yml \ + -i ./inventories/ocp-deployment/build-inventory.py \ + --extra-vars "kubeconfig=${KUBECONFIG_PATH} ocp_version=$VERSION" -vv + +echo "Configuring GitOps" +ansible-playbook playbooks/ran/hub-sno-configure-gitops.yml \ + -i ./inventories/ocp-deployment/build-inventory.py \ + --extra-vars "kubeconfig=${KUBECONFIG_PATH} gitlab_repo_url=${ZTP_GIT_REPO}" -vv diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-config/telcov10n-functional-cnf-ran-ibi-target-hub-config-ref.metadata.json b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-config/telcov10n-functional-cnf-ran-ibi-target-hub-config-ref.metadata.json new file mode 100644 index 000000000000..ab71641b57de --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-config/telcov10n-functional-cnf-ran-ibi-target-hub-config-ref.metadata.json @@ -0,0 +1,15 @@ +{ + "path": "telcov10n/functional/cnf-ran/ibi-target-hub-config/telcov10n-functional-cnf-ran-ibi-target-hub-config-ref.yaml", + "owners": { + "approvers": [ + "ccardenosa", + "eifrach", + "kononovn", + "mkochanowski", + "rdiazcam", + "rdiscala", + "shaior", + "timurmp" + ] + } +} \ No newline at end of file diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-config/telcov10n-functional-cnf-ran-ibi-target-hub-config-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-config/telcov10n-functional-cnf-ran-ibi-target-hub-config-ref.yaml new file mode 100644 index 000000000000..61d352f7f4f4 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-config/telcov10n-functional-cnf-ran-ibi-target-hub-config-ref.yaml @@ -0,0 +1,46 @@ +ref: + as: telcov10n-functional-cnf-ran-ibi-target-hub-config + from_image: + namespace: telcov10n-ci + name: eco-ci-cd + tag: eco-ci-cd + commands: telcov10n-functional-cnf-ran-ibi-target-hub-config-commands.sh + timeout: 5h + resources: + requests: + cpu: 100m + env: + - name: VERSION + default: "4.20" + documentation: OCP version of the target hub + - name: CLUSTER_NAME + default: "kni-qe-128" + documentation: BM cluster name for the IBI target hub (overridden at runtime via ${SHARED_DIR}/cluster_name) + - name: HUB_OPERATORS + default: | + [ + {"name":"local-storage-operator","catalog":"redhat-operators","nsname":"openshift-local-storage","channel":"stable","og_name":"local-operator-group","subscription_name":"local-storage-operator","deploy_default_config":false,"ns_annotations":{"workload.openshift.io/allowed":"management"}}, + {"name":"openshift-gitops-operator","catalog":"redhat-operators","nsname":"openshift-gitops-operator","channel":"latest","og_name":"openshift-gitops-operator","subscription_name":"openshift-gitops-operator","deploy_default_config":false,"og_spec":{"targetNamespaces":[]}}, + {"name":"advanced-cluster-management","catalog":"redhat-operators","nsname":"open-cluster-management","channel":"release-2.15","og_name":"open-cluster-management","subscription_name":"acm-operator-subscription","deploy_default_config":false,"og_spec":{"targetNamespaces":["open-cluster-management"]}}, + {"name":"multicluster-engine","catalog":"redhat-operators","nsname":"multicluster-engine","channel":"stable-2.10","og_name":"multicluster-engine","subscription_name":"multicluster-engine","deploy_default_config":true,"og_spec":{}}, + {"name":"topology-aware-lifecycle-manager","catalog":"topology-aware-lifecycle-manager-fbc","og_name":"global-operators","nsname":"openshift-operators","fbc_iib_repo":"latest","channel":"stable","deploy_default_config":false,"ocp_operator_mirror_fbc_image_base":"quay.io/redhat-user-workloads/telco-5g-tenant/topology-aware-lifecycle-manager-fbc-${VERSION_TAG}"} + ] + documentation: Hub cluster operators to deploy on the IBI target hub + - name: DISCONNECTED + default: "true" + documentation: Install operators in disconnected mode + - name: ZTP_GIT_REPO + default: "https://gitlab.cee.redhat.com/telcov10n/ztp-site-configs-ci.git" + documentation: ztp-site-configs-ci repo URL + credentials: + - namespace: test-credentials + name: telcov10n-ansible-group-all + mount_path: /var/group_variables/common/all + - namespace: test-credentials + name: telcov10n-ansible-group-bastions + mount_path: /var/group_variables/common/bastions + documentation: |- + Configure IBI target hub (kni-qe-128) with operators and ACM/GitOps setup. + Cluster identity is read from ${SHARED_DIR}/cluster_name written by ibi-target-hub-deploy. + Installs ACM, MCE, LSO, GitOps, and TALM at VERSION. No LCA/OADP needed on the target hub + (those are deployed on the seed spoke by ZTP for seed image generation). diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-deploy/OWNERS b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-deploy/OWNERS new file mode 100644 index 000000000000..b63f3e998249 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-deploy/OWNERS @@ -0,0 +1,9 @@ +approvers: +- ccardenosa +- eifrach +- kononovn +- mkochanowski +- rdiazcam +- rdiscala +- shaior +- timurmp diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-deploy/telcov10n-functional-cnf-ran-ibi-target-hub-deploy-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-deploy/telcov10n-functional-cnf-ran-ibi-target-hub-deploy-commands.sh new file mode 100644 index 000000000000..e5194ec7554e --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-deploy/telcov10n-functional-cnf-ran-ibi-target-hub-deploy-commands.sh @@ -0,0 +1,137 @@ +#!/bin/bash +set -euo pipefail + +if [ -f "${SHARED_DIR}/skip.txt" ]; then + echo "Detected skip.txt — skipping" + exit 0 +fi + +MOUNTED_HOST_INVENTORY="/var/host_variables" + +cleanup() { + local rc=$? + trap - EXIT + rm -rf -- "${TEMP_DIR}" || rc=1 + exit "${rc}" +} + +process_inventory() { + local directory="$1" + local dest_file="$2" + + if [ -z "$directory" ]; then + echo "Usage: process_inventory " + return 1 + fi + + if [ ! -d "$directory" ]; then + echo "Error: '$directory' is not a valid directory" + return 1 + fi + + find "$directory" -type f | while IFS= read -r filename; do + if [[ $filename == *"secretsync-vault-source-path"* ]]; then + continue + fi + local content varname + content=$(cat "$filename") + varname=$(basename "${filename}") + if [[ "$content" == *$'\n'* ]]; then + printf '%s: |\n' "${varname}" + printf '%s\n' "$content" | sed 's/^/ /' + else + printf "%s: '%s'\n" "${varname}" "${content//\'/\'\'}" + fi + done > "${dest_file}" +} + +echo "TARGET_CLUSTER_NAME=${TARGET_CLUSTER_NAME}" +echo "TARGET_HUB_VERSION=${VERSION}" + +echo "Processing common group_vars" +mkdir /eco-ci-cd/inventories/ocp-deployment/group_vars + +find /var/group_variables/common/ -mindepth 1 -maxdepth 1 -type d | while read -r dir; do + echo " group_var: $(basename "${dir}")" + process_inventory "$dir" /eco-ci-cd/inventories/ocp-deployment/group_vars/"$(basename "${dir}")" +done + +echo "Processing target hub group_vars (${TARGET_CLUSTER_NAME})" +find "/var/group_variables/${TARGET_CLUSTER_NAME}/" -mindepth 1 -maxdepth 1 -type d | while read -r dir; do + echo " group_var: $(basename "${dir}")" + process_inventory "$dir" /eco-ci-cd/inventories/ocp-deployment/group_vars/"$(basename "${dir}")" +done + +echo "Processing target hub host_vars (${TARGET_CLUSTER_NAME})" +mkdir /eco-ci-cd/inventories/ocp-deployment/host_vars + +find "${MOUNTED_HOST_INVENTORY}/${TARGET_CLUSTER_NAME}/" -mindepth 1 -maxdepth 1 -type d | while read -r dir; do + echo " host_var: $(basename "${dir}")" + process_inventory "$dir" /eco-ci-cd/inventories/ocp-deployment/host_vars/"$(basename "${dir}")" +done + +cd /eco-ci-cd + +echo "Running deploy-ocp-sno for target hub ${TARGET_CLUSTER_NAME} (version=${VERSION})" +EXTRA_VARS="release=${VERSION} cluster_name=${TARGET_CLUSTER_NAME} disconnected=true" +if [ "${DISABLE_INSIGHTS}" = "true" ]; then + EXTRA_VARS="${EXTRA_VARS} disable_insights=true" +fi + +# Inventory preserves PEM newlines; extra-var precedence overrides the legacy certificate formatter. +ansible-playbook ./playbooks/deploy-ocp-sno.yml \ + -i ./inventories/ocp-deployment/build-inventory.py \ + --extra-vars "${EXTRA_VARS}" \ + --extra-vars '{"disconnected_registry_cert_formatted":"{{ disconnected_registry_cert }}"}' + +# Write target hub inventory to SHARED_DIR (used by downstream steps). +# host_vars are copied flat — no prefix, as these are the "primary" hub files. +# group_vars/all is common across all clusters — same approach as seed hub. +echo "Copying target hub inventory to SHARED_DIR" +find /eco-ci-cd/inventories/ocp-deployment/host_vars -maxdepth 1 -type f | while read -r f; do + cp "$f" "${SHARED_DIR}/$(basename "$f")" +done +find /eco-ci-cd/inventories/ocp-deployment/group_vars -maxdepth 1 -type f | while read -r f; do + cp "$f" "${SHARED_DIR}/$(basename "$f")" +done +echo "${TARGET_CLUSTER_NAME}" > "${SHARED_DIR}/cluster_name" + +echo "Preserving target hub inventory with target- prefix (readable after ibu-restore-seed-inventory)" +for key in bastion hypervisor master0 all bastions hypervisors nodes masters; do + [[ -f "${SHARED_DIR}/${key}" ]] && cp "${SHARED_DIR}/${key}" "${SHARED_DIR}/target-${key}" +done + +echo "Getting target hub cluster version" +HUB_KUBECONFIG="/home/telcov10n/project/generated/${TARGET_CLUSTER_NAME}/auth/kubeconfig" + +TEMP_DIR=$(mktemp -d /tmp/ibi-target-hub-deploy.XXXXXX) +trap cleanup EXIT +install -m 600 /var/group_variables/common/all/ansible_ssh_private_key "${TEMP_DIR}/ssh-key" + +# Match seed hub deployment: read connection fields from the generated inventory. +if ! BASTION_IP=$(grep -oP '(?<=ansible_host: ).*' /eco-ci-cd/inventories/ocp-deployment/host_vars/bastion | sed "s/'//g") || + ! BASTION_USER=$(grep -oP '(?<=ansible_user: ).*' /eco-ci-cd/inventories/ocp-deployment/group_vars/all | sed "s/'//g"); then + echo "Could not read target bastion address and user from inventory." >&2 + exit 1 +fi +if [[ ! "${BASTION_IP} ${BASTION_USER}" =~ ^[^[:space:]]+[[:blank:]][^[:space:]]+$ ]]; then + echo "Target bastion inventory must provide one address and one user." >&2 + exit 1 +fi + +if CLUSTER_VERSION=$(ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -i "${TEMP_DIR}/ssh-key" "${BASTION_USER}@${BASTION_IP}" \ + "KUBECONFIG=${HUB_KUBECONFIG} oc get clusterversion version -ojsonpath='{.status.desired.version}'" \ + 2>"${TEMP_DIR}/version.log"); then + if [[ -z "${CLUSTER_VERSION}" ]]; then + echo "Target hub cluster version query returned an empty result." >&2 + exit 1 + fi +else + status=$? + echo "Could not read target hub cluster version (SSH/oc exit status ${status})." >&2 + exit "${status}" +fi + +echo "Target hub cluster version: ${CLUSTER_VERSION}" +echo "${CLUSTER_VERSION}" > "${SHARED_DIR}/target_hub_version" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-deploy/telcov10n-functional-cnf-ran-ibi-target-hub-deploy-ref.metadata.json b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-deploy/telcov10n-functional-cnf-ran-ibi-target-hub-deploy-ref.metadata.json new file mode 100644 index 000000000000..2b77c83a65ff --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-deploy/telcov10n-functional-cnf-ran-ibi-target-hub-deploy-ref.metadata.json @@ -0,0 +1,15 @@ +{ + "path": "telcov10n/functional/cnf-ran/ibi-target-hub-deploy/telcov10n-functional-cnf-ran-ibi-target-hub-deploy-ref.yaml", + "owners": { + "approvers": [ + "ccardenosa", + "eifrach", + "kononovn", + "mkochanowski", + "rdiazcam", + "rdiscala", + "shaior", + "timurmp" + ] + } +} \ No newline at end of file diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-deploy/telcov10n-functional-cnf-ran-ibi-target-hub-deploy-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-deploy/telcov10n-functional-cnf-ran-ibi-target-hub-deploy-ref.yaml new file mode 100644 index 000000000000..19ff0d1825af --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-hub-deploy/telcov10n-functional-cnf-ran-ibi-target-hub-deploy-ref.yaml @@ -0,0 +1,53 @@ +ref: + as: telcov10n-functional-cnf-ran-ibi-target-hub-deploy + from_image: + namespace: telcov10n-ci + name: eco-ci-cd + tag: eco-ci-cd + commands: telcov10n-functional-cnf-ran-ibi-target-hub-deploy-commands.sh + timeout: 6h + grace_period: 1m + resources: + requests: + cpu: 100m + memory: 200Mi + env: + - name: VERSION + default: "4.20" + documentation: OCP version to deploy on the IBI target hub + - name: TARGET_CLUSTER_NAME + default: "kni-qe-128" + documentation: BM cluster name for the IBI target hub + - name: DISABLE_INSIGHTS + default: "false" + documentation: Set to "true" to remove cloud.openshift.com from pull secret, disabling Insights and Telemetry + credentials: + - namespace: test-credentials + name: telcov10n-ansible-group-all + mount_path: /var/group_variables/common/all + - namespace: test-credentials + name: telcov10n-ansible-group-bastions + mount_path: /var/group_variables/common/bastions + - namespace: test-credentials + name: telcov10n-ansible-group-hypervisors + mount_path: /var/group_variables/common/hypervisors + # kni-qe-128 (IBI target hub) + - namespace: test-credentials + name: telcov10n-ansible-hub-kni-qe-128 + mount_path: /var/host_variables/kni-qe-128/master0 + - namespace: test-credentials + name: telcov10n-ansible-kni-qe-128-bastion + mount_path: /var/host_variables/kni-qe-128/bastion + - namespace: test-credentials + name: telcov10n-ansible-group-hub-kni-qe-128-nodes + mount_path: /var/group_variables/kni-qe-128/nodes + - namespace: test-credentials + name: telcov10n-ansible-group-hub-kni-qe-128-masters + mount_path: /var/group_variables/kni-qe-128/masters + - namespace: test-credentials + name: telcov10n-ansible-hypervisors-helix118 + mount_path: /var/host_variables/kni-qe-128/hypervisor + documentation: |- + Deploy IBI target hub (kni-qe-128). + The target hub manages the IBI target spoke cluster (helix82) that will be + installed fresh via the Image-Based Installation ISO generated from the seed spoke. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/OWNERS b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/OWNERS new file mode 100644 index 000000000000..b63f3e998249 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/OWNERS @@ -0,0 +1,9 @@ +approvers: +- ccardenosa +- eifrach +- kononovn +- mkochanowski +- rdiazcam +- rdiscala +- shaior +- timurmp diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators-commands.sh new file mode 100644 index 000000000000..1600cbead6dd --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators-commands.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -e +set -o pipefail + +if [ -f "${SHARED_DIR}/skip.txt" ]; then + echo "Detected skip.txt — skipping" + exit 0 +fi + +echo "Copying inventory from SHARED_DIR" +mkdir -p /eco-ci-cd/inventories/ocp-deployment/group_vars + +cp "${SHARED_DIR}/all" /eco-ci-cd/inventories/ocp-deployment/group_vars/all +cp "${SHARED_DIR}/bastions" /eco-ci-cd/inventories/ocp-deployment/group_vars/bastions +cp "${SHARED_DIR}/hypervisors" /eco-ci-cd/inventories/ocp-deployment/group_vars/hypervisors +cp "${SHARED_DIR}/nodes" /eco-ci-cd/inventories/ocp-deployment/group_vars/nodes +cp "${SHARED_DIR}/masters" /eco-ci-cd/inventories/ocp-deployment/group_vars/masters + +mkdir -p /eco-ci-cd/inventories/ocp-deployment/host_vars + +cp "${SHARED_DIR}/bastion" /eco-ci-cd/inventories/ocp-deployment/host_vars/bastion +cp "${SHARED_DIR}/hypervisor" /eco-ci-cd/inventories/ocp-deployment/host_vars/hypervisor +cp "${SHARED_DIR}/master0" /eco-ci-cd/inventories/ocp-deployment/host_vars/master0 + +if [[ -f "${SHARED_DIR}/cluster_name" ]]; then + CLUSTER_NAME=$(cat "${SHARED_DIR}/cluster_name") +fi +echo "CLUSTER_NAME=${CLUSTER_NAME}" + +KUBECONFIG_PATH="/home/telcov10n/project/generated/${CLUSTER_NAME}/auth/kubeconfig" + +cd /eco-ci-cd + +echo "Mirroring spoke operators to target hub disconnected registry (VERSION=${VERSION})" +ansible-playbook ./playbooks/deploy-ocp-operators.yml \ + -i ./inventories/ocp-deployment/build-inventory.py \ + --extra-vars "kubeconfig=${KUBECONFIG_PATH} version=${VERSION} disconnected=true mirror_only=true operators='$SPOKE_OPERATORS' ocp_operator_mirror_skip_internal_registry_cleanup=true" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators-ref.metadata.json b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators-ref.metadata.json new file mode 100644 index 000000000000..09e6abc434f6 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators-ref.metadata.json @@ -0,0 +1,15 @@ +{ + "path": "telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators-ref.yaml", + "owners": { + "approvers": [ + "ccardenosa", + "eifrach", + "kononovn", + "mkochanowski", + "rdiazcam", + "rdiscala", + "shaior", + "timurmp" + ] + } +} \ No newline at end of file diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators-ref.yaml new file mode 100644 index 000000000000..c0038da74b63 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-mirror-spoke-operators/telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators-ref.yaml @@ -0,0 +1,33 @@ +ref: + as: telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators + from_image: + namespace: telcov10n-ci + name: eco-ci-cd + tag: eco-ci-cd + commands: telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators-commands.sh + timeout: 4h + resources: + requests: + cpu: 100m + memory: 200Mi + env: + - name: VERSION + default: "4.20" + documentation: OCP version of the spoke operators to mirror + - name: SPOKE_OPERATORS + default: | + [ + {"name":"sriov-fec","catalog":"certified-operators","nsname":"vran-acceleration-operators","channel":"stable"}, + {"name":"ptp-operator","catalog":"redhat-operators-ptp-art","fbc_iib_repo":"ose-ptp-rhel9-operator","nsname":"openshift-ptp","channel":"stable","ns_labels":{"workload.openshift.io/allowed":"management","name":"openshift-ptp"}}, + {"name":"sriov-network-operator","catalog":"redhat-operators-sriov-art","fbc_iib_repo":"ose-sriov-network-rhel9-operator","nsname":"openshift-sriov-network-operator","channel":"stable","og_name":"sriov-network-operators","subscription_name":"sriov-network-operator-subscription"}, + {"name":"cluster-logging","catalog":"redhat-operators","catalog_version_override":"4.20","nsname":"openshift-logging","channel":"stable-6.2","og_name":"cluster-logging","subscription_name":"cluster-logging","og_spec":{"targetNamespaces":[]}}, + {"name":"local-storage-operator","fbc_iib_repo":"ose-local-storage-rhel9-operator","catalog":"redhat-operators-storage-art","nsname":"openshift-local-storage","channel":"stable","og_name":"local-operator-group","subscription_name":"local-storage-operator","deploy_default_config":false,"ns_labels":{"workload.openshift.io/allowed":"management"}}, + {"name":"lifecycle-agent","catalog":"lifecycle-agent-fbc","og_name":"global-operators","nsname":"openshift-operators","fbc_iib_repo":"latest","channel":"stable","deploy_default_config":false,"ocp_operator_mirror_fbc_image_base":"quay.io/redhat-user-workloads/telco-5g-tenant/lifecycle-agent-fbc-4-20"}, + {"name":"redhat-oadp-operator","catalog":"oadp-fbc","fbc_iib_repo":"oadp-1.5__v4.20__oadp-rhel9-operator","art_fbc":true,"ocp_operator_mirror_fbc_image_base":"quay.io/redhat-user-workloads/ocp-art-tenant/art-fbc","nsname":"openshift-adp","channel":"stable-1.5","og_name":"openshift-adp","subscription_name":"redhat-oadp-operator","deploy_default_config":false,"og_spec":{"targetNamespaces":[]}} + ] + documentation: Spoke operators to mirror to the target hub disconnected registry + documentation: |- + Mirror spoke operators to the IBI target hub (kni-qe-128) disconnected registry. + Unlike IBU, only a single version (VERSION) is mirrored — the target spoke installs + fresh at VERSION via IBI ISO, so no pre-upgrade operator set is needed. + Reads cluster identity and inventory from ${SHARED_DIR} written by ibi-target-hub-deploy. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-preinstall/OWNERS b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-preinstall/OWNERS new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-preinstall/telcov10n-functional-cnf-ran-ibi-target-preinstall-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-preinstall/telcov10n-functional-cnf-ran-ibi-target-preinstall-commands.sh new file mode 100644 index 000000000000..62ff32e8533f --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-preinstall/telcov10n-functional-cnf-ran-ibi-target-preinstall-commands.sh @@ -0,0 +1,134 @@ +#!/bin/bash +set +x +set -euo pipefail +umask 077 + +cleanup() { + rm -rf -- "${TEMP_DIR}" +} + +validate_inputs() { + : "${TARGET_CLUSTER_NAME:?TARGET_CLUSTER_NAME is required}" + # Consume the seed version and pinned inputs recorded by earlier steps. + SEED_VERSION=$(<"${SHARED_DIR}/ibi-seed-version") + SEED_DIGEST=$(<"${SHARED_DIR}/ibi-seed-digest") + GIT_REVISION=$(<"${SHARED_DIR}/ibi-seed-git-revision") + + # The playbook validates the full version, registry and generated URLs. + [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+$ ]] + if [[ "${SEED_VERSION}" != "${VERSION}."* ]]; then + echo "Recorded seed version must belong to the ${VERSION} release family." >&2 + return 1 + fi + [[ "$SEED_DIGEST" =~ ^sha256:[a-f0-9]{64}$ ]] + [[ "$GIT_REVISION" =~ ^[a-f0-9]{40}$ ]] + SEED_IMAGE="${MIRROR_REGISTRY}/ibu/seed@${SEED_DIGEST}" + TARGET_SPOKE_NAME=$(printf '%s' "${TARGET_SPOKE_CLUSTER}" | tr -d "[]'\" ") + [[ "${TARGET_SPOKE_NAME}" =~ ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ]] +} + +restore_target_inventory() { + local name + INVENTORY_PATH=/eco-ci-cd/inventories/ocp-deployment + mkdir -p "${INVENTORY_PATH}/group_vars" "${INVENTORY_PATH}/host_vars" + for name in all bastions; do + cp "${SHARED_DIR}/target-${name}" "${INVENTORY_PATH}/group_vars/${name}" + done + cp "${SHARED_DIR}/target-bastion" "${INVENTORY_PATH}/host_vars/bastion" +} + +create_work_directories() { + TEMP_DIR=$(mktemp -d /tmp/ibi-preinstall.XXXXXX) + trap cleanup EXIT + WORK_DIR="/tmp/eco_gotests_ibi_preinstall/${TEMP_DIR##*/}" + REPORT_DIR="${ARTIFACT_DIR}/ibi-preinstall" + mkdir -p "${REPORT_DIR}" + printf '%s\n' "${WORK_DIR}/report" > "${SHARED_DIR}/ibi-rp-preinstall-dir" +} + +configure_ansible() { + install -m 600 /var/group_variables/common/all/ansible_ssh_private_key "${TEMP_DIR}/ssh-key" + export ANSIBLE_PRIVATE_KEY_FILE="${TEMP_DIR}/ssh-key" + export ANSIBLE_HOST_KEY_CHECKING=False + export ANSIBLE_SSH_RETRIES=3 + export ANSIBLE_TIMEOUT=600 + export ANSIBLE_REMOTE_TEMP=/tmp + + # Match hub deployment: read connection fields from the generated inventory. + if ! BASTION_IP=$(grep -oP '(?<=ansible_host: ).*' "${INVENTORY_PATH}/host_vars/bastion" | sed "s/'//g") || + ! BASTION_USER=$(grep -oP '(?<=ansible_user: ).*' "${INVENTORY_PATH}/group_vars/all" | sed "s/'//g"); then + echo "Could not read target bastion address and user from inventory." >&2 + return 1 + fi + if [[ ! "${BASTION_IP} ${BASTION_USER}" =~ ^[^[:space:]]+[[:blank:]][^[:space:]]+$ ]]; then + echo "Target bastion inventory must provide one address and one user." >&2 + return 1 + fi +} + +redact_bastion() { + local line + while IFS= read -r line || [[ -n "${line}" ]]; do + line="${line//${BASTION_USER}@${BASTION_IP}/}" + line="${line//${BASTION_IP}/}" + printf '%s\n' "${line}" + done +} + +prepare_launcher() { + local site_config_url="${ZTP_GIT_REPO%.git}/-/raw/${GIT_REVISION}/${VERSION}/${TARGET_SPOKE_NAME}/clusterinstance" + cd /eco-ci-cd + ansible-playbook ./playbooks/ran/ibi-preinstall-stage.yml \ + -i "${INVENTORY_PATH}/build-inventory.py" \ + --limit bastion \ + --extra-vars ibi_preinstall_phase=prepare \ + --extra-vars "ibi_hub_kubeconfig=/home/telcov10n/project/generated/${TARGET_CLUSTER_NAME}/auth/kubeconfig" \ + --extra-vars "ibi_seed_image=${SEED_IMAGE}" \ + --extra-vars "ibi_seed_version=${SEED_VERSION}" \ + --extra-vars "ibi_preinstall_registry=${MIRROR_REGISTRY}" \ + --extra-vars "ibi_site_config_url=${site_config_url}" \ + --extra-vars "ibi_work_dir=${WORK_DIR}" \ + --extra-vars '{"ibi_skip_tls_verify":true}' \ + 2>&1 | redact_bastion | tee "${REPORT_DIR}/setup.log" +} + +run_preinstall() { + local playbook_rc=0 console_rc=0 test_rc + local console_log="${REPORT_DIR}/report/console.log" + ansible-playbook ./playbooks/ran/ibi-preinstall-stage.yml \ + -i "${INVENTORY_PATH}/build-inventory.py" --limit bastion \ + --extra-vars ibi_preinstall_phase=run \ + --extra-vars "ibi_work_dir=${WORK_DIR} ibi_report_dir=${REPORT_DIR}" \ + 2>&1 | redact_bastion | tee "${REPORT_DIR}/execution.log" || playbook_rc=$? + + # The playbook collects artifacts even on failure; retain the full console in Prow. + if [[ ! -f "$console_log" ]]; then console_log="${REPORT_DIR}/runner.log"; fi + if [[ -f "$console_log" ]]; then + redact_bastion < "$console_log" || console_rc=$? + fi + test -s "${REPORT_DIR}/execution-exit-code" || return 1 + test_rc=$(<"${REPORT_DIR}/execution-exit-code") + [[ "$test_rc" =~ ^[0-9]+$ && "$test_rc" -le 255 ]] || return 1 + if (( test_rc != 0 )); then return "$test_rc"; fi + if (( playbook_rc != 0 )); then return "$playbook_rc"; fi + return "$console_rc" +} + +main() { + if [[ -f "${SHARED_DIR}/skip.txt" ]]; then + echo "Skipping IBI target preinstall." + return 0 + fi + + cd /eco-ci-cd + validate_inputs + restore_target_inventory + create_work_directories + configure_ansible + prepare_launcher + run_preinstall + + echo "IBI preinstall execution and report collection completed." +} + +main "$@" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-preinstall/telcov10n-functional-cnf-ran-ibi-target-preinstall-ref.metadata.json b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-preinstall/telcov10n-functional-cnf-ran-ibi-target-preinstall-ref.metadata.json new file mode 100644 index 000000000000..022d0eb44e7e --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-preinstall/telcov10n-functional-cnf-ran-ibi-target-preinstall-ref.metadata.json @@ -0,0 +1,4 @@ +{ + "path": "telcov10n/functional/cnf-ran/ibi-target-preinstall/telcov10n-functional-cnf-ran-ibi-target-preinstall-ref.yaml", + "owners": {} +} \ No newline at end of file diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-preinstall/telcov10n-functional-cnf-ran-ibi-target-preinstall-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-preinstall/telcov10n-functional-cnf-ran-ibi-target-preinstall-ref.yaml new file mode 100644 index 000000000000..484175cdec18 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-target-preinstall/telcov10n-functional-cnf-ran-ibi-target-preinstall-ref.yaml @@ -0,0 +1,44 @@ +ref: + as: telcov10n-functional-cnf-ran-ibi-target-preinstall + from_image: + namespace: telcov10n-ci + name: eco-ci-cd + tag: eco-ci-cd + commands: telcov10n-functional-cnf-ran-ibi-target-preinstall-commands.sh + timeout: 4h + grace_period: 5m + resources: + requests: + cpu: 100m + memory: 200Mi + env: + - name: TARGET_CLUSTER_NAME + default: "" + documentation: Target hub name used to locate its kubeconfig on the target bastion. + - name: VERSION + default: "4.20" + documentation: Release family used for Git paths and the seed image tag. + - name: MIRROR_REGISTRY + default: "disconnected.registry.local:5000" + documentation: Target registry containing the mirrored seed image. + - name: TARGET_SPOKE_CLUSTER + default: "['ibi-target']" + documentation: Single target spoke name in the existing list format. + - name: ZTP_GIT_REPO + default: "https://gitlab.cee.redhat.com/telcov10n/ztp-site-configs-ci.git" + documentation: GitLab repository containing the target ClusterInstance and preinstall template. + credentials: + - namespace: test-credentials + name: telcov10n-ansible-group-all + mount_path: /var/group_variables/common/all + documentation: |- + Restore target inventory and use ibi-preinstall-stage.yml with phase + prepare to check the installer and prepare the launcher. Select phase run + to execute it and collect console output and reports, including on test failure. + Preserve the launcher exit code and retained Report Portal paths. + Requires a mirrored seed image, installer, HTTP service, matching SSH key, + target-* inventory files from target hub preparation, and ibi-seed-version + written by seed preparation from the running seed cluster. The mirror step + supplies the pinned seed digest and Git commit used for preinstall inputs. + The installer must match that full version before setup. Console output + is printed after collection; Ansible reports progress while the test runs. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-workflow/OWNERS b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-workflow/OWNERS new file mode 120000 index 000000000000..ec405d65a79d --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-workflow/OWNERS @@ -0,0 +1 @@ +../OWNERS \ No newline at end of file diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi/telcov10n-functional-cnf-ran-ibi-workflow.metadata.json b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-workflow/telcov10n-functional-cnf-ran-ibi-workflow-workflow.metadata.json similarity index 61% rename from ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi/telcov10n-functional-cnf-ran-ibi-workflow.metadata.json rename to ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-workflow/telcov10n-functional-cnf-ran-ibi-workflow-workflow.metadata.json index f220589304b4..880c3176e45b 100644 --- a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi/telcov10n-functional-cnf-ran-ibi-workflow.metadata.json +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-workflow/telcov10n-functional-cnf-ran-ibi-workflow-workflow.metadata.json @@ -1,5 +1,5 @@ { - "path": "telcov10n/functional/cnf-ran/ibi/telcov10n-functional-cnf-ran-ibi-workflow.yaml", + "path": "telcov10n/functional/cnf-ran/ibi-workflow/telcov10n-functional-cnf-ran-ibi-workflow-workflow.yaml", "owners": { "approvers": [ "ccardenosa", diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-workflow/telcov10n-functional-cnf-ran-ibi-workflow-workflow.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-workflow/telcov10n-functional-cnf-ran-ibi-workflow-workflow.yaml new file mode 100644 index 000000000000..6cce609d94c6 --- /dev/null +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi-workflow/telcov10n-functional-cnf-ran-ibi-workflow-workflow.yaml @@ -0,0 +1,30 @@ +workflow: + as: telcov10n-functional-cnf-ran-ibi-workflow + documentation: |- + Deploy the seed and target hubs, mirror the target OpenShift release, + prepare the seed SNO, and generate and mirror the seed image. + + steps: + pre: + - ref: telcov10n-functional-cnf-ran-hub-deploy + - ref: telcov10n-functional-cnf-ran-hub-config + - ref: telcov10n-functional-cnf-ran-mirror-spoke-operators + - ref: telcov10n-functional-cnf-ran-ibi-target-hub-deploy + - ref: telcov10n-functional-cnf-ran-ibi-target-hub-config + - ref: telcov10n-functional-cnf-ran-ibi-target-mirror-spoke-operators + - ref: telcov10n-functional-cnf-ran-ibi-hub-prepare + - ref: telcov10n-functional-cnf-ran-ibu-target-mirror-ocp + - ref: telcov10n-functional-cnf-ran-ibu-restore-seed-inventory + - ref: telcov10n-functional-cnf-ran-ibu-deploy-spoke-sno-seed + - ref: telcov10n-functional-cnf-ran-ibi-seed-prepare + - ref: telcov10n-functional-cnf-ran-ibu-prune-argocd-apps + - ref: telcov10n-functional-cnf-ran-ibi-eco-gotests-seed + - ref: telcov10n-functional-cnf-ran-ibu-mirror-seed-image + - ref: telcov10n-functional-cnf-ran-ibi-target-preinstall + - ref: telcov10n-functional-cnf-ran-ibu-target-deploy-spoke-sno + test: + - ref: telcov10n-functional-cnf-ran-ibi-deploymenttypes + - ref: telcov10n-functional-cnf-ran-ibi-replacement-preinstall + - ref: telcov10n-functional-cnf-ran-ibi-ibbf + - ref: telcov10n-functional-cnf-ran-ibi-report + - ref: telcov10n-verify-junit-reports-bastion diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi/telcov10n-functional-cnf-ran-ibi-workflow.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi/telcov10n-functional-cnf-ran-ibi-workflow.yaml deleted file mode 100644 index 611e1471b6f6..000000000000 --- a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibi/telcov10n-functional-cnf-ran-ibi-workflow.yaml +++ /dev/null @@ -1,20 +0,0 @@ -workflow: - as: telcov10n-functional-cnf-ran-ibi - documentation: |- - IBI (Image Based Installation) workflow for CNF RAN testing. - Pre: deploy seed hub (kni-qe-127) at VERSION, install operators, - mirror spoke operators to seed bastion's disconnected registry, - then deploy seed SNO spoke (helix81) via ZTP. - Target hub (kni-qe-128) and IBI installation steps TBD. - Test: TBD - seedgeneration, IBI install, deploymenttypes, IBBF/IBR, ZTP IBI tests. - Post: TBD - report results, Slack notification. - steps: - pre: - # Seed hub setup — kni-qe-127 deployed at VERSION - - ref: telcov10n-functional-cnf-ran-hub-deploy - - ref: telcov10n-functional-cnf-ran-hub-config - - ref: telcov10n-functional-cnf-ran-mirror-spoke-operators - - post: - - ref: wait - diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-deploy-spoke-sno-seed/telcov10n-functional-cnf-ran-ibu-deploy-spoke-sno-seed-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-deploy-spoke-sno-seed/telcov10n-functional-cnf-ran-ibu-deploy-spoke-sno-seed-commands.sh index 5eec43236b15..c3c9e9d864ee 100644 --- a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-deploy-spoke-sno-seed/telcov10n-functional-cnf-ran-ibu-deploy-spoke-sno-seed-commands.sh +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-deploy-spoke-sno-seed/telcov10n-functional-cnf-ran-ibu-deploy-spoke-sno-seed-commands.sh @@ -32,12 +32,18 @@ KUBECONFIG_PATH="/home/telcov10n/project/generated/${CLUSTER_NAME}/auth/kubeconf cd /eco-ci-cd -ZTP_CLUSTERS_PATH="${VERSION}/ibu-seed/clusterinstance" -ZTP_POLICIES_PATH="${VERSION}/ibu-seed/policygentemplate" +# IBU Git paths use ibu-seed even when the spoke is named after its hardware. +ZTP_SEED_NAME="ibu-seed" +if [[ "$(echo "${SPOKE_CLUSTER}" | tr -d "[]'\" ")" == "ibi-seed" ]]; then + ZTP_SEED_NAME="ibi-seed" +fi + +ZTP_CLUSTERS_PATH="${VERSION}/${ZTP_SEED_NAME}/clusterinstance" +ZTP_POLICIES_PATH="${VERSION}/${ZTP_SEED_NAME}/policygentemplate" # 4.16 predates the siteconfig operator: the clusters dir holds a SiteConfig CR if [[ ${VERSION} == "4.16" ]]; then - ZTP_CLUSTERS_PATH="${VERSION}/ibu-seed/siteconfig" + ZTP_CLUSTERS_PATH="${VERSION}/${ZTP_SEED_NAME}/siteconfig" fi echo "Running IBU seed SNO ZTP deployment for spoke cluster: ${SPOKE_CLUSTER}" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-mirror-seed-image/telcov10n-functional-cnf-ran-ibu-mirror-seed-image-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-mirror-seed-image/telcov10n-functional-cnf-ran-ibu-mirror-seed-image-commands.sh index 6b20950854cd..e1d16af57deb 100644 --- a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-mirror-seed-image/telcov10n-functional-cnf-ran-ibu-mirror-seed-image-commands.sh +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-mirror-seed-image/telcov10n-functional-cnf-ran-ibu-mirror-seed-image-commands.sh @@ -2,22 +2,87 @@ set -e set -o pipefail -if [ -f "${SHARED_DIR}/skip.txt" ]; then - echo "Detected skip.txt — skipping" - exit 0 -fi +restore_seed_inventory() { + mkdir -p /eco-ci-cd/inventories/ocp-deployment/group_vars + mkdir -p /eco-ci-cd/inventories/ocp-deployment/host_vars + cp "${SHARED_DIR}/seed-all" /eco-ci-cd/inventories/ocp-deployment/group_vars/all + cp "${SHARED_DIR}/seed-bastions" /eco-ci-cd/inventories/ocp-deployment/group_vars/bastions + cp "${SHARED_DIR}/seed-bastion" /eco-ci-cd/inventories/ocp-deployment/host_vars/bastion +} -mkdir -p /eco-ci-cd/inventories/ocp-deployment/group_vars -mkdir -p /eco-ci-cd/inventories/ocp-deployment/host_vars +mirror_seed() { + cd /eco-ci-cd + ansible-playbook playbooks/ran/ibu-mirror-seed-image.yml \ + -i ./inventories/ocp-deployment/build-inventory.py \ + --extra-vars "version=${VERSION} target_registry_host=${TARGET_REGISTRY_HOST}" +} -cp "${SHARED_DIR}/seed-all" /eco-ci-cd/inventories/ocp-deployment/group_vars/all -cp "${SHARED_DIR}/seed-bastions" /eco-ci-cd/inventories/ocp-deployment/group_vars/bastions -cp "${SHARED_DIR}/seed-bastion" /eco-ci-cd/inventories/ocp-deployment/host_vars/bastion +finish() { + local rc=$? + trap - EXIT + rm -rf -- "$WORK_DIR" || rc=1 + if (( rc != 0 )); then + rm -f -- "${SHARED_DIR}/ibi-seed-digest" "${SHARED_DIR}/ibi-seed-git-revision" + echo "IBI image transfer/validation failed; target preinstall is blocked." >&2 + fi + exit "$rc" +} -echo "VERSION=${VERSION}" -echo "TARGET_REGISTRY_HOST=${TARGET_REGISTRY_HOST}" +configure_ibi_mirror() { + # Disable tracing before accessing inventory credentials. + set +x + set -u + umask 077 + rm -f -- "${SHARED_DIR}/ibi-seed-digest" "${SHARED_DIR}/ibi-seed-git-revision" -cd /eco-ci-cd -ansible-playbook playbooks/ran/ibu-mirror-seed-image.yml \ - -i ./inventories/ocp-deployment/build-inventory.py \ - --extra-vars "version=${VERSION} target_registry_host=${TARGET_REGISTRY_HOST}" + WORK_DIR=$(mktemp -d /tmp/ibi-seed-mirror.XXXXXX) + trap finish EXIT + + cp /var/group_variables/common/all/ansible_ssh_private_key "$WORK_DIR/ssh-key" + chmod 600 "$WORK_DIR/ssh-key" + export ANSIBLE_PRIVATE_KEY_FILE="$WORK_DIR/ssh-key" + export ANSIBLE_HOST_KEY_CHECKING=False + export ANSIBLE_SSH_RETRIES=3 + export ANSIBLE_TIMEOUT=600 + export ANSIBLE_REMOTE_TEMP=/tmp +} + +mirror_seed_dependencies() { + SEED_VERSION=$(<"${SHARED_DIR}/ibi-seed-version") + TARGET_SPOKE_NAME=$(printf '%s' "$TARGET_SPOKE_CLUSTER" | tr -d "[]'\" ") + + cd /eco-ci-cd + ansible-playbook playbooks/ran/ibi-seed-images.yml \ + -i ./inventories/ocp-deployment/build-inventory.py \ + --extra-vars "ibi_seed_phase=mirror" \ + --extra-vars "version=${VERSION} target_registry_host=${TARGET_REGISTRY_HOST}" \ + --extra-vars "ibi_seed_version=${SEED_VERSION} ibi_mirror_registry=${MIRROR_REGISTRY}" \ + --extra-vars "ibi_seed_hub_kubeconfig=/home/telcov10n/project/generated/${CLUSTER_NAME}/auth/kubeconfig" \ + --extra-vars "ibi_target_hub_kubeconfig=/home/telcov10n/project/generated/${TARGET_CLUSTER_NAME}/auth/kubeconfig" \ + --extra-vars "ibi_ztp_git_repo=${ZTP_GIT_REPO} ibi_ztp_git_branch=${ZTP_GIT_BRANCH}" \ + --extra-vars "ibi_target_spoke=${TARGET_SPOKE_NAME}" \ + --extra-vars "ibi_shared_dir=${SHARED_DIR} ibi_report_dir=${ARTIFACT_DIR}/ibi-seed-mirror" \ + --extra-vars "ibi_seed_inventory=/eco-ci-cd/inventories/ocp-deployment/build-inventory.py" \ + --extra-vars "{\"ibi_target_inventory_files\":[\"${SHARED_DIR}/target-all\",\"${SHARED_DIR}/target-bastions\",\"${SHARED_DIR}/target-bastion\"]}" +} + +main() { + if [ -f "${SHARED_DIR}/skip.txt" ]; then + echo "Detected skip.txt — skipping" + return 0 + fi + + restore_seed_inventory + + # Ordinary IBU jobs retain the existing playbook and behavior. + case "${IBI_MIRROR_SEED_DEPENDENCIES:-false}" in + false) mirror_seed; return 0 ;; + true) ;; + *) echo "IBI_MIRROR_SEED_DEPENDENCIES must be true or false." >&2; return 1 ;; + esac + + configure_ibi_mirror + mirror_seed_dependencies +} + +main "$@" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-mirror-seed-image/telcov10n-functional-cnf-ran-ibu-mirror-seed-image-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-mirror-seed-image/telcov10n-functional-cnf-ran-ibu-mirror-seed-image-ref.yaml index 914324a3ccc9..f1098d51edfa 100644 --- a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-mirror-seed-image/telcov10n-functional-cnf-ran-ibu-mirror-seed-image-ref.yaml +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-mirror-seed-image/telcov10n-functional-cnf-ran-ibu-mirror-seed-image-ref.yaml @@ -8,7 +8,13 @@ ref: documentation: |- Mirror the IBU seed image from the seed bastion's local registry to the target bastion's disconnected registry, making it available for eco-gotests IBU upgrade. + With IBI_MIRROR_SEED_DEPENDENCIES enabled, also copy the seed inventory and + captured catalog manifests, verify target manifests and Linux/amd64 blobs, + and publish the verified seed digest for both IBI preinstall stages. + IBI uses ibi-seed-images.yml (mirror phase) to orchestrate this work and invoke + the unchanged IBU seed-copy playbook. Full validation runs on the target bastion. timeout: 60m + grace_period: 5m resources: requests: cpu: 100m @@ -20,3 +26,28 @@ ref: - name: TARGET_REGISTRY_HOST default: "10.6.184.4" documentation: IP or hostname of the target bastion's disconnected registry + - name: IBI_MIRROR_SEED_DEPENDENCIES + default: "false" + documentation: Enable blocking IBI dependency transfer and target pull verification. + - name: CLUSTER_NAME + default: "kni-qe-127" + documentation: Seed hub used to read local registry credentials for IBI. + - name: TARGET_CLUSTER_NAME + default: "" + documentation: Target hub used to read local registry credentials and mirror mappings for IBI. + - name: MIRROR_REGISTRY + default: "disconnected.registry.local:5000" + documentation: Logical registry hostname and port used on both IBI bastions. + - name: TARGET_SPOKE_CLUSTER + default: "['ibi-target']" + documentation: Target spoke used to locate its preinstall image mirror configuration. + - name: ZTP_GIT_REPO + default: "https://gitlab.cee.redhat.com/telcov10n/ztp-site-configs-ci.git" + documentation: GitLab repository containing the IBI preinstall template. + - name: ZTP_GIT_BRANCH + default: "main" + documentation: Branch resolved once and shared with IBI preinstall consumers. + credentials: + - namespace: test-credentials + name: telcov10n-ansible-group-all + mount_path: /var/group_variables/common/all diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-prune-argocd-apps/telcov10n-functional-cnf-ran-ibu-prune-argocd-apps-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-prune-argocd-apps/telcov10n-functional-cnf-ran-ibu-prune-argocd-apps-ref.yaml index a47842640971..973088f5a22c 100644 --- a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-prune-argocd-apps/telcov10n-functional-cnf-ran-ibu-prune-argocd-apps-ref.yaml +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-prune-argocd-apps/telcov10n-functional-cnf-ran-ibu-prune-argocd-apps-ref.yaml @@ -31,7 +31,11 @@ ref: - namespace: test-credentials name: telcov10n-ansible-kni-qe-133-bastion mount_path: /var/host_variables/kni-qe-133/bastion + # kni-qe-127 (IBI seed hub) + - namespace: test-credentials + name: telcov10n-ansible-kni-qe-127-bastion + mount_path: /var/host_variables/kni-qe-127/bastion documentation: |- Patch ArgoCD apps (clusters, policies) to remove finalizers, delete them, and remove the spoke ManagedCluster from the hub selected by CLUSTER_NAME. - Runs against the hub bastion using directly mounted credentials for kni-qe-108 or kni-qe-133. + Runs against the hub bastion using directly mounted credentials for kni-qe-108, kni-qe-127, or kni-qe-133. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-target-deploy-spoke-sno/telcov10n-functional-cnf-ran-ibu-target-deploy-spoke-sno-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-target-deploy-spoke-sno/telcov10n-functional-cnf-ran-ibu-target-deploy-spoke-sno-commands.sh index 697016aa2b9d..3fb745f807b6 100644 --- a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-target-deploy-spoke-sno/telcov10n-functional-cnf-ran-ibu-target-deploy-spoke-sno-commands.sh +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-target-deploy-spoke-sno/telcov10n-functional-cnf-ran-ibu-target-deploy-spoke-sno-commands.sh @@ -1,4 +1,5 @@ #!/bin/bash +set +x set -e set -o pipefail @@ -33,12 +34,18 @@ KUBECONFIG_PATH="/home/telcov10n/project/generated/${TARGET_CLUSTER_NAME}/auth/k cd /eco-ci-cd -ZTP_CLUSTERS_PATH="${VERSION}/ibu-target/clusterinstance" -ZTP_POLICIES_PATH="${VERSION}/ibu-target/policygentemplate" +# IBU Git paths use ibu-target even when the spoke is named after its hardware. +ZTP_TARGET_NAME="ibu-target" +if [[ "$(echo "${TARGET_SPOKE_CLUSTER}" | tr -d "[]'\" ")" == "ibi-target" ]]; then + ZTP_TARGET_NAME="ibi-target" +fi + +ZTP_CLUSTERS_PATH="${VERSION}/${ZTP_TARGET_NAME}/clusterinstance" +ZTP_POLICIES_PATH="${VERSION}/${ZTP_TARGET_NAME}/policygentemplate" # 4.16 predates the siteconfig operator: the clusters dir holds a SiteConfig CR if [[ ${VERSION} == "4.16" ]]; then - ZTP_CLUSTERS_PATH="${VERSION}/ibu-target/siteconfig" + ZTP_CLUSTERS_PATH="${VERSION}/${ZTP_TARGET_NAME}/siteconfig" fi echo "Running ZTP deployment for target SNO spoke cluster: ${TARGET_SPOKE_CLUSTER}" diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-target-hub-deploy/telcov10n-functional-cnf-ran-ibu-target-hub-deploy-ref.yaml b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-target-hub-deploy/telcov10n-functional-cnf-ran-ibu-target-hub-deploy-ref.yaml index 6d90896e38ca..279ddde8a7b9 100644 --- a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-target-hub-deploy/telcov10n-functional-cnf-ran-ibu-target-hub-deploy-ref.yaml +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-target-hub-deploy/telcov10n-functional-cnf-ran-ibu-target-hub-deploy-ref.yaml @@ -46,6 +46,22 @@ ref: - namespace: test-credentials name: telcov10n-ansible-hypervisors-helix89 mount_path: /var/host_variables/kni-qe-109/hypervisor + # kni-qe-128 (IBI target hub) + - namespace: test-credentials + name: telcov10n-ansible-hub-kni-qe-128 + mount_path: /var/host_variables/kni-qe-128/master0 + - namespace: test-credentials + name: telcov10n-ansible-kni-qe-128-bastion + mount_path: /var/host_variables/kni-qe-128/bastion + - namespace: test-credentials + name: telcov10n-ansible-group-hub-kni-qe-128-nodes + mount_path: /var/group_variables/kni-qe-128/nodes + - namespace: test-credentials + name: telcov10n-ansible-group-hub-kni-qe-128-masters + mount_path: /var/group_variables/kni-qe-128/masters + - namespace: test-credentials + name: telcov10n-ansible-hypervisors-helix118 + mount_path: /var/host_variables/kni-qe-128/hypervisor documentation: |- - Deploy IBU target hub (kni-qe-109). - The target hub manages the spoke clusters that will be upgraded via IBU. + Deploy IBU/IBI target hub (kni-qe-109 or kni-qe-128). + The target hub manages the spoke clusters that will be upgraded/installed via IBU/IBI. diff --git a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-target-mirror-ocp/telcov10n-functional-cnf-ran-ibu-target-mirror-ocp-commands.sh b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-target-mirror-ocp/telcov10n-functional-cnf-ran-ibu-target-mirror-ocp-commands.sh index d4075bcbe27b..2fc02472c166 100644 --- a/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-target-mirror-ocp/telcov10n-functional-cnf-ran-ibu-target-mirror-ocp-commands.sh +++ b/ci-operator/step-registry/telcov10n/functional/cnf-ran/ibu-target-mirror-ocp/telcov10n-functional-cnf-ran-ibu-target-mirror-ocp-commands.sh @@ -1,4 +1,5 @@ #!/bin/bash +set +x set -e set -o pipefail diff --git a/ci-operator/step-registry/telcov10n/verify-junit-reports-bastion/telcov10n-verify-junit-reports-bastion-commands.sh b/ci-operator/step-registry/telcov10n/verify-junit-reports-bastion/telcov10n-verify-junit-reports-bastion-commands.sh index bce73c3274b5..278af36f0cf0 100644 --- a/ci-operator/step-registry/telcov10n/verify-junit-reports-bastion/telcov10n-verify-junit-reports-bastion-commands.sh +++ b/ci-operator/step-registry/telcov10n/verify-junit-reports-bastion/telcov10n-verify-junit-reports-bastion-commands.sh @@ -1,4 +1,7 @@ #!/bin/bash +# Disable tracing because this step handles the bastion SSH key. +set +x +umask 077 set -e set -o pipefail @@ -10,6 +13,48 @@ fi echo "Failed" >> "${SHARED_DIR}/job_status.txt" +# Keep execution/collection failures even when the available XML reports pass. +result=0 +read -r -a required_results <<< "${JUNIT_REQUIRED_RESULT_FILES:-}" +for name in "${required_results[@]}"; do + if [[ ! "${name}" =~ ^[A-Za-z0-9][A-Za-z0-9_.-]*$ ]]; then + echo "Invalid required result filename." >&2 + result=1 + continue + fi + result_file="${SHARED_DIR}/${name}" + if [[ ! -r "${result_file}" ]]; then + echo "Missing required result: ${name}." >&2 + result=1 + continue + fi + status=$(<"${result_file}") + if [[ ! "${status}" =~ ^(0|[1-9][0-9]{0,2})$ ]] || (( status > 255 )); then + echo "Invalid exit code in ${name}." >&2 + result=1 + elif (( status != 0 )); then + echo "${name} recorded exit code ${status}; the job will fail." >&2 + result=1 + fi +done + +if [[ -n "${JUNIT_REPORT_DIR_FILE:-}" ]]; then + if [[ ! "${JUNIT_REPORT_DIR_FILE}" =~ ^[A-Za-z0-9][A-Za-z0-9_.-]*$ ]]; then + echo "Invalid report-directory filename." >&2 + exit 1 + fi + report_dir_file="${SHARED_DIR}/${JUNIT_REPORT_DIR_FILE}" + if [[ ! -r "${report_dir_file}" ]]; then + echo "Missing current-run report directory file." >&2 + exit 1 + fi + JUNIT_REPORT_DIR=$(<"${report_dir_file}") + if [[ "${JUNIT_REPORT_DIR}" != /* || "${JUNIT_REPORT_DIR}" == *$'\n'* ]]; then + echo "The current-run report directory must be one absolute path." >&2 + exit 1 + fi +fi + PROJECT_DIR="/tmp" echo "Set bastion SSH configuration" @@ -17,16 +62,38 @@ cat /var/group_variables/common/all/ansible_ssh_private_key > "${PROJECT_DIR}/te chmod 600 "${PROJECT_DIR}/temp_ssh_key" trap 'rm -f "${PROJECT_DIR}/temp_ssh_key"' EXIT -BASTION_HOST_FILE="/var/host_variables/${CLUSTER_NAME}/bastion/ansible_host" -if [[ -r "${BASTION_HOST_FILE}" ]]; then - BASTION_IP=$(tr -d '[:space:]' < "${BASTION_HOST_FILE}") +if [[ -n "${JUNIT_INVENTORY_PREFIX:-}" ]]; then + if [[ ! "${JUNIT_INVENTORY_PREFIX}" =~ ^[A-Za-z0-9_-]+$ ]]; then + echo "Invalid shared inventory prefix." >&2 + exit 1 + fi + BASTION_IP=$(grep -oP '(?<=ansible_host: ).*' \ + "${SHARED_DIR}/${JUNIT_INVENTORY_PREFIX}bastion" | sed "s/'//g") + BASTION_USER=$(grep -oP '(?<=ansible_user: ).*' \ + "${SHARED_DIR}/${JUNIT_INVENTORY_PREFIX}all" | sed "s/'//g") else - BASTION_IP=$(python3 -c 'import sys, yaml; print(yaml.safe_load(sys.stdin)["ansible_host"])' < "${SHARED_DIR}/bastion") + BASTION_HOST_FILE="/var/host_variables/${CLUSTER_NAME}/bastion/ansible_host" + if [[ -r "${BASTION_HOST_FILE}" ]]; then + BASTION_IP=$(tr -d '[:space:]' < "${BASTION_HOST_FILE}") + else + BASTION_IP=$(python3 -c 'import sys, yaml; print(yaml.safe_load(sys.stdin)["ansible_host"])' < "${SHARED_DIR}/bastion") + fi + BASTION_USER=$(tr -d '[:space:]' < /var/group_variables/common/all/ansible_user) fi -BASTION_USER=$(tr -d '[:space:]' < /var/group_variables/common/all/ansible_user) +[[ -n "${BASTION_IP}" && -n "${BASTION_USER}" ]] + +redact_bastion() { + local line + while IFS= read -r line || [[ -n "${line}" ]]; do + line="${line//${BASTION_USER}@${BASTION_IP}/}" + line="${line//${BASTION_IP}/}" + printf '%s\n' "${line}" + done +} REPORT_DIR="${JUNIT_REPORT_DIR}" -if [[ -s "${SHARED_DIR}/bastion_junit_report_dir" ]]; then +# An explicitly selected current-run report file takes precedence over the generic handoff. +if [[ -z "${JUNIT_REPORT_DIR_FILE:-}" && -s "${SHARED_DIR}/bastion_junit_report_dir" ]]; then REPORT_DIR=$(cat "${SHARED_DIR}/bastion_junit_report_dir") fi @@ -35,16 +102,28 @@ SSH_OPTS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "${PROJ echo "Copy fail_if_any_test_failed.py to bastion" scp "${SSH_OPTS[@]}" \ /eco-ci-cd/scripts/fail_if_any_test_failed.py \ - "${BASTION_USER}@${BASTION_IP}:/tmp/fail_if_any_test_failed.py" + "${BASTION_USER}@${BASTION_IP}:/tmp/fail_if_any_test_failed.py" \ + 2>&1 | redact_bastion echo "Run JUnit verification on bastion against ${REPORT_DIR}" +# Quote values for the remote Bash command, including JSON with apostrophes. printf -v verifier_args ' %q' "${REPORT_DIR}" "${KNOWN_FAILURES:-[]}" -ssh "${SSH_OPTS[@]}" "${BASTION_USER}@${BASTION_IP}" "bash -s --${verifier_args}" <<'EOF' +set +e +ssh "${SSH_OPTS[@]}" "${BASTION_USER}@${BASTION_IP}" "bash -s --${verifier_args}" <<'EOF' 2>&1 | redact_bastion set -e python3 -m venv --clear /tmp/verify-junit-venv /tmp/verify-junit-venv/bin/pip install --quiet junitparser - SHARED_DIR="$1" KNOWN_FAILURES="$2" \ + TESTS_DIR="$1" SHARED_DIR="$1" KNOWN_FAILURES="$2" \ /tmp/verify-junit-venv/bin/python3 /tmp/fail_if_any_test_failed.py EOF +verify_rc=$? +set -e +if (( verify_rc != 0 )); then + result=1 +fi +if (( result != 0 )); then + echo "JUnit verification or a required execution result failed." >&2 + exit 1 +fi echo "Passed" > "${SHARED_DIR}/job_status.txt" diff --git a/ci-operator/step-registry/telcov10n/verify-junit-reports-bastion/telcov10n-verify-junit-reports-bastion-ref.yaml b/ci-operator/step-registry/telcov10n/verify-junit-reports-bastion/telcov10n-verify-junit-reports-bastion-ref.yaml index fa5a8db0238f..1bc9115f3867 100644 --- a/ci-operator/step-registry/telcov10n/verify-junit-reports-bastion/telcov10n-verify-junit-reports-bastion-ref.yaml +++ b/ci-operator/step-registry/telcov10n/verify-junit-reports-bastion/telcov10n-verify-junit-reports-bastion-ref.yaml @@ -8,8 +8,10 @@ ref: documentation: |- Verify JUnit reports on the bastion host instead of the CI pod to avoid the 1 MB Kubernetes secret size limit of SHARED_DIR. - Runs fail_if_any_test_failed.py on the bastion against the directory in - SHARED_DIR/bastion_junit_report_dir when present, otherwise JUNIT_REPORT_DIR. + Runs fail_if_any_test_failed.py on the bastion against the directory selected + by JUNIT_REPORT_DIR_FILE, otherwise SHARED_DIR/bastion_junit_report_dir when + present, otherwise JUNIT_REPORT_DIR. Optionally use prefixed shared inventory. + Required execution results also fail the job, even when XML reports pass. grace_period: 10s timeout: 30m0s resources: @@ -23,6 +25,25 @@ ref: - name: JUNIT_REPORT_DIR default: "/tmp/test_reports/junit" documentation: Directory on the bastion containing JUnit XML reports to verify + - name: JUNIT_INVENTORY_PREFIX + default: "" + documentation: |- + Optional shared inventory prefix, for example target-. Reads bastion + and all from SHARED_DIR. Empty uses the mounted CLUSTER_NAME inventory + with SHARED_DIR/bastion as a fallback for the host address. + - name: JUNIT_REPORT_DIR_FILE + default: "" + documentation: |- + Optional filename under SHARED_DIR containing the current run's absolute + report directory on the bastion. Takes precedence over bastion_junit_report_dir + and JUNIT_REPORT_DIR; missing or invalid files fail verification instead of + falling back to another run. + - name: JUNIT_REQUIRED_RESULT_FILES + default: "" + documentation: |- + Optional space-separated filenames under SHARED_DIR containing step exit + codes. Missing, invalid, or nonzero results fail the final job. XML reports + are still verified when the bastion and report directory are available. - name: KNOWN_FAILURES default: "[]" documentation: |-