Skip to content

Commit a83006b

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 ea19fa3 commit a83006b

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
@@ -668,13 +668,23 @@ rbac_deployment() {
668668
# Returns:
669669
# 0 if both deployments succeed
670670
# 1 if either (or both) fail — failures are always reported individually
671+
#
672+
# Requires:
673+
# NAME_SPACE and NAME_SPACE_RBAC must be different to avoid resource conflicts
671674
_run_parallel_deployments() {
672675
local base_fn=$1
673676
local base_arg=$2
674677
local rbac_fn=$3
675678
local rbac_arg=$4
676679

680+
# Validate that namespaces are disjoint to prevent race conditions
681+
if [[ "${NAME_SPACE:-}" == "${NAME_SPACE_RBAC:-}" ]] || [[ -z "${NAME_SPACE:-}" ]] || [[ -z "${NAME_SPACE_RBAC:-}" ]]; then
682+
log::error "NAME_SPACE ('${NAME_SPACE:-}') and NAME_SPACE_RBAC ('${NAME_SPACE_RBAC:-}') must be different and non-empty for parallel deployment"
683+
return 1
684+
fi
685+
677686
log::section "Starting parallel deployments: base + RBAC"
687+
log::info "Base namespace: ${NAME_SPACE}, RBAC namespace: ${NAME_SPACE_RBAC}"
678688

679689
"${base_fn}" "${base_arg}" &
680690
local base_pid=$!
@@ -684,9 +694,11 @@ _run_parallel_deployments() {
684694
local rbac_pid=$!
685695
log::info "RBAC deployment started in background (PID: ${rbac_pid})"
686696

697+
log::section "Waiting for parallel deployments to complete..."
687698
local base_rc=0 rbac_rc=0
688699
wait "${base_pid}" || base_rc=$?
689700
wait "${rbac_pid}" || rbac_rc=$?
701+
log::section "Parallel deployments finished — evaluating results"
690702

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

0 commit comments

Comments
 (0)