diff --git a/Makefile b/Makefile index 6b50d50c..c333e331 100644 --- a/Makefile +++ b/Makefile @@ -59,13 +59,10 @@ up: env gen-certs control-plane-bake partition-bake # for some reason an allocated machine will not be able to phone home # without restarting the metal-core # TODO: should be investigated and fixed if possible +# check that underlay gets working sleep 10 ssh -F files/ssh/config leaf01 'systemctl restart metal-core' ssh -F files/ssh/config leaf02 'systemctl restart metal-core' -# TODO: for community SONiC versions > 202311 a bgp restart is needed in the virtual environment - sleep 15 - ssh -F files/ssh/config leaf01 'systemctl restart bgp' - ssh -F files/ssh/config leaf02 'systemctl restart bgp' .PHONY: restart restart: down up diff --git a/deploy_partition.yaml b/deploy_partition.yaml index c8299608..de4935bd 100644 --- a/deploy_partition.yaml +++ b/deploy_partition.yaml @@ -64,3 +64,11 @@ - lookup('metal', 'search', 'switch', api_url=metal_partition_metal_api_protocol+'://'+metal_partition_metal_api_addr+':'+metal_partition_metal_api_port|string+metal_partition_metal_api_basepath, api_hmac=metal_partition_metal_api_hmac_edit_key) | length == 2 - lookup('metal', 'search', 'switch', api_url=metal_partition_metal_api_protocol+'://'+metal_partition_metal_api_addr+':'+metal_partition_metal_api_port|string+metal_partition_metal_api_basepath, api_hmac=metal_partition_metal_api_hmac_edit_key)[0]["last_sync"] != None - lookup('metal', 'search', 'switch', api_url=metal_partition_metal_api_protocol+'://'+metal_partition_metal_api_addr+':'+metal_partition_metal_api_port|string+metal_partition_metal_api_basepath, api_hmac=metal_partition_metal_api_hmac_edit_key)[1]["last_sync"] != None + +- name: Wait for underlay + hosts: leaves + any_errors_fatal: true + gather_facts: false + pre_tasks: + - name: Wait until no route entries have "queued" + include_tasks: tasks/check_queued.yaml diff --git a/tasks/check_queued.yaml b/tasks/check_queued.yaml new file mode 100644 index 00000000..edd2c1bd --- /dev/null +++ b/tasks/check_queued.yaml @@ -0,0 +1,33 @@ +--- + + +- name: wait for more than one route + shell: | + set -euo pipefail + vtysh -c 'show bgp ipv4 unicast json' | jq -r '.routes | to_entries | length > 1' + args: + executable: /bin/bash + register: routes_check + until: routes_check.stdout == "true" + retries: 10 + delay: 5 + changed_when: false + +- name: check for queued routes + shell: | + vtysh -c 'show ip route json' | jq -r '[.[] | .[] | .queued == true] | any' + args: + executable: /bin/bash + register: queued_check + delay: 5 + changed_when: false + +- name: restart bgp + ansible.builtin.systemd: + name: bgp + state: restarted + when: queued_check.stdout == "true" + +- name: recheck for queued routes + include_tasks: tasks/check_queued.yaml + when: queued_check.stdout == "true"