From 878982333dcc6cfcc81d9f3dd38f3b9bf291ec03 Mon Sep 17 00:00:00 2001 From: Stavros Kontopoulos Date: Mon, 8 Jul 2024 17:17:47 +0300 Subject: [PATCH] fix release script --- hack/release.sh | 50 ++++++++++++++++++++++++++++++++++++++--------- test/e2e-tests.sh | 11 ++++------- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/hack/release.sh b/hack/release.sh index 6f83c3f0..4020ff00 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -19,17 +19,49 @@ source $(dirname $0)/../vendor/knative.dev/hack/release.sh +# Yaml files to generate, and the source config dir for them. +declare -A COMPONENTS +COMPONENTS=( + ["autoscaler-keda.yaml"]="config" +) +readonly COMPONENTS + +declare -A RELEASES +RELEASES=( + ["release.yaml"]="autoscaler-keda.yaml" +) +readonly RELEASES + function build_release() { - # Run `generate-yamls.sh`, which should be versioned with the - # branch since the detail of building may change over time. - local YAML_LIST="$(mktemp)" - export TAG - $(dirname $0)/generate-yamls.sh "${REPO_ROOT_DIR}" "${YAML_LIST}" - ARTIFACTS_TO_PUBLISH=$(cat "${YAML_LIST}" | tr '\n' ' ') - if (( ! PUBLISH_RELEASE )); then - # Copy the generated YAML files to the repo root dir if not publishing. - cp ${ARTIFACTS_TO_PUBLISH} ${REPO_ROOT_DIR} + # Update release labels if this is a tagged release + if [[ -n "${TAG}" ]]; then + echo "Tagged release, updating release labels to app.kubernetes.io/version: \"${TAG}\"" + LABEL_YAML_CMD=(sed -e "s|app.kubernetes.io/version: devel|app.kubernetes.io/version: \"${TAG:1}\"|") + else + echo "Untagged release, will NOT update release labels" + LABEL_YAML_CMD=(cat) fi + + # Build the components + local all_yamls=() + for yaml in "${!COMPONENTS[@]}"; do + local config="${COMPONENTS[${yaml}]}" + echo "Building Knative autoscaler-keda - ${config}" + ko resolve ${KO_FLAGS} -f ${config}/ | "${LABEL_YAML_CMD[@]}" > ${yaml} + all_yamls+=(${yaml}) + done + # Assemble the release + for yaml in "${!RELEASES[@]}"; do + echo "Assembling Knative autoscaler-keda - ${yaml}" + echo "" > ${yaml} + for component in ${RELEASES[${yaml}]}; do + echo "---" >> ${yaml} + echo "# ${component}" >> ${yaml} + cat ${component} >> ${yaml} + done + all_yamls+=(${yaml}) + done + ARTIFACTS_TO_PUBLISH="${all_yamls[@]}" } main $@ diff --git a/test/e2e-tests.sh b/test/e2e-tests.sh index 6fa7ca39..f95fdeeb 100755 --- a/test/e2e-tests.sh +++ b/test/e2e-tests.sh @@ -24,7 +24,7 @@ KEDA_NS="keda" initialize --num-nodes=4 --cluster-version=1.28 "$@" git clone https://github.com/knative/serving.git "serving" -cd serving +pushd serving rm ./test/config/chaosduck/chaosduck.yaml # Disable HPA manifests @@ -45,6 +45,7 @@ knative_setup echo ">> Uploading test images..." ko resolve --jobs=4 -RBf ./test/test_images/autoscale > /dev/null +popd # Setup Helm - TODO move to the infra image @@ -70,15 +71,14 @@ kubectl wait deployment.apps/keda-operator -n "${KEDA_NS}" --for condition=avail kubectl wait deployment.apps/keda-operator-metrics-apiserver -n "${KEDA_NS}" --for condition=available --timeout=600s #Setup Autoscaler KEDA -cd .. ko resolve -f ./config | sed "s/namespace: knative-serving/namespace: ${SYSTEM_NAMESPACE}/" | kubectl apply -f- # Wait for the Autoscaler KEDA deployment to be available kubectl wait deployments.apps/autoscaler-keda -n "${SYSTEM_NAMESPACE}" --for condition=available --timeout=600s +pushd serving # Run the HPA tests header "Running HPA tests" -cd serving # Needed for HPA Mem test, see https://keda.sh/docs/2.14/scalers/memory/#prerequisites toggle_feature queueproxy.resource-defaults "enabled" config-features @@ -86,8 +86,5 @@ go_test_e2e -timeout=30m -tags=hpa ./test/e2e "${E2E_TEST_FLAGS[@]}" || failed=1 (( failed )) && fail_test -# Remove the kail log file if the test flow passes. -# This is for preventing too many large log files to be uploaded to GCS in CI. -rm "${ARTIFACTS}/k8s.log-$(basename "${E2E_SCRIPT}").txt" - +popd success