Add workaround for restarting network with calico
dhclient needs to be restarted after dhclient.conf is set up, but simple network restart breaks Calico. Extra service restarts work around this problem. This workaround can be removed after calico v2.1 is released and in use. Change-Id: I43596018adbf6ca11a755efa920db997527c0ef2
This commit is contained in:
parent
7026bb045f
commit
f94ed64dc8
|
@ -0,0 +1,52 @@
|
|||
---
|
||||
# NOTE(mattymo): This can be removed after release of Calico 2.1
|
||||
|
||||
- name: Get timestamp from oldest dhclient pid
|
||||
shell: "pgrep -o dhclient | xargs --no-run-if-empty -I{} stat --printf='%Y' /proc/{}"
|
||||
register: oldest_dhclient_time
|
||||
|
||||
- name: check if /etc/dhclient.conf exists
|
||||
stat:
|
||||
path: /etc/dhclient.conf
|
||||
register: dhclient_find_stat
|
||||
|
||||
- name: target dhclient conf file for /etc/dhclient.conf
|
||||
set_fact:
|
||||
dhclientconffile: /etc/dhclient.conf
|
||||
when: dhclient_find_stat.stat.exists
|
||||
|
||||
- name: target dhclient conf file for /etc/dhcp/dhclient.conf
|
||||
set_fact:
|
||||
dhclientconffile: /etc/dhcp/dhclient.conf
|
||||
when: not dhclient_find_stat.stat.exists
|
||||
|
||||
- name: Gather info on dhclient.conf
|
||||
stat:
|
||||
path: "{{ dhclientconffile }}"
|
||||
register: dhclient_stat
|
||||
|
||||
- name: See if oldest dhclient process is older than dhclient.conf
|
||||
set_fact:
|
||||
needs_network_reset: "{{ oldest_dhclient_time.stdout != '' and oldest_dhclient_time.stdout|int < dhclient_stat.stat.mtime }}"
|
||||
|
||||
- name: Calculate number of seconds since dhclient.conf was modified
|
||||
set_fact:
|
||||
mtime_dhclientconf: "{{ ansible_date_time.epoch|int - dhclient_stat.stat.mtime|int }}"
|
||||
|
||||
- name: Set networking service name
|
||||
set_fact:
|
||||
networking_service_name: >-
|
||||
{% if ansible_os_family == "RedHat" -%}
|
||||
network
|
||||
{%- elif ansible_os_family == "Debian" -%}
|
||||
networking
|
||||
{%- endif %}
|
||||
|
||||
- name: Restart networking, kubelet, and docker services
|
||||
shell: "{{ item }}"
|
||||
when: needs_network_reset|bool and inventory_hostname in groups['k8s-cluster']
|
||||
with_items:
|
||||
- systemctl restart {{ networking_service_name }}
|
||||
- killall dhclient --older-than {{ mtime_dhclientconf }}s
|
||||
- docker exec -t -i calico-node killall -HUP calico-felix
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
---
|
||||
- include: dns_fix.yml
|
||||
when: kube_network_plugin in ['canal', 'calico']
|
||||
|
||||
- name: pick dnsmasq cluster IP
|
||||
set_fact:
|
||||
dnsmasq_server: >-
|
||||
|
|
Loading…
Reference in New Issue