Skip to content

Commit

Permalink
Merge pull request #358 from cwilkers/metallb_timeouts
Browse files Browse the repository at this point in the history
Switch from hard-coded delays to variable in metallb_setup role
  • Loading branch information
tonyskapunk authored Jun 25, 2024
2 parents 1ff03d1 + 372f427 commit 30e0213
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
2 changes: 2 additions & 0 deletions roles/metallb_setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ NOTES:
| mlb_ipv6_enabled | false | Boolean | No | If IPv6 Pools are defined for BGP, enable this boolean |
| mlb_namespace | metallb-system | String | No | Default name of the namespace to use to install operator resources |
| mlb_bfd_profile | bfd-fastest | String | No | Name of the BFD profile to use for BGP |
| mlb_wait_retries | 18 | Int | No | How many times to retry OCP operations that fail |
| mlb_wait_delay | 10 | Int | No | How long to wait between retries of OCP operations that fail |
| mlb_settings | "" | File Path | No | An optional YAML file with the variables listed above. |

## Role requirements for BGP mode
Expand Down
2 changes: 2 additions & 0 deletions roles/metallb_setup/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ mlb_bfd_profile: bfd-fastest
mlb_ipv4_enabled: true
mlb_ipv6_enabled: false
mlb_action: install
mlb_wait_delay: 10
mlb_wait_retries: 18
...
11 changes: 9 additions & 2 deletions roles/metallb_setup/tasks/pre-requisites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
loop:
- mlb_ipaddr_pool

- name: "Validate values of mlb_wait_* are positive integers"
ansible.builtin.assert:
that:
- mlb_wait_delay | int > 0
- mlb_wait_retries | int > 0
fail_msg: "The parameters mlb_wait_delay and mlb_wait_retries must both be integers"

- name: "Confirm that MetalLB controller pods are Running"
community.kubernetes.k8s_info:
api_version: v1
Expand All @@ -57,8 +64,8 @@
- control-plane = controller-manager
register: pod_list
until: pod_list|json_query('resources[*].status.phase')|unique == ["Running"]
retries: 9
delay: 10
retries: "{{ mlb_wait_retries }}"
delay: "{{ mlb_wait_delay }}"
no_log: true

- name: "Validate parameter mlb_ipaddr_pool is a list"
Expand Down
28 changes: 14 additions & 14 deletions roles/metallb_setup/tasks/setup-metallb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
- component = speaker
register: pod_list
until: pod_list | json_query('resources[*].status.phase')|unique == ["Running"]
retries: 18
delay: 10
retries: "{{ mlb_wait_retries }}"
delay: "{{ mlb_wait_delay }}"
no_log: true

- name: "Create MetalLB IP Address Pool"
Expand All @@ -41,8 +41,8 @@
addresses: "{{ mlb_ipaddr_pool }}"
register: address_pool
until: address_pool is succeeded
retries: 6
delay: 10
retries: "{{ mlb_wait_retries }}"
delay: "{{ mlb_wait_delay }}"
no_log: true

- name: "Setup BGP mode objects"
Expand All @@ -68,8 +68,8 @@
minimumTtl: 254
register: bfdprof
until: bfdprof is succeeded
retries: 6
delay: 10
retries: "{{ mlb_wait_retries }}"
delay: "{{ mlb_wait_delay }}"
no_log: true

- name: "Create MetalLB BGP Peers"
Expand All @@ -81,8 +81,8 @@
loop_var: peer
register: bgppeer
until: bgppeer is succeeded
retries: 6
delay: 10
retries: "{{ mlb_wait_retries }}"
delay: "{{ mlb_wait_delay }}"
no_log: true

- name: "Create MetalLB BGP Advertisements"
Expand All @@ -107,8 +107,8 @@
definition: "{{ bgpadvert }}"
register: bgpadver
until: bgpadver is succeeded
retries: 6
delay: 10
retries: "{{ mlb_wait_retries }}"
delay: "{{ mlb_wait_delay }}"
no_log: true

- name: "Create MetalLB L2 Advertisements"
Expand All @@ -125,8 +125,8 @@
- "{{ mlb_setup_name | default('metallb') }}"
register: l2adver
until: l2adver is succeeded
retries: 6
delay: 10
retries: "{{ mlb_wait_retries }}"
delay: "{{ mlb_wait_delay }}"
no_log: true
when:
- mlb_bgp_peers is undefined
Expand All @@ -138,7 +138,7 @@
namespace: "{{ mlb_namespace }}"
register: pod_list
until: pod_list|json_query('resources[*].status.phase')|unique == ["Running"]
retries: 9
delay: 10
retries: "{{ mlb_wait_retries }}"
delay: "{{ mlb_wait_delay }}"
no_log: true
...

0 comments on commit 30e0213

Please sign in to comment.