Browse Source

More docker upgrade fixes.

Devan Goodwin 8 years ago
parent
commit
f004b52607

+ 7 - 5
playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml

@@ -12,7 +12,8 @@
       msg: Cannot upgrade Docker on Atomic hosts
     when: openshift.common.is_atomic | bool
 
-  - include: ../../../common/openshift-cluster/upgrades/docker/upgrade_check-yml
+  - include: ../../../../common/openshift-cluster/upgrades/docker/upgrade_check.yml
+    when: docker_upgrade is not defined or docker_upgrade | bool
 
 
 # If a node fails, halt everything, the admin will need to clean up and we
@@ -27,20 +28,21 @@
     command: >
       {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --schedulable=false
     delegate_to: "{{ groups.oo_first_master.0 }}"
-    when: docker_upgrade is defined and docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config
+    when: l_docker_upgrade is defined and l_docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config
 
   - name: Evacuate Node for Kubelet upgrade
     command: >
       {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --evacuate --force
     delegate_to: "{{ groups.oo_first_master.0 }}"
-    when: docker_upgrade is defined and docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config
+    when: l_docker_upgrade is defined and l_docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config
 
-  - include: ../../../common/openshift-cluster/upgrades/docker/upgrade.yml
+  - include: ../../../../common/openshift-cluster/upgrades/docker/upgrade.yml
+    when: l_docker_upgrade is defined and l_docker_upgrade | bool
 
   - name: Set node schedulability
     command: >
       {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --schedulable=true
     delegate_to: "{{ groups.oo_first_master.0 }}"
     when: openshift.node.schedulable | bool
-    when: docker_upgrade is defined and docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config and openshift.node.schedulable | bool
+    when: l_docker_upgrade is defined and l_docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config and openshift.node.schedulable | bool
 

+ 4 - 5
playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml

@@ -11,16 +11,15 @@
     - etcd_container
     - openvswitch
   failed_when: false
-  when: docker_upgrade | bool and openshift.common.is_containerized | bool
+  when: openshift.common.is_containerized | bool
 
 - name: Remove all containers and images
   script: nuke_images.sh docker
   register: nuke_images_result
-  when: docker_upgrade | bool and docker_upgrade_nuke_images is defined and docker_upgrade_nuke_images | bool
+  when: docker_upgrade_nuke_images is defined and docker_upgrade_nuke_images | bool
 
 - name: Upgrade Docker
   action: "{{ ansible_pkg_mgr }} name=docker{{ '-' + docker_version }} state=present"
-  when: docker_upgrade | bool
 
 - name: Restart containerized services
   service: name={{ item }} state=started
@@ -32,7 +31,7 @@
     - "{{ openshift.common.service_type }}-master-controllers"
     - "{{ openshift.common.service_type }}-node"
   failed_when: false
-  when: docker_upgrade | bool and openshift.common.is_containerized | bool
+  when: openshift.common.is_containerized | bool
 
 - name: Wait for master API to come back online
   become: no
@@ -42,4 +41,4 @@
       state=started
       delay=10
       port="{{ openshift.master.api_port }}"
-  when: docker_upgrade | bool and inventory_hostname in groups.oo_masters_to_config
+  when: inventory_hostname in groups.oo_masters_to_config

+ 12 - 16
playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml

@@ -1,13 +1,11 @@
 ---
 
-# This snippet determines if docker_upgrade should be set for the host. If it's already
-# set via the inventory we will respect it. Otherwise we check if the current version
-# is equal to the either the latest, or the requested docker_version, and set
-# docker_upgrade accordingly.
+# This snippet determines if a Docker upgrade is required by checking the inventory
+# variables, the available packages, and sets l_docker_version to True if so.
 
-- name: Determine available Docker version
-  script: ../../../../common/openshift-cluster/upgrades/files/rpm_versions.sh docker
-  register: g_docker_version_result
+- set_fact:
+    docker_upgrade: True
+  when: docker_upgrade is not defined
 
 - name: Check if Docker is installed
   command: rpm -q docker
@@ -32,24 +30,22 @@
   # Disable the 1.10 requirement if the user set a specific Docker version
   when: avail_docker_version.stdout | version_compare('1.10','<') and docker_version is not defined
 
-# We respect docker_upgrade=False in the inventory, but True is the default and
-# if set in inventory, we still flip it to False here and only set to true if
-# they're not already running the required version.
+# Default l_docker_upgrade to False, we'll set to True if an upgrade is required:
 - set_fact:
-    docker_upgrade: False
-  when: docker_upgrade is not defined or docker_upgrade | bool
+    l_docker_upgrade: False
 
 # Make sure a docker_verison is set if none was requested:
 - set_fact:
-    docker_version: avail_docker_version.stdout
+    docker_version: "{{ avail_docker_version.stdout }}"
   when: docker_version is not defined
 
 - name: Flag for Docker upgrade if necessary
   set_fact:
-    docker_upgrade: True
-  when: docker_version is defined and pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(docker_version,'<')
+    l_docker_upgrade: True
+  when: pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(docker_version,'<')
 
 - name: Flag to delete all images prior to upgrade if crossing Docker 1.10 boundary
   set_fact:
       docker_upgrade_nuke_images: True
-  when: docker_upgrade_nuke_images is not defined and docker_upgrade | bool and curr_docker_version.stdout | version_compare('1.10','<') and docker_version | version_compare('1.10','>=')
+  when: docker_upgrade_nuke_images is not defined and curr_docker_version.stdout | version_compare('1.10','<') and docker_version | version_compare('1.10','>=')
+

+ 1 - 1
playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml

@@ -86,7 +86,7 @@
     when: docker_upgrade is not defined or docker_upgrade | bool
 
   - include: ../docker/upgrade.yml
-    when: docker_upgrade | bool
+    when: l_docker_upgrade is defined and l_docker_upgrade | bool
 
   - include: rpm_upgrade.yml
     vars: