Jelajahi Sumber

Bring first etcd server up before others.

In faster environments (i.e. all local VMs) etcd nodes could come online at
roughly the same time leading to conflicts with self-elections, resulting in a
non-functional cluster.

To solve we configure the first etcd host by itself, then configure the
remaining ones in parallel to keep things as fast as possible.
Devan Goodwin 9 tahun lalu
induk
melakukan
bee65e693b
1 mengubah file dengan 26 tambahan dan 2 penghapusan
  1. 26 2
      playbooks/common/openshift-etcd/config.yml

+ 26 - 2
playbooks/common/openshift-etcd/config.yml

@@ -68,8 +68,32 @@
       validate_checksum: yes
     with_items: etcd_needing_server_certs
 
-- name: Configure etcd hosts
-  hosts: oo_etcd_to_config
+# Configure a first etcd host to avoid conflicts in choosing a leader
+# if other members come online too quickly.
+- name: Configure first etcd host
+  hosts: oo_first_etcd
+  vars:
+    sync_tmpdir: "{{ hostvars.localhost.g_etcd_mktemp.stdout }}"
+    etcd_url_scheme: https
+    etcd_peer_url_scheme: https
+    etcd_peers_group: oo_etcd_to_config
+  pre_tasks:
+  - name: Ensure certificate directory exists
+    file:
+      path: "{{ etcd_cert_config_dir }}"
+      state: directory
+  - name: Unarchive the tarball on the etcd host
+    unarchive:
+      src: "{{ sync_tmpdir }}/{{ etcd_cert_subdir }}.tgz"
+      dest: "{{ etcd_cert_config_dir }}"
+    when: etcd_server_certs_missing
+  roles:
+  - etcd
+  - role: nickhammond.logrotate
+
+# Configure the remaining etcd hosts, skipping the first one we dealt with above.
+- name: Configure remaining etcd hosts
+  hosts: oo_etcd_to_config:!oo_first_etcd
   vars:
     sync_tmpdir: "{{ hostvars.localhost.g_etcd_mktemp.stdout }}"
     etcd_url_scheme: https