summaryrefslogtreecommitdiffstats
path: root/roles/etcd_migrate/tasks/check.yml
diff options
context:
space:
mode:
authorOpenShift Bot <eparis+openshiftbot@redhat.com>2017-06-18 19:25:04 -0400
committerGitHub <noreply@github.com>2017-06-18 19:25:04 -0400
commitd7be27f7f9321099e52b54afcce2308ac1e1671f (patch)
treedd840473d179259b098d651da0ad73bb642901ce /roles/etcd_migrate/tasks/check.yml
parente2840e8ab50215eb7603a832f2f729d873e5a811 (diff)
parent0fc47e5030577479be08126818dd2b5b5ccdf995 (diff)
downloadopenshift-d7be27f7f9321099e52b54afcce2308ac1e1671f.tar.gz
openshift-d7be27f7f9321099e52b54afcce2308ac1e1671f.tar.bz2
openshift-d7be27f7f9321099e52b54afcce2308ac1e1671f.tar.xz
openshift-d7be27f7f9321099e52b54afcce2308ac1e1671f.zip
Merge pull request #3954 from ingvagabund/etcd-migrate
Merged by openshift-bot
Diffstat (limited to 'roles/etcd_migrate/tasks/check.yml')
-rw-r--r--roles/etcd_migrate/tasks/check.yml55
1 files changed, 55 insertions, 0 deletions
diff --git a/roles/etcd_migrate/tasks/check.yml b/roles/etcd_migrate/tasks/check.yml
new file mode 100644
index 000000000..2f07713bc
--- /dev/null
+++ b/roles/etcd_migrate/tasks/check.yml
@@ -0,0 +1,55 @@
+---
+# Check the cluster is healthy
+- include: check_cluster_health.yml
+
+# Check if the member has v3 data already
+# Run the migration only if the data are v2
+- name: Check if there are any v3 data
+ command: >
+ etcdctl --cert {{ etcd_peer_cert_file }} --key {{ etcd_peer_key_file }} --cacert {{ etcd_peer_ca_file }} --endpoints 'https://{{ etcd_peer }}:2379' get "" --from-key --keys-only -w json --limit 1
+ environment:
+ ETCDCTL_API: 3
+ register: l_etcdctl_output
+
+- fail:
+ msg: "Unable to get a number of v3 keys"
+ when: l_etcdctl_output.rc != 0
+
+- fail:
+ msg: "The etcd has at least one v3 key"
+ when: "'count' in (l_etcdctl_output.stdout | from_json) and (l_etcdctl_output.stdout | from_json).count != 0"
+
+
+# TODO(jchaloup): once the until loop can be used over include/block,
+# remove the repetive code
+# - until loop not supported over include statement (nor block)
+# https://github.com/ansible/ansible/issues/17098
+# - with_items not supported over block
+
+# Check the cluster status for the first time
+- include: check_cluster_status.yml
+
+# Check the cluster status for the second time
+- block:
+ - debug:
+ msg: "l_etcd_cluster_status_ok: {{ l_etcd_cluster_status_ok }}"
+ - name: Wait a while before another check
+ pause:
+ seconds: 5
+ when: not l_etcd_cluster_status_ok | bool
+
+ - include: check_cluster_status.yml
+ when: not l_etcd_cluster_status_ok | bool
+
+
+# Check the cluster status for the third time
+- block:
+ - debug:
+ msg: "l_etcd_cluster_status_ok: {{ l_etcd_cluster_status_ok }}"
+ - name: Wait a while before another check
+ pause:
+ seconds: 5
+ when: not l_etcd_cluster_status_ok | bool
+
+ - include: check_cluster_status.yml
+ when: not l_etcd_cluster_status_ok | bool