From 29fd9573523a0498b9b4c2e22de50867c4df6c31 Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Thu, 9 Feb 2017 14:33:40 +0300 Subject: [PATCH] Enable weave upgrade from previous versions Raise readiness probe initial time to 60 (was 30) --- .../network_plugin/weave/tasks/main.yml | 4 +- roles/network_plugin/weave/tasks/main.yml | 2 + .../weave/tasks/pre-upgrade.yml | 39 +++++++++++++++++++ .../weave/templates/weave-net.yml.j2 | 2 +- 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 roles/network_plugin/weave/tasks/pre-upgrade.yml diff --git a/roles/kubernetes-apps/network_plugin/weave/tasks/main.yml b/roles/kubernetes-apps/network_plugin/weave/tasks/main.yml index f900e8b09..1c216fd92 100644 --- a/roles/kubernetes-apps/network_plugin/weave/tasks/main.yml +++ b/roles/kubernetes-apps/network_plugin/weave/tasks/main.yml @@ -30,8 +30,8 @@ return_content: yes run_once: true register: weave_status - retries: 10 - delay: "{{ retry_stagger | random + 3 }}" + retries: 12 + delay: 10 until: "{{ weave_status.status == 200 and 'Status: ready' in weave_status.content }}" delegate_to: "{{groups['kube-master'][0]}}" diff --git a/roles/network_plugin/weave/tasks/main.yml b/roles/network_plugin/weave/tasks/main.yml index 5edb837bb..a956b9481 100644 --- a/roles/network_plugin/weave/tasks/main.yml +++ b/roles/network_plugin/weave/tasks/main.yml @@ -1,4 +1,6 @@ --- +- include: pre-upgrade.yml + - name: Weave | Copy cni plugins from hyperkube command: "{{ docker_bin_dir }}/docker run --rm -v /opt/cni/bin:/cnibindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /bin/cp -r /opt/cni/bin/. /cnibindir/" register: cni_task_result diff --git a/roles/network_plugin/weave/tasks/pre-upgrade.yml b/roles/network_plugin/weave/tasks/pre-upgrade.yml new file mode 100644 index 000000000..42a031f45 --- /dev/null +++ b/roles/network_plugin/weave/tasks/pre-upgrade.yml @@ -0,0 +1,39 @@ +- name: Weave pre-upgrade | Stop legacy weave + command: weave stop + failed_when: false + +- name: Weave pre-upgrade | Stop legacy systemd weave services + service: + name: "{{ item }}" + enabled: no + state: stopped + with_items: + - weaveexpose + - weaveproxy + - weave + failed_when: false + +- name: Weave pre-upgrade | Purge legacy systemd weave systemd unit files + file: + path: "{{ item }}" + state: absent + register: purged_weave_systemd_units + with_items: + - "/etc/systemd/system/weaveexpose.service" + - "/etc/systemd/system/weaveproxy.service" + - "/etc/systemd/system/weave.service" + +- name: Weave pre-upgrade | Reload systemd + command: systemctl daemon-reload + when: ansible_service_mgr == "systemd" and purged_weave_systemd_units.changed + +- name: Weave pre-upgrade | Purge legacy weave configs and binary + file: + path: "{{ item }}" + state: absent + with_items: + - "{{ bin_dir }}/weave" + - "/etc/weave.env" + +- name: Weave pre-upgrade | Purge legacy weave docker containers + shell: "docker ps -af 'name=^/weave.*' -q | xargs --no-run-if-empty docker rm -f" diff --git a/roles/network_plugin/weave/templates/weave-net.yml.j2 b/roles/network_plugin/weave/templates/weave-net.yml.j2 index 38f23c359..93b95346d 100644 --- a/roles/network_plugin/weave/templates/weave-net.yml.j2 +++ b/roles/network_plugin/weave/templates/weave-net.yml.j2 @@ -54,7 +54,7 @@ spec: value: {{ weave_expose_ip }} {% endif %} livenessProbe: - initialDelaySeconds: 30 + initialDelaySeconds: 60 httpGet: host: 127.0.0.1 path: /status