Skip to content
Open
15 changes: 14 additions & 1 deletion src/connectedk8s/azext_connectedk8s/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
ConnectedClusterPatch,
ConnectedClusterPatchProperties,
ConnectedClusterProperties,
ConnectivityStatus,
Gateway,
OidcIssuerProfile,
SecurityProfile,
Expand Down Expand Up @@ -1513,7 +1514,19 @@ def connected_cluster_exists(
client: ConnectedClusterOperations, resource_group_name: str, cluster_name: str
) -> bool:
try:
client.get(resource_group_name, cluster_name)
connected_cluster = client.get(resource_group_name, cluster_name)
Comment thread
ikanni marked this conversation as resolved.
connectivity_status = getattr(connected_cluster, "connectivity_status", None)

# Allow AgentNotInstalled -> Agent conversion:
# treat an existing ARM resource in AgentNotInstalled state as non-existent for onboarding flows.
if connectivity_status == ConnectivityStatus.AGENT_NOT_INSTALLED:
logger.info(
"Arc enabling the %s in resource group %s with connectivity status %s",
cluster_name,
resource_group_name,
connectivity_status,
)
return False
except Exception as e: # pylint: disable=broad-except
utils.arm_exception_handler(
e,
Expand Down
Loading