From c4bcf5b0a0d2ecb68f86a3df8b80f6ed98ace0e1 Mon Sep 17 00:00:00 2001 From: Mohammed Boukhalfa Date: Mon, 14 Oct 2024 19:04:49 +0300 Subject: [PATCH] Add option to skip apply BMHs Signed-off-by: Mohammed Boukhalfa --- 03_launch_mgmt_cluster.sh | 10 +++++- 04_verify.sh | 73 +++++++++++++++++++++------------------ config_example.sh | 3 ++ vars.md | 1 + 4 files changed, 53 insertions(+), 34 deletions(-) diff --git a/03_launch_mgmt_cluster.sh b/03_launch_mgmt_cluster.sh index 969b8120f..80c8ad833 100755 --- a/03_launch_mgmt_cluster.sh +++ b/03_launch_mgmt_cluster.sh @@ -538,7 +538,15 @@ if [ "${EPHEMERAL_CLUSTER}" != "tilt" ]; then # Thus we are deleting validatingwebhookconfiguration resource if exists to let BMO is working properly on local runs. kubectl delete validatingwebhookconfiguration/"${BMO_NAME_PREFIX}"-validating-webhook-configuration --ignore-not-found=true fi - apply_bm_hosts "$NAMESPACE" + # Tests might want to apply bmh inside the test scipt + # then dev-env will create the bmh files but do not apply tehm + if [[ "${SKIP_APPLY_BMH:-false}" == "true" ]]; then + pushd "${BMOPATH}" + list_nodes | make_bm_hosts + popd + else + apply_bm_hosts "$NAMESPACE" + fi elif [ "${EPHEMERAL_CLUSTER}" == "tilt" ]; then source tilt-setup/deploy_tilt_env.sh diff --git a/04_verify.sh b/04_verify.sh index b891c9f40..b41ee21aa 100755 --- a/04_verify.sh +++ b/04_verify.sh @@ -32,43 +32,47 @@ check_bm_hosts() { -n metal3 -o json)" BARE_METAL_VMS="$(sudo virsh list --all)" BARE_METAL_VMNAME="${NAME//-/_}" - # Verify BM host exists - RESULT_STR="${NAME} Baremetalhost exist" - echo "${BARE_METAL_HOSTS}" | grep -w "${NAME}" > /dev/null - process_status $? - BARE_METAL_HOST="$(echo "${BARE_METAL_HOSTS}" | \ - jq ' .items[] | select(.metadata.name=="'"${NAME}"'" )')" + # Skip BMH verification if not applied + if [[ "${SKIP_APPLY_BMH:-false}" != "true" ]]; then + # Verify BM host exists + RESULT_STR="${NAME} Baremetalhost exist" + echo "${BARE_METAL_HOSTS}" | grep -w "${NAME}" > /dev/null + process_status $? - # Verify addresses of the host - RESULT_STR="${NAME} Baremetalhost address correct" - equals "$(echo "${BARE_METAL_HOST}" | jq -r '.spec.bmc.address')" "${ADDRESS}" + BARE_METAL_HOST="$(echo "${BARE_METAL_HOSTS}" | \ + jq ' .items[] | select(.metadata.name=="'"${NAME}"'" )')" - RESULT_STR="${NAME} Baremetalhost mac address correct" - equals "$(echo "${BARE_METAL_HOST}" | jq -r '.spec.bootMACAddress')" \ - "${MAC}" + # Verify addresses of the host + RESULT_STR="${NAME} Baremetalhost address correct" + equals "$(echo "${BARE_METAL_HOST}" | jq -r '.spec.bmc.address')" "${ADDRESS}" - # Verify BM host status - RESULT_STR="${NAME} Baremetalhost status OK" - equals "$(echo "${BARE_METAL_HOST}" | jq -r '.status.operationalStatus')" \ - "OK" + RESULT_STR="${NAME} Baremetalhost mac address correct" + equals "$(echo "${BARE_METAL_HOST}" | jq -r '.spec.bootMACAddress')" \ + "${MAC}" - # Verify credentials exist - RESULT_STR="${NAME} Baremetalhost credentials secret exist" - CRED_NAME="$(echo "${BARE_METAL_HOST}" | jq -r '.spec.bmc.credentialsName')" - CRED_SECRET="$(kubectl get secret "${CRED_NAME}" -n metal3 -o json | \ - jq '.data')" - process_status $? + # Verify BM host status + RESULT_STR="${NAME} Baremetalhost status OK" + equals "$(echo "${BARE_METAL_HOST}" | jq -r '.status.operationalStatus')" \ + "OK" - # Verify credentials correct - RESULT_STR="${NAME} Baremetalhost password correct" - equals "$(echo "${CRED_SECRET}" | jq -r '.password' | \ - base64 --decode)" "${PASSWORD}" + # Verify credentials exist + RESULT_STR="${NAME} Baremetalhost credentials secret exist" + CRED_NAME="$(echo "${BARE_METAL_HOST}" | jq -r '.spec.bmc.credentialsName')" + CRED_SECRET="$(kubectl get secret "${CRED_NAME}" -n metal3 -o json | \ + jq '.data')" + process_status $? - RESULT_STR="${NAME} Baremetalhost user correct" - equals "$(echo "${CRED_SECRET}" | jq -r '.username' | \ - base64 --decode)" "${USER}" + # Verify credentials correct + RESULT_STR="${NAME} Baremetalhost password correct" + equals "$(echo "${CRED_SECRET}" | jq -r '.password' | \ + base64 --decode)" "${PASSWORD}" + RESULT_STR="${NAME} Baremetalhost user correct" + equals "$(echo "${CRED_SECRET}" | jq -r '.username' | \ + base64 --decode)" "${USER}" + fi + # Verify the VM was created RESULT_STR="${NAME} Baremetalhost VM exist" echo "${BARE_METAL_VMS} "| grep -w "${BARE_METAL_VMNAME}" > /dev/null @@ -82,10 +86,13 @@ check_bm_hosts() { process_status $? done - #Verify the introspection completed successfully - RESULT_STR="${NAME} Baremetalhost introspecting completed" - is_in "$(echo "${BARE_METAL_HOST}" | jq -r '.status.provisioning.state')" \ - "ready available" + # Skip introspection verification in no BMH applied + if [[ "${SKIP_APPLY_BMH:-false}" != "true" ]]; then + #Verify the introspection completed successfully + RESULT_STR="${NAME} Baremetalhost introspecting completed" + is_in "$(echo "${BARE_METAL_HOST}" | jq -r '.status.provisioning.state')" \ + "ready available" + fi echo "" diff --git a/config_example.sh b/config_example.sh index 44c8d2636..0d3ff36a9 100644 --- a/config_example.sh +++ b/config_example.sh @@ -206,3 +206,6 @@ # Uncomment the line below to build ironic-image from source # export IRONIC_FROM_SOURCE="true" + +# Skip applying BMHs +# export SKIP_APPLY_BMH="true" diff --git a/vars.md b/vars.md index f0f025a39..0bdcd9bca 100644 --- a/vars.md +++ b/vars.md @@ -27,6 +27,7 @@ assured that they are persisted. | BMO_RUN_LOCAL | Run a local baremetal operator instead of deploying in Kubernetes | "true", "false" | "false" | | CAPM3_RUN_LOCAL | Run a local CAPM3 operator instead of deploying in Kubernetes | "true", "false" | "false" | | SKIP_RETRIES | Do not retry on failure during verifications or tests of the environment. This should be false. It could only be set to false for verifications of a dev env deployment that fully completed. Otherwise failures will appear as resources are not ready. | "true", "false" | "false" | +| SKIP_APPLY_BMH | Do not apply the BMHs. used usually when the BMHs will be applied later in the tests. | "true", "false" | "false" | | TEST_TIME_INTERVAL | Interval between retries after verification or test failure (seconds) | | 10 | | TEST_MAX_TIME | Number of maximum verification or test retries | | 120 | | BMO_ROLLOUT_WAIT | Number of minutes(Until max 10m that is the default value of deployment.spec.progressDeadlineSeconds) to wait for BMO rollout | | 5 |