diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index e8952fc..f7eb373 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -8103,7 +8103,20 @@ refresh_oci_edge_endpoint() { 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}") + # The instance may have been recreated in a child compartment + # after the original state was removed. Enumerate the tenancy's + # compartments so recovery does not depend on the old compartment + # OCID being correct. + if [[ -n "${LAB_OCI_TENANCY_ID:-}" ]]; then + while IFS= read -r candidate_compartment; do + [[ -n "${candidate_compartment}" ]] && edge_compartments+=("${candidate_compartment}") + done < <("${oci_bin}" iam compartment list \ + --compartment-id "${LAB_OCI_TENANCY_ID}" \ + --compartment-id-in-subtree true --all \ + --query 'data[].id' --raw-output 2>/dev/null || true) + edge_compartments+=("${LAB_OCI_TENANCY_ID}") + fi for candidate_compartment in "${edge_compartments[@]}"; do [[ -n "${candidate_compartment}" ]] || continue candidate_id="$("${oci_bin}" compute instance list \