Show logs when indices not found

Sometimes CI job are failing because the Gearman service
is not up.
Also changed url for checking indices from localhost to 0.0.0.0.

Change-Id: I69f4345f35c19a72048a842ef8a1360be75bb1e6
This commit is contained in:
Daniel Pawlik
2022-03-10 10:38:42 +01:00
parent f9acf16ba2
commit 7f8e4d1b6d
2 changed files with 118 additions and 49 deletions

View File

@@ -89,34 +89,65 @@
register: _service_status
failed_when: _service_status.rc != 0
# FIXME: The index is created on the beginning of the logsender work.
# The playbook should validate if some data has been pushed to the ES.
- name: Get Opensearch indices
uri:
url: "https://localhost:9200/_cat/indices"
user: "admin"
password: "admin"
force_basic_auth: true
method: GET
validate_certs: false
status_code: "200"
return_content: true
register: _opensearch_indices
until: "'logstash-logscraper' in _opensearch_indices.content"
retries: 30
delay: 10
block:
- name: Get indices
uri:
url: "https://0.0.0.0:9200/_cat/indices"
user: "admin"
password: "admin"
force_basic_auth: true
method: GET
validate_certs: false
status_code: "200"
return_content: true
register: _opensearch_indices
until: "'logstash-logscraper' in _opensearch_indices.content"
retries: 30
delay: 10
- name: Check if build_branch exists in index content
uri:
url: "https://localhost:9200/logstash-logscraper"
user: "admin"
password: "admin"
force_basic_auth: true
method: GET
validate_certs: false
status_code: "200"
return_content: true
register: _opensearch_index_content
until: "'build_branch' in _opensearch_index_content.content"
retries: 30
delay: 10
- name: Check if build_branch exists in index content
uri:
url: "https://0.0.0.0:9200/logstash-logscraper"
user: "admin"
password: "admin"
force_basic_auth: true
method: GET
validate_certs: false
status_code: "200"
return_content: true
register: _opensearch_index_content
until: "'build_branch' in _opensearch_index_content.content"
retries: 30
delay: 10
rescue:
- name: List all podman containers
shell: |
podman ps -a
- name: Get opensearch logs
shell: |
podman logs opensearch
- name: Get logscraper logs
shell: |
podman logs logscraper-openstack
- name: Get logsender logs
shell: |
podman logs logsender-openstack
- name: Get indices to fail the test
uri:
url: "https://0.0.0.0:9200/_cat/indices"
user: "admin"
password: "admin"
force_basic_auth: true
method: GET
validate_certs: false
status_code: "200"
return_content: true
register: _opensearch_indices
until: "'logstash-logscraper' in _opensearch_indices.content"
retries: 3
delay: 10

View File

@@ -142,6 +142,13 @@
meta: flush_handlers
### service validation ###
- name: Check if log gearman client is listening
wait_for:
host: "{{ gearman_host }}"
port: "{{ gearman_port }}"
delay: 10
timeout: 300
- name: Ensure that all services are available and running
shell: |
systemctl is-active -q {{ item }}
@@ -152,24 +159,55 @@
register: _service_status
failed_when: _service_status.rc != 0
- name: Check if log gearman client is listening
wait_for:
host: "{{ gearman_host }}"
port: "{{ gearman_port }}"
delay: 10
timeout: 300
- name: Get Opensearch indices
uri:
url: "https://localhost:9200/_cat/indices"
user: "admin"
password: "admin"
force_basic_auth: true
method: GET
validate_certs: false
status_code: "200"
return_content: true
register: _opensearch_indices
until: "'logstash-logscraper' in _opensearch_indices.content"
retries: 30
delay: 10
block:
- name: Get indices
uri:
url: "https://0.0.0.0:9200/_cat/indices"
user: "admin"
password: "admin"
force_basic_auth: true
method: GET
validate_certs: false
status_code: "200"
return_content: true
register: _opensearch_indices
until: "'logstash-logscraper' in _opensearch_indices.content"
retries: 30
delay: 10
rescue:
- name: List all podman containers
shell: |
podman ps -a
- name: Get logstash logs
shell: |
podman logs logstash
- name: Get opensearch logs
shell: |
podman logs opensearch
- name: Get gearman client logs
shell: |
podman logs loggearman-client
- name: Get gearman worker logs
shell: |
podman logs loggearman-worker
- name: Get indices to fail the test
uri:
url: "https://0.0.0.0:9200/_cat/indices"
user: "admin"
password: "admin"
force_basic_auth: true
method: GET
validate_certs: false
status_code: "200"
return_content: true
register: _opensearch_indices
until: "'logstash-logscraper' in _opensearch_indices.content"
retries: 3
delay: 10