Przeglądaj źródła

Make openshift_control_plane/check_master_api_is_ready.yml generic

Scott Dodson 6 lat temu
rodzic
commit
de6873067d

+ 10 - 32
roles/openshift_control_plane/tasks/check_master_api_is_ready.yml

@@ -1,47 +1,25 @@
 ---
 ---
-- name: Wait for API to become available
-  # Using curl here since the uri module requires python-httplib2 and
-  # wait_for port doesn't provide health information.
+- name: Wait for APIs to become available
   command: >
   command: >
-    curl --silent --tlsv1.2 --max-time 2
-    --cacert {{ openshift.common.config_base }}/master/ca-bundle.crt
-    {{ openshift.master.api_url }}/healthz/ready
-  register: l_api_available_output
-  until: l_api_available_output.stdout == 'ok'
-  retries: 120
-  delay: 1
-  run_once: true
-  changed_when: false
-  failed_when: false
-
-- name: "Collect verbose curl output when API didn't become available"
-  command: >-
-    curl --verbose --tlsv1.2
-    --cacert {{ openshift.common.config_base }}/master/ca-bundle.crt
-    {{ openshift.master.api_url }}/healthz/ready
-  register: l_api_available_verbose_output
-  failed_when: false
+    {{ openshift_client_binary }} get --raw /apis/{{ item }}/v1
+  register: openshift_apis
+  until: openshift_apis.rc == 0
+  with_items: "{{ l_core_api_list }}"
+  retries: 60
+  delay: 5
 
 
 - name: "Collect API logs when API didn't become available"
 - name: "Collect API logs when API didn't become available"
   command: journalctl --no-pager -n 100 -u {{ openshift_service_type }}-master-api
   command: journalctl --no-pager -n 100 -u {{ openshift_service_type }}-master-api
   register: l_api_log_output
   register: l_api_log_output
-  when:
-  - l_api_available_output.stdout != 'ok'
-
-- name: "Dump verbose curl output when the API didn't become available"
-  debug:
-    msg: "{{ l_api_available_verbose_output.stderr_lines }}"
-  when: l_api_available_output.stdout != 'ok'
+  when: openshift_apis is failed
 
 
 - name: "Dump API logs when the API didn't become availabale"
 - name: "Dump API logs when the API didn't become availabale"
   debug:
   debug:
     msg: "{{ l_api_log_output.stdout_lines }}"
     msg: "{{ l_api_log_output.stdout_lines }}"
-  when:
-  - l_api_available_output.stdout != 'ok'
+  when: openshift_apis is failed
 
 
 - fail:
 - fail:
     msg: >
     msg: >
       API did not become available. Verbose curl output and API logs
       API did not become available. Verbose curl output and API logs
       have been collected above to assist with debugging.
       have been collected above to assist with debugging.
-  when:
-  - l_api_available_output.stdout != 'ok'
+  when: openshift_apis is failed

+ 1 - 8
roles/openshift_control_plane/tasks/main.yml

@@ -320,14 +320,7 @@
     fail:
     fail:
       msg: Control plane pods didn't pass health check
       msg: Control plane pods didn't pass health check
 
 
-- name: Wait for Openshift APIs to register themselves
-  command: >
-    {{ openshift_client_binary }} get --raw /apis/{{ item }}/v1
-  register: openshift_apis
-  until: openshift_apis.rc == 0
-  with_items: "{{ l_core_api_list }}"
-  retries: 60
-  delay: 5
+- import_tasks: check_master_api_is_ready.yml
 
 
 - name: Remove oc cache to refresh a list of APIs
 - name: Remove oc cache to refresh a list of APIs
   file:
   file: