Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dhclient hooks have wrong formatting when using resolvconf #11930

Closed
kyrbrbik opened this issue Jan 27, 2025 · 2 comments · Fixed by #11946
Closed

Dhclient hooks have wrong formatting when using resolvconf #11930

kyrbrbik opened this issue Jan 27, 2025 · 2 comments · Fixed by #11946
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@kyrbrbik
Copy link
Contributor

What happened?

dhclient.conf entries supersede domain-name and supersede domain-search aren't enclosed in quotes. This results in resolvconf enter hooks failing which breaks networking.service on debian. With networking.service broken the dhcp leases cannot be renewed and the machines loses network access after they expire.

What did you expect to happen?

dhclient to have correct format like this:

# Ansible entries BEGIN
supersede domain-name-servers 169.254.25.10,1.1.1.1,8.8.8.8;
supersede domain-name "cluster.local";
supersede domain-search "default.svc.cluster.local,svc.cluster.local";
# Ansible entries END

How can we reproduce it (as minimally and precisely as possible)?

Install kubespray on debian that uses resolvconf. Might be reproducible on other distributions as well, but when resolvconf is not present the issue doesn't happen

OS

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Version of Ansible

ansible [core 2.16.14]
  config file = /home/brbik/github/infra/kubespray-2.23.0/ansible.cfg
  configured module search path = ['/home/brbik/github/infra/kubespray-2.23.0/library']
  ansible python module location = /home/brbik/github/infra/kubespray-2.23.0/venv/lib/python3.13/site-packages/ansible
  ansible collection location = /home/brbik/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/brbik/github/infra/kubespray-2.23.0/venv/bin/ansible
  python version = 3.13.1 (main, Dec  4 2024, 18:05:56) [GCC 14.2.1 20240910] (/home/brbik/github/infra/kubespray-2.23.0/venv/bin/python3)
  jinja version = 3.1.5
  libyaml = Tru

Version of Python

Python 3.13.1

Version of Kubespray (commit)

7d14c42

Network plugin used

calico

Full inventory with variables

[all]
master-0 ansible_host=192.168.8.10 ip=192.168.8.10
master-1 ansible_host=192.168.8.11 ip=192.168.8.11
master-2 ansible_host=192.168.8.12 ip=192.168.8.12
worker-0 ansible_host=192.168.8.20 ip=192.168.8.20
worker-1 ansible_host=192.168.8.21 ip=192.168.8.21
worker-2 ansible_host=192.168.8.22 ip=192.168.8.22

[etcd]
master-0
master-1
master-2

[kube_control_plane]
master-0
master-1
master-2

[kube_node]
worker-0
worker-1
worker-2

[calico_rr]

[k8s_cluster:children]
kube_control_plane
kube_node
calico_rr

variables are pretty much default just with cloud_provider: external and kube_oidc_auth enabled

Command used to invoke ansible

ansible-playbook -i inventory.ini -b -u root upgrade-cluster.yaml -e upgrade_node_confirm=true -e system_upgrade=true

Output of ansible run

Ansible runs successfully but nodes start having network issues when the dhcp lease expires

Anything else we need to know

I can submit a PR for this. I have it already fixed locally.

@kyrbrbik kyrbrbik added the kind/bug Categorizes issue or PR as related to a bug. label Jan 27, 2025
@VannTen
Copy link
Contributor

VannTen commented Jan 28, 2025

Should the arguments be always quoted, or only when it's domain names ? If always quoting works, it's simpler to do that

@kyrbrbik
Copy link
Contributor Author

I'm pretty sure that the name servers need to be unquoted. It's not very pretty but you can just add an if statement to 0100-dhclient-hooks.yml

block: |-
       {% for key, val in dhclient_supersede.items() | rejectattr(1, '==', []) -%}
       {% if key == "domain-name-servers" -%}
       supersede {{ key }} {{ val | join(',') }};
       {% else -%}
       supersede {{ key }} "{{ val | join('","') }}";
       {% endif -%}
       {% endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants