Skip to content

Commit

Permalink
Refactor periodic sanity plugin checks deployment logic
Browse files Browse the repository at this point in the history
Moved plugin checks deployment logic to a reusable function `initiate_sanity_plugin_checks_deployment`. Simplified the `run_sanity_plugins_check` method by delegating complex deployment steps to the new function, improving readability and maintainability.

Signed-off-by: Gustavo Lira <[email protected]>
  • Loading branch information
gustavolira committed Feb 18, 2025
1 parent ab5ad6c commit e99f40b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
15 changes: 1 addition & 14 deletions .ibm/pipelines/jobs/periodic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,7 @@ run_runtime_config_change_tests() {
}

run_sanity_plugins_check() {
configure_namespace "${NAME_SPACE_SANITY_PLUGINS_CHECK}"
uninstall_helmchart "${NAME_SPACE_SANITY_PLUGINS_CHECK}" "${RELEASE_NAME}"
oc apply -f "$DIR/resources/redis-cache/redis-deployment.yaml" --namespace="${NAME_SPACE_SANITY_PLUGINS_CHECK}"
initiate_sanity_plugin_checks_deployment "${RELEASE_NAME}" "${NAME_SPACE_SANITY_PLUGINS_CHECK}"
local sanity_plugins_url="https://${RELEASE_NAME}-backstage-${NAME_SPACE_SANITY_PLUGINS_CHECK}.${K8S_CLUSTER_ROUTER_BASE}"
apply_yaml_files "${DIR}" "${NAME_SPACE_SANITY_PLUGINS_CHECK}" "${sanity_plugins_url}"

helm upgrade -i "${RELEASE_NAME}" \
-n "${NAME_SPACE_SANITY_PLUGINS_CHECK}" "${HELM_REPO_NAME}/${HELM_IMAGE_NAME}" \
--version "${CHART_VERSION}" \
-f "${DIR}/value_files/${HELM_CHART_VALUE_FILE_NAME}" \
-f "${DIR}/value_files/sanity-check-plugins.yaml" \
--set global.clusterRouterBase="${K8S_CLUSTER_ROUTER_BASE}" \
--set upstream.backstage.image.repository="${QUAY_REPO}" \
--set upstream.backstage.image.tag="${TAG_NAME}"

check_and_test "${RELEASE_NAME}" "${NAME_SPACE_SANITY_PLUGINS_CHECK}" "${sanity_plugins_url}"
}
19 changes: 17 additions & 2 deletions .ibm/pipelines/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ wait_for_svc(){
local svc_name=$1
local namespace=$2
local timeout=${3:-300}

timeout "${timeout}" bash -c "
echo ${svc_name}
while ! oc get svc $svc_name -n $namespace &> /dev/null; do
Expand Down Expand Up @@ -666,7 +666,7 @@ install_acm_operator(){
wait_for_svc multiclusterhub-operator-webhook open-cluster-management
oc apply -f "${DIR}/cluster/operators/acm/multiclusterhub.yaml"
# wait until multiclusterhub is Running.
timeout 900 bash -c 'while true; do
timeout 900 bash -c 'while true; do
CURRENT_PHASE=$(oc get multiclusterhub multiclusterhub -n open-cluster-management -o jsonpath="{.status.phase}")
echo "MulticlusterHub Current Status: $CURRENT_PHASE"
[[ "$CURRENT_PHASE" == "Running" ]] && echo "MulticlusterHub is now in Running phase." && break
Expand Down Expand Up @@ -801,6 +801,21 @@ initiate_runtime_deployment() {
--set upstream.backstage.image.tag="${TAG_NAME}"
}

initiate_sanity_plugin_checks_deployment() {
configure_namespace "${NAME_SPACE_SANITY_PLUGINS_CHECK}"
uninstall_helmchart "${NAME_SPACE_SANITY_PLUGINS_CHECK}" "${RELEASE_NAME}"
oc apply -f "$DIR/resources/redis-cache/redis-deployment.yaml" --namespace="${NAME_SPACE_SANITY_PLUGINS_CHECK}"
apply_yaml_files "${DIR}" "${NAME_SPACE_SANITY_PLUGINS_CHECK}" "${sanity_plugins_url}"
helm upgrade -i "${RELEASE_NAME}" \
-n "${NAME_SPACE_SANITY_PLUGINS_CHECK}" "${HELM_REPO_NAME}/${HELM_IMAGE_NAME}" \
--version "${CHART_VERSION}" \
-f "${DIR}/value_files/${HELM_CHART_VALUE_FILE_NAME}" \
-f "${DIR}/value_files/sanity-check-plugins.yaml" \
--set global.clusterRouterBase="${K8S_CLUSTER_ROUTER_BASE}" \
--set upstream.backstage.image.repository="${QUAY_REPO}" \
--set upstream.backstage.image.tag="${TAG_NAME}"
}

check_and_test() {
local release_name=$1
local namespace=$2
Expand Down

0 comments on commit e99f40b

Please sign in to comment.