Recover OCI edge endpoint from foundation compartment
This commit is contained in:
parent
23776ac0d5
commit
e0a7f8381f
|
|
@ -8009,6 +8009,12 @@ refresh_oci_edge_endpoint() {
|
|||
fi
|
||||
discovered_edge_ip="$(tofu -chdir="${stack}" output "${tofu_state_args[@]}" -raw edge_public_ip 2>/dev/null || true)"
|
||||
discovered_edge_instance_id="$(tofu -chdir="${stack}" output "${tofu_state_args[@]}" -raw edge_instance_id 2>/dev/null || true)"
|
||||
# The API service may not inherit the interactive shell's OCI compartment
|
||||
# variables. Recover the managed compartment from foundation state so a
|
||||
# recreated edge can still be discovered without manual exports.
|
||||
if [[ -z "${instance_compartment}" ]]; then
|
||||
instance_compartment="$(tofu -chdir="${stack}" output "${tofu_state_args[@]}" -raw compartment_id 2>/dev/null || true)"
|
||||
fi
|
||||
|
||||
# Existing-instance mode can retain an old/null public_ip in state. Query
|
||||
# OCI directly from the instance OCID and read the attached VNIC instead.
|
||||
|
|
@ -8039,12 +8045,12 @@ refresh_oci_edge_endpoint() {
|
|||
# State may have been lost even though the Jeannie-created instance still
|
||||
# exists. Recover only the exact managed identity: display name
|
||||
# homelab-edge plus managed_by=jeannie. Never adopt arbitrary jump boxes.
|
||||
if [[ -n "${LAB_OCI_TENANCY_ID:-}" &&
|
||||
if [[ ( -n "${LAB_OCI_TENANCY_ID:-}" || -n "${instance_compartment}" ) &&
|
||||
"${LAB_OCI_EDGE_INSTANCE_MANAGED:-false}" != "true" ]] &&
|
||||
declare -F oci_cli_resolve >/dev/null 2>&1; then
|
||||
oci_bin="${oci_bin:-$(oci_cli_resolve 2>/dev/null || true)}"
|
||||
if [[ -n "${oci_bin}" ]]; then
|
||||
local -a edge_compartments=("${instance_compartment}" "${LAB_OCI_TENANCY_ID}")
|
||||
local -a edge_compartments=("${instance_compartment}" "${LAB_OCI_TENANCY_ID:-}")
|
||||
for candidate_compartment in "${edge_compartments[@]}"; do
|
||||
[[ -n "${candidate_compartment}" ]] || continue
|
||||
candidate_id="$("${oci_bin}" compute instance list \
|
||||
|
|
@ -8073,7 +8079,8 @@ refresh_oci_edge_endpoint() {
|
|||
|
||||
if [[ -z "${discovered_edge_ip}" || "${discovered_edge_ip}" == "null" ]]; then
|
||||
if [[ "${LAB_OCI_EDGE_INSTANCE_MANAGED:-false}" == "true" ]]; then
|
||||
echo "Jeannie-managed OCI edge instance has no resolvable public IP; refusing stale LAB_EDGE_HOST." >&2
|
||||
printf 'Jeannie-managed OCI edge discovery failed (instance=%s compartment=%s); refusing stale LAB_EDGE_HOST=%s.\n' \
|
||||
"${discovered_edge_instance_id:-unknown}" "${instance_compartment:-unknown}" "${LAB_EDGE_HOST:-unset}" >&2
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue