Browse Source

Conditionally bind mount /usr/bin/docker-current when it is present (#1941)

* Conditionally bind mount /usr/bin/docker-current when it is present

* fix upgrade

* add atomic-openshift-node-dep files to uninstall playbook

* Fix variable expansion
Scott Dodson 8 years ago
parent
commit
eab842f5b6

+ 5 - 3
playbooks/adhoc/uninstall.yml

@@ -173,12 +173,12 @@
       changed_when: False
       failed_when: False
       with_items: "{{ images_to_delete.results }}"
-    
+
     - name: Remove sdn drop files
-      file: 
+      file:
         path: /run/openshift-sdn
         state: absent
-        
+
     - name: restart docker
       service:
         name: docker
@@ -199,6 +199,7 @@
         - /etc/systemd/system/atomic-openshift-master-api.service
         - /etc/systemd/system/atomic-openshift-master-controllers.service
         - /etc/systemd/system/atomic-openshift-node.service
+        - /etc/systemd/system/atomic-openshift-node-dep.service
         - /etc/systemd/system/etcd_container.service
         - /etc/systemd/system/openvswitch.service
         - /etc/sysconfig/atomic-enterprise-master
@@ -211,6 +212,7 @@
         - /etc/sysconfig/atomic-openshift-node
         - /etc/sysconfig/openshift-master
         - /etc/sysconfig/openshift-node
+        - /etc/sysconfig/openshift-node
         - /etc/sysconfig/openvswitch
         - /etc/sysconfig/origin-master
         - /etc/sysconfig/origin-master-api

+ 1 - 1
playbooks/common/openshift-cluster/upgrades/files/openshift_container_versions.sh

@@ -2,7 +2,7 @@
 
 # Here we don't really care if this is a master, api, controller or node image.
 # We just need to know the version of one of them.
-unit_file=$(ls /etc/systemd/system/${1}*.service | head -n1)
+unit_file=$(ls /etc/systemd/system/${1}*.service | grep -v node-dep | head -n1)
 
 if [ ${1} == "origin" ]; then
     image_name="openshift/origin"

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

@@ -52,7 +52,7 @@
   - name: Update registry image to current version
     when: _default_registry.rc == 0
     command: >
-      {{ oc_cmd }} patch dc/docker-registry -p -n default
+      {{ oc_cmd }} patch dc/docker-registry -n default -p
       '{"spec":{"template":{"spec":{"containers":[{"name":"registry","image":"{{ registry_image }}"}]}}}}'
       --api-version=v1
 

+ 5 - 5
roles/openshift_node/tasks/main.yml

@@ -52,8 +52,9 @@
 
 - name: Reload systemd units
   command: systemctl daemon-reload
-  when: openshift.common.is_containerized | bool and ( ( install_node_result  | changed )
-    or ( install_ovs_sysconfig | changed ) )
+  when: openshift.common.is_containerized | bool and (install_node_result | changed or install_ovs_sysconfig | changed or install_node_dep_result | changed)
+  notify:
+  - restart node
 
 - name: Start and enable openvswitch docker service
   service: name=openvswitch.service enabled=yes state=started
@@ -113,16 +114,15 @@
   service: name={{ openshift.common.service_type }}-node enabled=yes state=started
   register: node_start_result
   ignore_errors: yes
-  
+
 - name: Check logs on failure
   command: journalctl -xe
   register: node_failure
   when: node_start_result | failed
-  
+
 - name: Dump failure information
   debug: var=node_failure
   when: node_start_result | failed
-  
 
 - set_fact:
     node_service_status_changed: "{{ node_start_result | changed }}"

+ 7 - 0
roles/openshift_node/tasks/systemd_units.yml

@@ -1,6 +1,13 @@
 # This file is included both in the openshift_master role and in the upgrade
 # playbooks.
 
+- name: Install Node dependencies docker service file
+  template:
+    dest: "/etc/systemd/system/{{ openshift.common.service_type }}-node-dep.service"
+    src: openshift.docker.node.dep.service
+  register: install_node_dep_result
+  when: openshift.common.is_containerized | bool
+
 - name: Install Node docker service file
   template:
     dest: "/etc/systemd/system/{{ openshift.common.service_type }}-node.service"

+ 11 - 0
roles/openshift_node/templates/openshift.docker.node.dep.service

@@ -0,0 +1,11 @@
+[Unit]
+Requires=docker.service
+After=docker.service
+PartOf={{ openshift.common.service_type }}-node.service
+Before={{ openshift.common.service_type }}-node.service
+
+
+[Service]
+ExecStart=/bin/bash -c "if [[ -f /usr/bin/docker-current ]]; then echo \"DOCKER_ADDTL_BIND_MOUNTS=--volume=/usr/bin/docker-current:/usr/bin/docker-current:ro\" > /etc/sysconfig/{{ openshift.common.service_type }}-node-dep; else echo \"#DOCKER_ADDTL_BIND_MOUNTS=\" > /etc/sysconfig/{{ openshift.common.service_type }}-node-dep; fi"
+ExecStop=
+SyslogIdentifier={{ openshift.common.service_type }}-node-dep

File diff suppressed because it is too large
+ 4 - 1
roles/openshift_node/templates/openshift.docker.node.service