Skip to content

Commit

Permalink
Cleanup .modified pipeline files
Browse files Browse the repository at this point in the history
Also update comments accordingly to make it clear what pipeline files
are used to check validity.

Signed-off-by: Chenxiong Qi <[email protected]>
  • Loading branch information
tkdchen committed Jan 9, 2025
1 parent 32f691b commit ebd6ba2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions hack/validate-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ list_preprocessed_pipelines() {
# This function checks two aspects:
# - whether the migration file exits successfully or not.
# - whether the migration file modifies a pipeline. If nothing changed, it is treated a failure.
# The modified pipeline is saved into a separate file with suffix '.modified'.
check_apply_on_pipelines() {
local -r migration_file=$1
local -r run_log_file=$(mktemp --suffix=-migration-run-test)
Expand Down Expand Up @@ -300,8 +301,15 @@ check_apply_in_real_cluster() {
else
kubectl create namespace ${K8S_TEST_NS}
fi
local -r apply_logfile=$(mktemp --suffix="-${FUNCNAME[0]}")
local -r modified_pipeline_files=$(find "${WORK_DIR}/pipelines" -type f -name "*.modified")
local apply_logfile
local modified_pipeline_files
apply_logfile=$(mktemp --suffix="-${FUNCNAME[0]}")
modified_pipeline_files=$(find "${WORK_DIR}/pipelines" -type f -name "*.modified")
if [ -z "$modified_pipeline_files" ]; then
echo "error: No modified pipeline file is found." >&2
echo "error: Please check if migrations work correctly to update pipelines." >&2
exit 1
fi
while read -r pl_file; do
if ! kubectl apply -f "$pl_file" -n ${K8S_TEST_NS} 2>"$apply_logfile" >/dev/null; then
echo "${FUNCNAME[0]}: failed to apply pipeline to cluster: $pl_file" >&2
Expand Down Expand Up @@ -338,6 +346,8 @@ main() {
check_pass_shellcheck "$migration_file"
check_migrations_is_in_task_version_specific_dir "$migration_file"
check_version_match "$migration_file"
# Cleanup any existing pipeline files modified previously.
find "${WORK_DIR}/pipelines" -type f -name "*.modified" -delete
check_apply_on_pipelines "$migration_file"
check_apply_in_real_cluster
done
Expand Down

0 comments on commit ebd6ba2

Please sign in to comment.