Skip to content

Commit

Permalink
Enable some debugging if no DNS records
Browse files Browse the repository at this point in the history
It seems some scenarios might lead to no DNS records. This isn't normal,
and we need to know why we're hitting that issue.

This patch should help tracking down the issue.
  • Loading branch information
cjeanner authored and openshift-merge-bot[bot] committed Jul 4, 2024
1 parent d36631c commit 36b39bf
Showing 1 changed file with 78 additions and 43 deletions.
121 changes: 78 additions & 43 deletions roles/libvirt_manager/tasks/reserve_dnsmasq_ips.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,59 +42,94 @@
label: "{{ host_data.key }} - {{ net.name }}"
loop_var: "host_data"

- name: Create host records
when:
- host_data.value.networks[_cleaned_netname] is defined
- name: Manage common parameters
vars:
_net_name: >-
{{ (net.name is match '.*osp_trunk$') | ternary('ctlplane', net.name) }}
_cleaned_netname: "{{ _net_name | regex_replace('^cifmw[_-]', '') }}"
_net_data: "{{ host_data.value.networks[_cleaned_netname] }}"
_ocp_name: >-
{{
host_data.key | replace('_', '-') |
replace('ocp-worker', 'worker') |
replace('ocp', 'master')
}}
_hostname: >-
{{
(host_data.key is match('^ocp.*')) |
ternary(_ocp_name, host_data.key)
}}
_translate: >-
{{ cifmw_networking_mapper_interfaces_info_translations | default({}) }}
_net_domain: >-
{{
(net.name in _translate) |
ternary(_translate[net.name], [net.name])
}}
_fqdn: >-
{%- if net.name == cifmw_libvirt_manager_pub_net -%}
{{ [_hostname ~ '.' ~ cifmw_reproducer_domain | default('local')] }}
{%- else -%}
{{
[_hostname] | product(_net_domain) |
map('join', '.') |
product([cifmw_reproducer_domain | default('local')]) |
map('join', '.')
}}
{%- endif -%}
_record:
- state: present
ips: >-
_net_name: >-
{{ (net.name is match '.*osp_trunk$') | ternary('ctlplane', net.name) }}
_cleaned_netname: "{{ _net_name | regex_replace('^cifmw[_-]', '') }}"
block:
- name: Create host records
when:
- host_data.value.networks[_cleaned_netname] is defined
vars:
_net_data: "{{ host_data.value.networks[_cleaned_netname] }}"
_ocp_name: >-
{{
[
_net_data.ip_v4 | default(''),
_net_data.ip_v6 | default('')
]
host_data.key | replace('_', '-') |
replace('ocp-worker', 'worker') |
replace('ocp', 'master')
}}
names: "{{ _fqdn }}"
ansible.builtin.set_fact:
host_records: "{{ host_records | default([]) + _record }}"
loop: "{{ cifmw_networking_env_definition.instances | dict2items }}"
loop_control:
label: "{{ host_data.key }} - {{ net.name }}"
loop_var: "host_data"
_hostname: >-
{{
(host_data.key is match('^ocp.*')) |
ternary(_ocp_name, host_data.key)
}}
_fqdn: >-
{%- if net.name == cifmw_libvirt_manager_pub_net -%}
{{ [_hostname ~ '.' ~ cifmw_reproducer_domain | default('local')] }}
{%- else -%}
{{
[_hostname] | product(_net_domain) |
map('join', '.') |
product([cifmw_reproducer_domain | default('local')]) |
map('join', '.')
}}
{%- endif -%}
_record:
- state: present
ips: >-
{{
[
_net_data.ip_v4 | default(''),
_net_data.ip_v6 | default('')
]
}}
names: "{{ _fqdn }}"
ansible.builtin.set_fact:
host_records: "{{ host_records | default([]) + _record }}"
loop: "{{ cifmw_networking_env_definition.instances | dict2items }}"
loop_control:
label: "{{ host_data.key }} - {{ net.name }}"
loop_var: "host_data"

- name: Debugging block/rescue
block:
- name: Assert we have records
ansible.builtin.assert:
that:
- host_records is defined

rescue:
- name: Debug net.name
ansible.builtin.debug:
msg: "net.name: {{ net.name }}"

- name: Debug _translate
ansible.builtin.debug:
var: _translate

- name: Debug _net_domain
ansible.builtin.debug:
var: _net_domain

- name: Debug _net_name
ansible.builtin.debug:
var: _net_name

- name: Debug _cleaned_netname
ansible.builtin.debug:
var: _cleaned_netname

- name: Fail for good
ansible.builtin.fail:
msg: "Error detected, please check debug above"

- name: Inject host records
vars:
Expand Down

0 comments on commit 36b39bf

Please sign in to comment.