Skip to content

Commit 023e121

Browse files
fonta-rhclaude
andcommitted
fix: correct common.sh path and use config/ folder in doctor hints
After the config-folder PR moved common.sh from deploy/aws-hypervisor/scripts/ to deploy/, doctor.sh referenced the old path and would fail on startup. Fix the source path and replace msg_err with an inline printf so the summary works even when common.sh fails to load. All fix hints now point to the central config/ folder instead of the deep canonical paths, consistent with the config-folder workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e14101d commit 023e121

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

deploy/openshift-clusters/scripts/doctor.sh

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@
1515
SCRIPT_DIR=$(dirname "$0")
1616
DEPLOY_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"
1717

18+
REPO_ROOT="$(cd "${DEPLOY_DIR}/.." && pwd)"
19+
CONFIG_DIR="${REPO_ROOT}/config"
1820
INSTANCE_ENV="${DEPLOY_DIR}/aws-hypervisor/instance.env"
1921

2022
# common.sh provides the color constants, msg_* helpers, and env defaults, but
2123
# unconditionally sources instance.env; silence that noise when instance.env
2224
# does not exist yet (its absence is reported as a proper check below).
2325
if [[ -f "${INSTANCE_ENV}" ]]; then
2426
# shellcheck source=/dev/null
25-
source "${DEPLOY_DIR}/aws-hypervisor/scripts/common.sh"
27+
source "${DEPLOY_DIR}/common.sh"
2628
else
2729
# shellcheck source=/dev/null
28-
source "${DEPLOY_DIR}/aws-hypervisor/scripts/common.sh" 2>/dev/null
30+
source "${DEPLOY_DIR}/common.sh" 2>/dev/null
2931
fi
3032

3133
# Strict flags only after common.sh: it expands variables that may be unset.
@@ -164,7 +166,7 @@ if [[ -n "${SSH_PUBLIC_KEY:-}" ]]; then
164166
check_pass "SSH public key found (SSH_PUBLIC_KEY=${SSH_PUBLIC_KEY})"
165167
else
166168
check_fail "SSH_PUBLIC_KEY in instance.env points to a missing file: ${SSH_PUBLIC_KEY}" \
167-
"fix the path in ${INSTANCE_ENV}, or generate a key: 'ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519'"
169+
"fix the path in ${CONFIG_DIR}/instance.env, or generate a key: 'ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519'"
168170
fi
169171
elif [[ -f "${HOME}/.ssh/id_ed25519.pub" ]]; then
170172
check_pass "SSH public key found (~/.ssh/id_ed25519.pub)"
@@ -233,7 +235,7 @@ fi
233235
section "AWS hypervisor (instance.env)"
234236

235237
if [[ ! -f "${INSTANCE_ENV}" ]]; then
236-
check_note "section skipped: instance.env not found (only needed for the AWS hypervisor flow) - to use it: 'cp ${INSTANCE_ENV}.template ${INSTANCE_ENV}' and edit"
238+
check_note "section skipped: instance.env not found (only needed for the AWS hypervisor flow) - to use it: 'cp ${CONFIG_DIR}/instance.env.template ${CONFIG_DIR}/instance.env' and edit"
237239
else
238240
# set +u: the deployment scripts never source instance.env under nounset,
239241
# so the probe must not be stricter than real usage
@@ -242,14 +244,14 @@ else
242244
check_pass "instance.env sources cleanly"
243245
else
244246
check_fail "instance.env does not source cleanly: ${SOURCE_ERR}" \
245-
"fix the shell syntax in ${INSTANCE_ENV}"
247+
"fix the shell syntax in ${CONFIG_DIR}/instance.env"
246248
fi
247249

248250
if [[ -n "${REGION:-}" && -n "${AWS_PROFILE:-}" ]]; then
249251
check_pass "REGION (${REGION}) and AWS_PROFILE (${AWS_PROFILE}) are set"
250252
else
251253
check_fail "REGION and/or AWS_PROFILE not set by instance.env" \
252-
"set REGION and AWS_PROFILE in ${INSTANCE_ENV} (see instance.env.template)"
254+
"set REGION and AWS_PROFILE in ${CONFIG_DIR}/instance.env (see ${CONFIG_DIR}/instance.env.template)"
253255
fi
254256

255257
if ! command -v aws >/dev/null 2>&1 || ! command -v timeout >/dev/null 2>&1; then
@@ -284,25 +286,25 @@ if [[ -f "${DS_PULL_SECRET}" ]]; then
284286
DS_PULL_SECRET_OK=1
285287
else
286288
check_fail "pull-secret.json is not valid JSON (dev-scripts)" \
287-
"re-download it from https://cloud.redhat.com/openshift/install/pull-secret and save it to ${DS_PULL_SECRET}"
289+
"re-download it from https://cloud.redhat.com/openshift/install/pull-secret and save it to ${CONFIG_DIR}/pull-secret.json"
288290
fi
289291
elif [[ "${NEED_DEVSCRIPTS}" -eq 1 ]]; then
290292
check_fail "pull-secret.json missing (required for the requested dev-scripts deployment)" \
291-
"download it from https://cloud.redhat.com/openshift/install/pull-secret and save it to ${DS_PULL_SECRET}"
293+
"download it from https://cloud.redhat.com/openshift/install/pull-secret and save it to ${CONFIG_DIR}/pull-secret.json"
292294
else
293295
check_warn "pull-secret.json missing (needed for dev-scripts deployments)" \
294-
"download it from https://cloud.redhat.com/openshift/install/pull-secret and save it to ${DS_PULL_SECRET}"
296+
"download it from https://cloud.redhat.com/openshift/install/pull-secret and save it to ${CONFIG_DIR}/pull-secret.json"
295297
fi
296298

297299
for topology in arbiter fencing sno; do
298300
CONFIG_FILE="${DS_FILES_DIR}/config_${topology}.sh"
299301
if [[ ! -f "${CONFIG_FILE}" ]]; then
300302
if topology_required "${topology}"; then
301303
check_fail "config_${topology}.sh missing (required for the requested deployment)" \
302-
"cp ${DS_FILES_DIR}/config_${topology}_example.sh ${CONFIG_FILE} and set OPENSHIFT_RELEASE_IMAGE / CI_TOKEN"
304+
"cp ${CONFIG_DIR}/config_${topology}_example.sh ${CONFIG_DIR}/config_${topology}.sh and set OPENSHIFT_RELEASE_IMAGE / CI_TOKEN"
303305
else
304306
check_warn "config_${topology}.sh missing (only needed to deploy the ${topology} topology with dev-scripts)" \
305-
"cp ${DS_FILES_DIR}/config_${topology}_example.sh ${CONFIG_FILE} and set OPENSHIFT_RELEASE_IMAGE / CI_TOKEN"
307+
"cp ${CONFIG_DIR}/config_${topology}_example.sh ${CONFIG_DIR}/config_${topology}.sh and set OPENSHIFT_RELEASE_IMAGE / CI_TOKEN"
306308
fi
307309
continue
308310
fi
@@ -315,7 +317,7 @@ for topology in arbiter fencing sno; do
315317
check_pass "pull secret has registry.ci.openshift.org auth (used by config_${topology}.sh)"
316318
else
317319
check_fail "config_${topology}.sh uses registry.ci.openshift.org but the pull secret has no auth entry for it" \
318-
"add CI registry credentials to ${DS_PULL_SECRET}, or switch to a public release image (quay.io/openshift-release-dev/ocp-release)"
320+
"add CI registry credentials to ${CONFIG_DIR}/pull-secret.json, or switch to a public release image (quay.io/openshift-release-dev/ocp-release)"
319321
fi
320322
fi
321323

@@ -334,7 +336,7 @@ for topology in arbiter fencing sno; do
334336
check_warn "CI token check: could not reach ${RELEASE_REGISTRY} (network failure or timeout)"
335337
elif [[ "${HTTP_CODE}" == "401" ]]; then
336338
check_fail "CI token in config_${topology}.sh is invalid or expired (HTTP 401 from ${RELEASE_REGISTRY})" \
337-
"update CI_TOKEN in ${CONFIG_FILE} (copy a fresh token from the CI cluster console)"
339+
"update CI_TOKEN in ${CONFIG_DIR}/config_${topology}.sh (copy a fresh token from the CI cluster console)"
338340
elif [[ "${HTTP_CODE}" == "200" ]]; then
339341
check_pass "CI token in config_${topology}.sh accepted by ${RELEASE_REGISTRY}"
340342
else
@@ -361,19 +363,18 @@ else
361363
check_pass "pull-secret.json present and valid JSON (kcli)"
362364
else
363365
check_fail "pull-secret.json is not valid JSON (kcli)" \
364-
"re-download it from https://cloud.redhat.com/openshift/install/pull-secret and save it to ${KCLI_PULL_SECRET}"
366+
"re-download it from https://cloud.redhat.com/openshift/install/pull-secret and save it to ${CONFIG_DIR}/pull-secret.json"
365367
fi
366368
if [[ -f "${DS_PULL_SECRET}" ]] && ! cmp -s "${KCLI_PULL_SECRET}" "${DS_PULL_SECRET}"; then
367-
# per the /setup docs, both locations are meant to hold the same secret
368369
check_warn "kcli pull-secret.json differs from the dev-scripts copy" \
369-
"cp ${DS_PULL_SECRET} ${KCLI_PULL_SECRET} (or the other way around, whichever is current)"
370+
"save the correct version to ${CONFIG_DIR}/pull-secret.json and run 'make sync-config' to update both locations"
370371
fi
371372
elif [[ "${NEED_KCLI}" -eq 1 ]]; then
372373
check_fail "pull-secret.json missing (required for the requested kcli deployment)" \
373-
"download it from https://cloud.redhat.com/openshift/install/pull-secret and save it to ${KCLI_PULL_SECRET}"
374+
"download it from https://cloud.redhat.com/openshift/install/pull-secret and save it to ${CONFIG_DIR}/pull-secret.json"
374375
else
375376
check_warn "pull-secret.json missing (needed for *-kcli deployments)" \
376-
"download it from https://cloud.redhat.com/openshift/install/pull-secret and save it to ${KCLI_PULL_SECRET}"
377+
"download it from https://cloud.redhat.com/openshift/install/pull-secret and save it to ${CONFIG_DIR}/pull-secret.json"
377378
fi
378379
fi
379380

@@ -382,7 +383,7 @@ fi
382383
echo ""
383384
echo "Summary: ${PASS_COUNT} passed, ${WARN_COUNT} warnings, ${FAIL_COUNT} failures"
384385
if [[ ${FAIL_COUNT} -gt 0 ]]; then
385-
msg_err "configuration is not ready - address the FAIL items above"
386+
printf '%b%s%b\n' "${COLOR_RED:-}" "ERROR: configuration is not ready - address the FAIL items above" "${COLOR_CLEAR:-}" >&2
386387
exit 1
387388
fi
388389
exit 0

0 commit comments

Comments
 (0)