Browse Source

Merge pull request #6193 from mgugino-upstream-stage/etc-runtime

Cleanup etcd runtime variable.
Michael Gugino 7 years ago
parent
commit
4f83051b3b

+ 0 - 2
playbooks/common/openshift-cluster/redeploy-certificates/etcd-ca.yml

@@ -41,7 +41,6 @@
       name: etcd
       tasks_from: distribute_ca
     vars:
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
       etcd_sync_cert_dir: "{{ hostvars['localhost'].g_etcd_mktemp.stdout }}"
       etcd_ca_host: "{{ groups.oo_etcd_to_config.0 }}"
 
@@ -60,7 +59,6 @@
       tasks_from: retrieve_ca_certificates
     vars:
       etcd_sync_cert_dir: "{{ hostvars['localhost'].g_etcd_mktemp.stdout }}"
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
 
 - name: Distribute etcd CA to masters
   hosts: oo_masters_to_config

+ 0 - 1
playbooks/common/openshift-cluster/upgrades/etcd/backup.yml

@@ -9,7 +9,6 @@
       tasks_from: backup
     vars:
       r_etcd_common_backup_tag: "{{ etcd_backup_tag }}"
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
       r_etcd_common_embedded_etcd: "{{ groups.oo_etcd_to_config | default([]) | length == 0 }}"
       r_etcd_common_backup_sufix_name: "{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}"
 

+ 3 - 55
playbooks/common/openshift-cluster/upgrades/etcd/upgrade.yml

@@ -2,60 +2,9 @@
 - name: Determine etcd version
   hosts: oo_etcd_hosts_to_upgrade
   tasks:
-  - block:
-    - name: Record RPM based etcd version
-      command: rpm -qa --qf '%{version}' etcd\*
-      args:
-        warn: no
-      register: etcd_rpm_version
-      failed_when: false
-      # AUDIT:changed_when: `false` because we are only inspecting
-      # state, not manipulating anything
-      changed_when: false
-    - debug:
-        msg: "Etcd rpm version {{ etcd_rpm_version.stdout }} detected"
-    when:
-    - not openshift.common.is_containerized | bool
-
-  - block:
-    - name: Record containerized etcd version (docker)
-      command: docker exec etcd_container rpm -qa --qf '%{version}' etcd\*
-      register: etcd_container_version_docker
-      failed_when: false
-      # AUDIT:changed_when: `false` because we are only inspecting
-      # state, not manipulating anything
-      changed_when: false
-      when:
-      - not openshift.common.is_etcd_system_container | bool
-
-      # Given a register variables is set even if the whwen condition
-      # is false, we need to set etcd_container_version separately
-    - set_fact:
-        etcd_container_version: "{{ etcd_container_version_docker.stdout }}"
-      when:
-      - not openshift.common.is_etcd_system_container | bool
-
-    - name: Record containerized etcd version (runc)
-      command: runc exec etcd rpm -qa --qf '%{version}' etcd\*
-      register: etcd_container_version_runc
-      failed_when: false
-      # AUDIT:changed_when: `false` because we are only inspecting
-      # state, not manipulating anything
-      changed_when: false
-      when:
-      - openshift.common.is_etcd_system_container | bool
-
-      # Given a register variables is set even if the whwen condition
-      # is false, we need to set etcd_container_version separately
-    - set_fact:
-        etcd_container_version: "{{ etcd_container_version_runc.stdout }}"
-      when:
-      - openshift.common.is_etcd_system_container | bool
-
-    - debug:
-        msg: "Etcd containerized version {{ etcd_container_version }} detected"
-    when:
-    - openshift.common.is_containerized | bool
+  - include_role:
+      name: etcd
+      tasks_from: version_detect.yml
 
 - include: upgrade_rpm_members.yml
   vars:
@@ -109,7 +58,6 @@
       name: etcd
       tasks_from: upgrade_image
     vars:
-      r_etcd_common_etcd_runtime: "host"
       etcd_peer: "{{ openshift.common.hostname }}"
     when:
     - ansible_distribution == 'Fedora'

+ 0 - 1
playbooks/common/openshift-cluster/upgrades/etcd/upgrade_image_members.yml

@@ -11,7 +11,6 @@
       tasks_from: upgrade_image
     vars:
       r_etcd_upgrade_version: "{{ etcd_upgrade_version }}"
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
       etcd_peer: "{{ openshift.common.hostname }}"
     when:
     - etcd_container_version | default('99') | version_compare(etcd_upgrade_version,'<')

+ 0 - 1
playbooks/common/openshift-cluster/upgrades/etcd/upgrade_rpm_members.yml

@@ -11,7 +11,6 @@
       tasks_from: upgrade_rpm
     vars:
       r_etcd_upgrade_version: "{{ etcd_upgrade_version }}"
-      r_etcd_common_etcd_runtime: "host"
       etcd_peer: "{{ openshift.common.hostname }}"
     when:
     - etcd_rpm_version.stdout | default('99') | version_compare(etcd_upgrade_version, '<')

+ 0 - 7
playbooks/init/facts.yml

@@ -31,11 +31,6 @@
       l_is_containerized: "{{ (l_is_atomic | bool) or (containerized | default(false) | bool) }}"
       l_is_openvswitch_system_container: "{{ (openshift_use_openvswitch_system_container | default(openshift_use_system_containers | default(false)) | bool) }}"
       l_is_master_system_container: "{{ (openshift_use_master_system_container | default(openshift_use_system_containers | default(false)) | bool) }}"
-      l_is_etcd_system_container: "{{ (openshift_use_etcd_system_container | default(openshift_use_system_containers | default(false)) | bool) }}"
-
-  - name: initialize_facts set fact for l_etcd_runtime
-    set_fact:
-      l_etcd_runtime: "{{ 'runc' if l_is_etcd_system_container else 'docker' if l_is_containerized else 'host' }}"
 
   # TODO: Should this be moved into health checks??
   # Seems as though any check that happens with a corresponding fail should move into health_checks
@@ -134,8 +129,6 @@
         is_containerized: "{{ l_is_containerized | default(None) }}"
         is_openvswitch_system_container: "{{ l_is_openvswitch_system_container | default(false) }}"
         is_master_system_container: "{{ l_is_master_system_container | default(false) }}"
-        is_etcd_system_container: "{{ l_is_etcd_system_container | default(false) }}"
-        etcd_runtime: "{{ l_etcd_runtime }}"
         system_images_registry: "{{ system_images_registry }}"
         public_hostname: "{{ openshift_public_hostname | default(None) }}"
         public_ip: "{{ openshift_public_ip | default(None) }}"

+ 0 - 1
playbooks/openshift-etcd/private/config.yml

@@ -24,7 +24,6 @@
     etcd_peers: "{{ groups.oo_etcd_to_config | default([], true) }}"
     etcd_ca_host: "{{ groups.oo_etcd_to_config.0 }}"
     etcd_certificates_etcd_hosts: "{{ groups.oo_etcd_to_config | default([], true) }}"
-    r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
   - role: nickhammond.logrotate
 
 - name: etcd Install Checkpoint End

+ 0 - 10
playbooks/openshift-etcd/private/embedded2external.yml

@@ -36,7 +36,6 @@
       name: etcd
       tasks_from: backup
     vars:
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
       r_etcd_common_backup_tag: pre-migrate
       r_etcd_common_embedded_etcd: "{{ true }}"
       r_etcd_common_backup_sufix_name: "{{ embedded_etcd_backup_suffix }}"
@@ -45,7 +44,6 @@
       name: etcd
       tasks_from: backup.archive
     vars:
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
       r_etcd_common_backup_tag: pre-migrate
       r_etcd_common_embedded_etcd: "{{ true }}"
       r_etcd_common_backup_sufix_name: "{{ embedded_etcd_backup_suffix }}"
@@ -78,13 +76,9 @@
   - include_role:
       name: etcd
       tasks_from: disable_etcd
-    vars:
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
   - include_role:
       name: etcd
       tasks_from: clean_data
-    vars:
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
 
 # 6. copy the embedded etcd backup to the external host
 # TODO(jchaloup): if the etcd and first master are on the same host, just copy the directory
@@ -101,7 +95,6 @@
       name: etcd
       tasks_from: backup.fetch
     vars:
-      r_etcd_common_etcd_runtime: "{{ hostvars[groups.oo_first_master.0].openshift.common.etcd_runtime }}"
       etcd_backup_sync_directory: "{{ g_etcd_client_mktemp.stdout }}"
       r_etcd_common_backup_tag: pre-migrate
       r_etcd_common_embedded_etcd: "{{ true }}"
@@ -112,7 +105,6 @@
       name: etcd
       tasks_from: backup.copy
     vars:
-      r_etcd_common_etcd_runtime: "{{ hostvars[groups.oo_etcd_to_config.0].openshift.common.etcd_runtime }}"
       etcd_backup_sync_directory: "{{ g_etcd_client_mktemp.stdout }}"
       r_etcd_common_backup_tag: pre-migrate
       r_etcd_common_backup_sufix_name: "{{ hostvars[groups.oo_first_master.0].embedded_etcd_backup_suffix }}"
@@ -134,7 +126,6 @@
       name: etcd
       tasks_from: backup.unarchive
     vars:
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
       r_etcd_common_backup_tag: pre-migrate
       r_etcd_common_backup_sufix_name: "{{ hostvars[groups.oo_first_master.0].embedded_etcd_backup_suffix }}"
 
@@ -142,7 +133,6 @@
       name: etcd
       tasks_from: backup.force_new_cluster
     vars:
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
       r_etcd_common_backup_tag: pre-migrate
       r_etcd_common_backup_sufix_name: "{{ hostvars[groups.oo_first_master.0].embedded_etcd_backup_suffix }}"
       etcd_peer: "{{ openshift.common.ip }}"

+ 0 - 1
playbooks/openshift-etcd/private/master_etcd_certificates.yml

@@ -10,5 +10,4 @@
       etcd_cert_config_dir: "{{ openshift.common.config_base }}/master"
       etcd_cert_prefix: "master.etcd-"
       openshift_ca_host: "{{ groups.oo_first_master.0 }}"
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
       when: groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config

+ 0 - 3
playbooks/openshift-etcd/private/migrate.yml

@@ -48,7 +48,6 @@
       name: etcd
       tasks_from: backup
     vars:
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
       r_etcd_common_backup_tag: pre-migration
       r_etcd_common_embedded_etcd: "{{ groups.oo_etcd_to_config | default([]) | length == 0 }}"
       r_etcd_common_backup_sufix_name: "{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}"
@@ -76,8 +75,6 @@
   - include_role:
       name: etcd
       tasks_from: disable_etcd
-    vars:
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
 
 - name: Migrate data on first etcd
   hosts: oo_etcd_to_migrate[0]

+ 6 - 14
playbooks/openshift-etcd/private/restart.yml

@@ -3,25 +3,17 @@
   hosts: oo_etcd_to_config
   serial: 1
   tasks:
-    - name: restart etcd
-      service:
-        name: "{{ 'etcd_container' if openshift.common.etcd_runtime == 'docker' else 'etcd' }}"
-        state: restarted
+    - include_role:
+        name: etcd
+        tasks_from: restart.yml
       when:
         - not g_etcd_certificates_expired | default(false) | bool
 
 - name: Restart etcd
   hosts: oo_etcd_to_config
   tasks:
-    - name: stop etcd
-      service:
-        name: "{{ 'etcd_container' if openshift.common.etcd_runtime == 'docker' else 'etcd' }}"
-        state: stopped
-      when:
-        - g_etcd_certificates_expired | default(false) | bool
-    - name: start etcd
-      service:
-        name: "{{ 'etcd_container' if openshift.common.etcd_runtime == 'docker' else 'etcd' }}"
-        state: started
+    - include_role:
+        name: etcd
+        tasks_from: restart.yml
       when:
         - g_etcd_certificates_expired | default(false) | bool

+ 0 - 2
playbooks/openshift-etcd/private/scaleup.yml

@@ -36,7 +36,6 @@
     vars:
       etcd_peers: "{{ groups.oo_new_etcd_to_config | default([], true) }}"
       etcd_certificates_etcd_hosts: "{{ groups.oo_new_etcd_to_config | default([], true) }}"
-      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
   roles:
   - role: os_firewall
     when: etcd_add_check.rc == 0
@@ -48,7 +47,6 @@
     etcd_initial_cluster_state: "existing"
     etcd_initial_cluster: "{{ etcd_add_check.stdout_lines[3] | regex_replace('ETCD_INITIAL_CLUSTER=','') | regex_replace('\"','') }}"
     etcd_ca_setup: False
-    r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
   - role: nickhammond.logrotate
     when: etcd_add_check.rc == 0
   post_tasks:

+ 0 - 1
playbooks/openshift-etcd/private/server_certificates.yml

@@ -12,4 +12,3 @@
         etcd_ca_host: "{{ groups.oo_etcd_to_config.0 }}"
         etcd_peers: "{{ groups.oo_etcd_to_config | default([], true) }}"
         etcd_certificates_etcd_hosts: "{{ groups.oo_etcd_to_config | default([], true) }}"
-        r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"

+ 3 - 1
roles/etcd/defaults/main.yaml

@@ -2,8 +2,10 @@
 r_etcd_common_backup_tag: ''
 r_etcd_common_backup_sufix_name: ''
 
+l_is_etcd_system_container: "{{ (openshift_use_etcd_system_container | default(openshift_use_system_containers | default(false)) | bool) }}"
+
 # runc, docker, host
-r_etcd_common_etcd_runtime: "docker"
+r_etcd_common_etcd_runtime: "{{ 'runc' if l_is_etcd_system_container else 'docker' if l_is_containerized else 'host' }}"
 r_etcd_common_embedded_etcd: false
 
 osm_etcd_image: 'registry.access.redhat.com/rhel7/etcd'

+ 4 - 4
roles/etcd/tasks/main.yml

@@ -30,7 +30,7 @@
       src: etcd.docker.service
   when:
   - etcd_is_containerized | bool
-  - not openshift.common.is_etcd_system_container | bool
+  - not l_is_etcd_system_container | bool
 
 # Start secondary etcd instance for third party integrations
 # TODO: Determine an alternative to using thirdparty variable
@@ -90,7 +90,7 @@
       enabled: no
       masked: yes
       daemon_reload: yes
-    when: not openshift.common.is_etcd_system_container | bool
+    when: not l_is_etcd_system_container | bool
     register: task_result
     failed_when: task_result|failed and 'could not' not in task_result.msg|lower
 
@@ -98,11 +98,11 @@
     template:
       dest: "/etc/systemd/system/etcd_container.service"
       src: etcd.docker.service
-    when: not openshift.common.is_etcd_system_container | bool
+    when: not l_is_etcd_system_container | bool
 
   - name: Install Etcd system container
     include: system_container.yml
-    when: openshift.common.is_etcd_system_container | bool
+    when: l_is_etcd_system_container | bool
   when: etcd_is_containerized | bool
 
 - name: Validate permissions on the config dir

+ 21 - 0
roles/etcd/tasks/restart.yml

@@ -0,0 +1,21 @@
+---
+
+- name: restart etcd
+  service:
+    name: "{{ etcd_service }}"
+    state: restarted
+  when:
+    - not g_etcd_certificates_expired | default(false) | bool
+
+- name: stop etcd
+  service:
+    name: "{{ etcd_service }}"
+    state: stopped
+  when:
+    - g_etcd_certificates_expired | default(false) | bool
+- name: start etcd
+  service:
+    name: "{{ etcd_service }}"
+    state: started
+  when:
+    - g_etcd_certificates_expired | default(false) | bool

+ 55 - 0
roles/etcd/tasks/version_detect.yml

@@ -0,0 +1,55 @@
+---
+- block:
+  - name: Record RPM based etcd version
+    command: rpm -qa --qf '%{version}' etcd\*
+    args:
+      warn: no
+    register: etcd_rpm_version
+    failed_when: false
+    # AUDIT:changed_when: `false` because we are only inspecting
+    # state, not manipulating anything
+    changed_when: false
+  - debug:
+      msg: "Etcd rpm version {{ etcd_rpm_version.stdout }} detected"
+  when:
+  - not openshift.common.is_containerized | bool
+
+- block:
+  - name: Record containerized etcd version (docker)
+    command: docker exec etcd_container rpm -qa --qf '%{version}' etcd\*
+    register: etcd_container_version_docker
+    failed_when: false
+    # AUDIT:changed_when: `false` because we are only inspecting
+    # state, not manipulating anything
+    changed_when: false
+    when:
+    - not l_is_etcd_system_container | bool
+
+    # Given a register variables is set even if the whwen condition
+    # is false, we need to set etcd_container_version separately
+  - set_fact:
+      etcd_container_version: "{{ etcd_container_version_docker.stdout }}"
+    when:
+    - not l_is_etcd_system_container | bool
+
+  - name: Record containerized etcd version (runc)
+    command: runc exec etcd rpm -qa --qf '%{version}' etcd\*
+    register: etcd_container_version_runc
+    failed_when: false
+    # AUDIT:changed_when: `false` because we are only inspecting
+    # state, not manipulating anything
+    changed_when: false
+    when:
+    - l_is_etcd_system_container | bool
+
+    # Given a register variables is set even if the whwen condition
+    # is false, we need to set etcd_container_version separately
+  - set_fact:
+      etcd_container_version: "{{ etcd_container_version_runc.stdout }}"
+    when:
+    - l_is_etcd_system_container | bool
+
+  - debug:
+      msg: "Etcd containerized version {{ etcd_container_version }} detected"
+  when:
+  - openshift.common.is_containerized | bool