Search OCI compartments during edge recovery

This commit is contained in:
juvenal.diaz 2026-10-28 21:01:48 -06:00
parent 285e8cad3f
commit 8d1605c4cd
1 changed files with 14 additions and 1 deletions

View File

@ -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 \