From e0a7f8381fc3919b34101017f81e76cecbc9ae19 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Wed, 28 Oct 2026 19:36:12 -0600 Subject: [PATCH] Recover OCI edge endpoint from foundation compartment --- lib/jeannie/pipeline.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index 34d25d5..2794534 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -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