From 10ef95c3ebdaa2c2b04489c570bdd9468eb29106 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Wed, 28 Oct 2026 21:07:37 -0600 Subject: [PATCH] Recover from stale explicit OCI edge IDs --- lib/jeannie/pipeline.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index f8e25fb..edd4041 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -8011,6 +8011,7 @@ refresh_oci_edge_endpoint() { local tenancy_id="${LAB_OCI_TENANCY_ID:-}" local oci_config_file="${OCI_CLI_CONFIG_FILE:-${HOME}/.oci/config}" local instance_compartment="${LAB_OCI_COMPARTMENT_ID:-}" + local existing_instance_id="${LAB_OCI_EDGE_EXISTING_INSTANCE_ID:-}" local candidate_compartment="" local candidate_id="" local edge_identity_stale=false @@ -8072,6 +8073,26 @@ refresh_oci_edge_endpoint() { discovered_edge_instance_id="${LAB_OCI_EDGE_INSTANCE_ID:-}" fi fi + # An old explicit existing-instance input must not pin recovery to a + # deleted jump box. Prefer a still-valid explicit instance; otherwise + # clear it and allow adoption of the current Jeannie-managed edge. + if [[ -n "${existing_instance_id}" && "${existing_instance_id}" != "null" ]] && + 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}" ]] && "${oci_bin}" compute instance get \ + --instance-id "${existing_instance_id}" >/dev/null 2>&1; then + discovered_edge_instance_id="${existing_instance_id}" + edge_identity_stale=false + else + printf 'Configured OCI edge instance %s is absent; clearing the explicit identity and rediscovering.\n' \ + "${existing_instance_id}" >&2 + unset LAB_OCI_EDGE_EXISTING_INSTANCE_ID + existing_instance_id="" + edge_identity_stale=true + LAB_OCI_EDGE_INSTANCE_MANAGED=true + export LAB_OCI_EDGE_INSTANCE_MANAGED + fi + fi if [[ -n "${discovered_edge_instance_id}" && "${discovered_edge_instance_id}" != "null" && -n "${instance_compartment}" ]] && @@ -8110,7 +8131,7 @@ refresh_oci_edge_endpoint() { # exists. Recover only the exact managed identity: display name # homelab-edge plus managed_by=jeannie. Never adopt arbitrary jump boxes. if [[ ( -n "${tenancy_id}" || -n "${instance_compartment}" ) && - -z "${LAB_OCI_EDGE_EXISTING_INSTANCE_ID:-}" && + -z "${existing_instance_id}" && ( "${LAB_OCI_EDGE_INSTANCE_MANAGED:-false}" != "true" || "${edge_identity_stale}" == "true" || -z "${discovered_edge_instance_id}" ) ]] && declare -F oci_cli_resolve >/dev/null 2>&1; then oci_bin="${oci_bin:-$(oci_cli_resolve 2>/dev/null || true)}"