|
13 | 13 | client_cert: "{{ cert_dir }}/tls.crt" |
14 | 14 | client_key: "{{ cert_dir }}/tls.key" |
15 | 15 | ca_path: "{{ cert_dir }}/ca.crt" |
| 16 | + # TODO: Enable validate_certs in production environments |
16 | 17 | validate_certs: false |
17 | 18 | return_content: true |
18 | 19 | body_format: json |
19 | 20 | register: loki_response |
20 | | - # Wait condition |
| 21 | + # Wait for Loki to return all expected log entries |
21 | 22 | until: |
22 | 23 | - loki_response.status == 200 |
23 | 24 | - loki_response.json.status == 'success' |
24 | 25 | - loki_response.json.data.result | length > 0 |
| 26 | + # Verify Loki returned all expected log entries |
25 | 27 | - (loki_response.json.data.result | map(attribute='values') | map('length') | sum) >= (synth_data_rates.data_summary.log_count | int) |
26 | | - retries: 25 |
| 28 | + retries: 20 |
27 | 29 | delay: 60 |
28 | 30 |
|
29 | 31 | - name: "Save Loki Data to JSON file" |
|
47 | 49 | only returned {{ actual_count }} |
48 | 50 | success_msg: "Query returned all data entries. Input file had {{ synth_data_rates.data_summary.log_count }} entries and Loki returned {{ actual_count }}" |
49 | 51 |
|
| 52 | + # Only runs if retrieval was successful |
| 53 | + - name: "Generate chargeback stats from Loki-retrieved data file: {{ scenario_name }}" |
| 54 | + ansible.builtin.command: |
| 55 | + cmd: > |
| 56 | + python3 "{{ cloudkitty_summary_script }}" |
| 57 | + -j "{{ artifacts_dir_zuul }}/{{ scenario_name }}{{ cloudkitty_loki_data_suffix }}" |
| 58 | + -o "{{ artifacts_dir_zuul }}/{{ scenario_name }}{{ cloudkitty_loki_totals_metrics_suffix }}" |
| 59 | + --debug "{{ cloudkitty_debug }}" |
| 60 | + --debug_dir "{{ cloudkitty_debug_dir }}" |
| 61 | + register: synth_rating_info |
| 62 | + changed_when: synth_rating_info.rc == 0 |
| 63 | + |
50 | 64 | rescue: |
51 | | - - name: "Debug failure" |
52 | | - ansible.builtin.debug: |
| 65 | + - name: "Report Retrieval Failure" |
| 66 | + ansible.builtin.fail: |
53 | 67 | msg: |
| 68 | + - "Failed to retrieve Loki data for {{ scenario_name }}" |
54 | 69 | - "Status: {{ loki_response.status | default('Unknown') }}" |
55 | 70 | - "Body: {{ loki_response.content | default('No Content') }}" |
56 | | - - "Msg: {{ loki_response.msg | default('Request failed') }}" |
57 | | - |
58 | | - # Failure |
59 | | - - name: "Report Retrieval Failure" |
60 | | - ansible.builtin.fail: |
61 | | - msg: "Retrieval Failed" |
62 | | - |
63 | | -- name: "Generate chargeback stats from Loki-retrieved data file: {{ scenario_name }}" |
64 | | - ansible.builtin.command: |
65 | | - cmd: > |
66 | | - python3 "{{ cloudkitty_summary_script }}" |
67 | | - -j "{{ artifacts_dir_zuul }}/{{ scenario_name }}{{ cloudkitty_loki_data_suffix }}" |
68 | | - -o "{{ artifacts_dir_zuul }}/{{ scenario_name }}{{ cloudkitty_loki_totals_metrics_suffix }}" |
69 | | - --debug "{{ cloudkitty_debug }}" |
70 | | - --debug_dir "{{ cloudkitty_debug_dir }}" |
71 | | - register: synth_rating_info |
72 | | - changed_when: synth_rating_info.rc == 0 |
| 71 | + - "Message: {{ loki_response.msg | default('Request failed') }}" |
0 commit comments