Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
e92f7bc
telemetry_chargeback role task file additions
ayefimov-1 Apr 21, 2026
28a064f
ayefimov-1 Apr 21, 2026
9661085
remove loki_rate file
ayefimov-1 Apr 22, 2026
2fb8d72
added --ascending/--descending flags for generating
ayefimov-1 Apr 22, 2026
2e84da4
Updating README file.
ayefimov-1 Apr 22, 2026
1ac73cb
Fixes based on review feedback from Jaromir
ayefimov-1 Apr 23, 2026
b2f5d7d
Moved debug var from tasks/main.yml to defaults/main.yml
ayefimov-1 Apr 24, 2026
07daf4d
Merge branch 'master' into alexy_db_download_tasks_files
ayefimov-1 May 1, 2026
d5d9bb0
ayefimov-1 Apr 21, 2026
466f554
[telemetry_chargeback] Add ability to ingest and retrieve loki data
ayefimov-1 Apr 23, 2026
5844234
Add and ingest task file
ayefimov-1 May 1, 2026
051d106
ayefimov-1 Apr 21, 2026
e7c3b87
Add flushing loki DB task file
ayefimov-1 Apr 23, 2026
05a4923
[telemetry_chargeback] Add tasks file to flush data to the loki DB
ayefimov-1 Apr 23, 2026
1f15eed
Adding loki flush tasks file.
ayefimov-1 May 1, 2026
687d1ed
Add ability to retrieve loki db with retrieve_loki_data.yml
ayefimov-1 Apr 21, 2026
5c1b404
ayefimov-1 Apr 21, 2026
bb98208
Add task file to retrieve loki data
ayefimov-1 Apr 22, 2026
81dcb03
[telemetry_chargeback] Add ability retrieve loki data
ayefimov-1 Apr 23, 2026
f954053
Adding loki flush tasks file.
ayefimov-1 May 1, 2026
a7ade53
Moved debug var from tasks/main.yml to defaults/main.yml
ayefimov-1 Apr 24, 2026
74fd5a0
Merge branch 'master' into alexy_db_download_tasks_files
ayefimov-1 May 5, 2026
0baca16
Merge branch 'alexy_db_download_tasks_files' into alexy_ck_job_2
ayefimov-1 May 5, 2026
b187e41
Merge branch 'alexy_ck_job_3' into alexy_ck_job_4
ayefimov-1 May 5, 2026
f00e722
Merge branch 'alexy_ck_job_2' into alexy_ck_job_3
ayefimov-1 May 5, 2026
2f11ccf
ayefimov-1 Apr 21, 2026
88bda47
ayefimov-1 Apr 21, 2026
0780693
ayefimov-1 Apr 21, 2026
3287f32
ayefimov-1 Apr 21, 2026
661c553
Adding retrieve_loki_data.yml file so that job will download loki
ayefimov-1 May 5, 2026
0d9f322
Merge branch 'alexy_ck_job_3' into alexy_ck_job_4
ayefimov-1 May 5, 2026
a4f6f5d
Adding database upload tasks file ingest_loki_data.yml (#372)
ayefimov-1 May 6, 2026
a9c7fd2
Revert "Adding database upload tasks file ingest_loki_data.yml (#372)"
ayefimov-1 May 6, 2026
de83a0d
Merge branch 'revert-372-alexy_ck_job_2' into alexy_ck_job_3
ayefimov-1 May 6, 2026
6d482a9
Moved debug var from tasks/main.yml to defaults/main.yml
ayefimov-1 Apr 24, 2026
4dcc91c
Merge branch 'master' into alexy_db_download_tasks_files
ayefimov-1 May 6, 2026
75465d6
Merge branch 'alexy_db_download_tasks_files' into revert-372-alexy_ck…
ayefimov-1 May 6, 2026
d114c35
Merge branch 'revert-372-alexy_ck_job_2' into alexy_ck_job_3
ayefimov-1 May 6, 2026
cbd31e3
Merge branch 'alexy_ck_job_3' into alexy_ck_job_4
ayefimov-1 May 6, 2026
689a61f
Update README.md file with branch changes
ayefimov-1 May 6, 2026
d2e8146
Merge branch 'revert-372-alexy_ck_job_2' into alexy_ck_job_3
ayefimov-1 May 6, 2026
51bac27
Merge branch 'alexy_ck_job_3' into alexy_ck_job_4
ayefimov-1 May 6, 2026
6ec4b17
telemetry_chargeback role task file additions
ayefimov-1 Apr 21, 2026
f521983
ayefimov-1 Apr 21, 2026
aff2836
remove loki_rate file
ayefimov-1 Apr 22, 2026
6b81ebf
added --ascending/--descending flags for generating
ayefimov-1 Apr 22, 2026
493766c
Updating README file.
ayefimov-1 Apr 22, 2026
7b3e12e
Fixes based on review feedback from Jaromir
ayefimov-1 Apr 23, 2026
2305372
Moved debug var from tasks/main.yml to defaults/main.yml
ayefimov-1 Apr 24, 2026
6e86ee2
ayefimov-1 Apr 21, 2026
876ee5c
setting all certs dirs in same parent dir
ayefimov-1 May 6, 2026
335865e
ayefimov-1 Apr 21, 2026
4ff0f8c
[telemetry_chargeback] Add ability to ingest and retrieve loki data
ayefimov-1 Apr 23, 2026
f3685b6
Rebase from master
ayefimov-1 May 1, 2026
0844288
Removed needless fileIO to improve performance
ayefimov-1 May 8, 2026
690cf32
Updated telemetry_chargeback role per review
ayefimov-1 May 11, 2026
98a6159
Merge branch 'master' into alexy_db_download_tasks_files
ayefimov-1 May 12, 2026
307a661
Merge branch 'alexy_db_download_tasks_files' into alexy_ck_job_3
ayefimov-1 May 12, 2026
08fc018
Merge branch 'alexy_ck_job_3' into alexy_ck_job_4
ayefimov-1 May 12, 2026
8085e21
Merge branch 'alexy_db_download_tasks_files' into alexy_ck_job_3
ayefimov-1 May 12, 2026
86117c6
Merge branch 'master' into alexy_db_download_tasks_files
ayefimov-1 May 12, 2026
a61f7c7
Merge branch 'alexy_db_download_tasks_files' into alexy_ck_job_3
ayefimov-1 May 12, 2026
e412ff3
Merge branch 'alexy_ck_job_3' into alexy_ck_job_4
ayefimov-1 May 12, 2026
c449a41
Merge branch 'master' into alexy_ck_job_3
ayefimov-1 May 13, 2026
3fdaf96
Merge branch 'alexy_ck_job_3' into alexy_ck_job_4
ayefimov-1 May 13, 2026
590eab9
Merge branch 'master' into alexy_ck_job_4
ayefimov-1 May 20, 2026
e682e78
Fixed lint error
ayefimov-1 May 20, 2026
832c6e9
Merge branch 'master' into alexy_ck_job_4
ayefimov-1 May 20, 2026
3f2fe95
Merge branch 'master' into alexy_ck_job_4a
ayefimov-1 May 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions roles/telemetry_chargeback/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
telemetry_chargeback
===================

The **`telemetry_chargeback`** role validates and tests the **RHOSO CloudKitty** chargeback feature. It performs CloudKitty configuration validation and generates synthetic test data for chargeback scenario testing.

Expand Down Expand Up @@ -33,16 +32,15 @@ Role Variables

### User-Configurable Variables (defaults/main.yml)

These variables can be overridden when importing the role or set at the play level. Users can customize these based on their deployment environment and test requirements.

| Variable | Default Value | Description |
|----------|---------------|-------------|
| `openstack_cmd` | `"openstack"` | OpenStack CLI command (customize if not in PATH) |
| `cloudkitty_debug` | `false` | Enable debug mode for CloudKitty operations |
| `cloudkitty_debug_dir` | `"{{ (cloudkitty_debug \| bool) \| ternary(artifacts_dir_zuul + '/debug_ck_db', '') }}"` | Directory for debug output (auto-set based on debug flag) |
| `logs_dir_zuul` | `"{{ cifmw_basedir }}/logs"` | Directory for log files |
| `artifacts_dir_zuul` | `"{{ cifmw_basedir }}/artifacts"` | Directory for generated artifacts and test output |
| `cert_dir` | `"{{ cifmw_basedir }}/ck-certs"` | Directory for CloudKitty client certificates |
| `local_cert_dir` | `"{{ cifmw_basedir }}/flush_certs"` | Local directory for flush certificates (cleaned up after run) |
| `remote_cert_dir` | `"osp-certs"` | Remote directory inside OpenStack pod for certificates |
| `cert_secret_name` | `"cert-cloudkitty-client-internal"` | OpenShift secret name for client certificates |
| `client_secret` | `"secret/cloudkitty-lokistack-gateway-client-http"` | Secret for flush client certificates |
| `ca_configmap` | `"cm/cloudkitty-lokistack-ca-bundle"` | ConfigMap for CA bundle |
Expand All @@ -51,6 +49,7 @@ Role Variables
| `openstackpod` | `"openstackclient"` | OpenStack client pod name for exec/cp operations |
| `lookback` | `6` | Days to look back for Loki query time range |
| `limit` | `50` | Limit for Loki query results |
| `cloudkitty_test_scenarios` | `[]` | List of test scenario files to run (empty = auto-discover) |

How It Works
------------
Expand All @@ -68,7 +67,8 @@ The role executes the following workflow:
- Configures Loki push/query URLs

3. **Test Scenario Discovery**
- Automatically finds all `test_*.yml` files in `files/` directory
- **Auto-discovery** (default): Finds all `test_*.yml` files in `files/` directory
- **User-provided**: Uses scenarios from `cloudkitty_test_scenarios` variable

4. **Scenario Execution Loop** (for each discovered scenario)
- Generates synthetic Loki log data (`gen_synth_loki_data.py`)
Expand All @@ -79,6 +79,9 @@ The role executes the following workflow:
- Removes temporary certificate directories
- Always runs (even on failure) via block/rescue/always structure

### Loop Variable

The role uses `{{ scenario_name }}` as the loop variable when processing multiple test scenarios, making it easy to track which scenario is currently executing.

Python Scripts
--------------
Expand Down
47 changes: 19 additions & 28 deletions roles/telemetry_chargeback/tasks/ingest_loki_data.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
---
# Ingest data generated by gen_synth_loki_data.yml to Loki

- name: "Ingest data log to Loki via API"
block:
- name: "TEST Push data to Loki"
ansible.builtin.uri:
## loki_push_url will be used in future role developement
url: "{{ loki_push_url }}"
method: POST
src: "{{ cloudkitty_data_file }}"
body_format: json
client_cert: "{{ cert_dir }}/tls.crt"
client_key: "{{ cert_dir }}/tls.key"
validate_certs: false
status_code: 204
return_content: true
register: loki_response
ignore_errors: true
failed_when: loki_response.status != 204

- name: "Push data to Loki"
ansible.builtin.uri:
## loki_push_url will be used in future role developement
url: "{{ loki_push_url }}"
method: POST
src: "{{ cloudkitty_data_file }}"
body_format: json
client_cert: "{{ cert_dir }}/tls.crt"
client_key: "{{ cert_dir }}/tls.key"
validate_certs: false
status_code: 204
return_content: true
register: loki_response
ignore_errors: false
failed_when: loki_response.status != 204

# Success
- name: "Confirm ingestion success"
ansible.builtin.debug:
msg: "Ingestion Successful!"

rescue:
# Rescue block
- name: "Debug failure"
ansible.builtin.debug:
msg: "Ingest failed. Loki Status: {{ loki_response.status | default('N/A') }}"
- name: "Ingest Status Message"
ansible.builtin.debug:
msg: "Ingestion Successful"
when: loki_response.status | default(0) == 204
3 changes: 3 additions & 0 deletions roles/telemetry_chargeback/tasks/load_loki_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@

- name: "Flush data to Loki storage for {{ scenario_name }}"
ansible.builtin.include_tasks: flush_loki_data.yml

- name: "Retrieve data log from Loki for {{ scenario_name }}"
ansible.builtin.include_tasks: retrieve_loki_data.yml
71 changes: 71 additions & 0 deletions roles/telemetry_chargeback/tasks/retrieve_loki_data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
- name: "Expected Count {{ scenario_name }}"
ansible.builtin.debug:
msg: "Input file has {{ synth_data_rates.data_log.log_count }} data entries that Loki has to return"

# Query Loki
- name: "Retrieve Logs from Loki via API {{ scenario_name }}"
block:
- name: "Query Loki API"
ansible.builtin.uri:
url: "{{ loki_query_url }}?query={{ logql_query | urlencode }}&start={{ synth_data_rates.time.begin_step.nanosec }}&limit={{ limit }}"
method: GET
client_cert: "{{ cert_dir }}/tls.crt"
client_key: "{{ cert_dir }}/tls.key"
ca_path: "{{ cert_dir }}/ca.crt"
validate_certs: false
return_content: true
body_format: json
register: loki_response
# Wait condition
until:
- loki_response.status == 200
- loki_response.json.status == 'success'
- loki_response.json.data.result | length > 0
- (loki_response.json.data.result | map(attribute='values') | map('length') | sum) >= (synth_data_rates.data_log.log_count | int)
retries: 25
delay: 60

- name: "Save Loki Data to JSON file"
ansible.builtin.copy:
content: "{{ loki_response.json | to_json }}"
dest: "{{ artifacts_dir_zuul }}/{{ scenario_name }}{{ cloudkitty_loki_data_suffix }}"
mode: '0644'

# Validate
- name: "Verify Data Integrity {{ scenario_name }}"
vars:
actual_count: "{{ loki_response.json.data.result | map(attribute='values') | map('length') | sum }}"
ansible.builtin.assert:
that:
- loki_response.json.status == 'success'
- loki_response.json.data.result | length > 0
- actual_count | int == (synth_data_rates.data_log.log_count | int)
fail_msg: >-
Query did not return all data entries. Expected
{{ synth_data_rates.data_log.log_count }} log entries, but Loki
only returned {{ actual_count }}
success_msg: "Query returned all data entries. Input file had {{ synth_data_rates.data_log.log_count }} entries and Loki returned {{ actual_count }}"

rescue:
- name: "Debug failure"
ansible.builtin.debug:
msg:
- "Status: {{ loki_response.status | default('Unknown') }}"
- "Body: {{ loki_response.content | default('No Content') }}"
- "Msg: {{ loki_response.msg | default('Request failed') }}"

# Failure
- name: "Report Retrieval Failure"
ansible.builtin.fail:
msg: "Retrieval Failed"

- name: "Generate chargeback stats from Loki-retrieved data file: {{ scenario_name }}"
ansible.builtin.command:
cmd: >
python3 "{{ cloudkitty_summary_script }}"
-j "{{ artifacts_dir_zuul }}/{{ scenario_name }}{{ cloudkitty_loki_data_suffix }}"
-o "{{ artifacts_dir_zuul }}/{{ scenario_name }}{{ cloudkitty_loki_totals_metrics_suffix }}"
--debug "{{ cloudkitty_debug_dir }}"
register: synth_rating_info
changed_when: synth_rating_info.rc == 0
Loading