Skip to content

Commit f631cd9

Browse files
committed
refactor(ci): add defensive checks and improved logging to parallel deployments
Address code review findings from PR #4679: 1. **Namespace validation**: Add defensive check to ensure NAME_SPACE and NAME_SPACE_RBAC are different and non-empty before starting parallel deployments. Prevents subtle race conditions if misconfigured. 2. **Improved logging**: - Log both namespace names at the start for debugging - Add synchronization point logs ("Waiting for parallel deployments..." and "Parallel deployments finished") to make log flow clearer when output from both background jobs is interleaved 3. **Documentation**: Add "Requires" section to function header documenting the namespace disjointness requirement These changes improve debuggability and fail-fast behavior without changing the core parallelization logic.
1 parent b0560bc commit f631cd9

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

.ci/pipelines/utils.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,13 +647,23 @@ rbac_deployment() {
647647
# Returns:
648648
# 0 if both deployments succeed
649649
# 1 if either (or both) fail — failures are always reported individually
650+
#
651+
# Requires:
652+
# NAME_SPACE and NAME_SPACE_RBAC must be different to avoid resource conflicts
650653
_run_parallel_deployments() {
651654
local base_fn=$1
652655
local base_arg=$2
653656
local rbac_fn=$3
654657
local rbac_arg=$4
655658

659+
# Validate that namespaces are disjoint to prevent race conditions
660+
if [[ "${NAME_SPACE:-}" == "${NAME_SPACE_RBAC:-}" ]] || [[ -z "${NAME_SPACE:-}" ]] || [[ -z "${NAME_SPACE_RBAC:-}" ]]; then
661+
log::error "NAME_SPACE ('${NAME_SPACE:-}') and NAME_SPACE_RBAC ('${NAME_SPACE_RBAC:-}') must be different and non-empty for parallel deployment"
662+
return 1
663+
fi
664+
656665
log::section "Starting parallel deployments: base + RBAC"
666+
log::info "Base namespace: ${NAME_SPACE}, RBAC namespace: ${NAME_SPACE_RBAC}"
657667

658668
"${base_fn}" "${base_arg}" &
659669
local base_pid=$!
@@ -663,9 +673,11 @@ _run_parallel_deployments() {
663673
local rbac_pid=$!
664674
log::info "RBAC deployment started in background (PID: ${rbac_pid})"
665675

676+
log::section "Waiting for parallel deployments to complete..."
666677
local base_rc=0 rbac_rc=0
667678
wait "${base_pid}" || base_rc=$?
668679
wait "${rbac_pid}" || rbac_rc=$?
680+
log::section "Parallel deployments finished — evaluating results"
669681

670682
if [[ ${base_rc} -eq 0 ]]; then
671683
log::success "Base deployment completed"

0 commit comments

Comments
 (0)