def wait_for_promotion_to_complete()

in global-clusters-automation/failover_and_delete_global_cluster.py [0:0]


def wait_for_promotion_to_complete(global_cluster_id, cluster_arn):
    remaining_secondary_clusters = get_secondary_clusters(global_cluster_id)
    while len(remaining_secondary_clusters) > 0:
        time.sleep(10)
        remaining_secondary_clusters = get_secondary_clusters(global_cluster_id)
        print('Waiting for cluster promotion to complete...')
        # The below code is to check if the cluster provided as input has been deleted. This is to be used
        # when global cluster delete indicator is 'N'
        is_cluster_promotion_in_progress = False
        for each_cluster in remaining_secondary_clusters:
            # each_secondary_cluster_id = each_cluster.split(":")[-1]
            if each_cluster == cluster_arn:
                is_cluster_promotion_in_progress = True
                break
        if len(remaining_secondary_clusters) == 0 or (not is_cluster_promotion_in_progress):
            print('Cluster promotion process completed')
            break