Skip to content

Commit 68ea642

Browse files
authored
Merge branch 'master' into alexy_ck_job_6b
2 parents a9c68db + 1775c58 commit 68ea642

2 files changed

Lines changed: 9 additions & 17 deletions

File tree

roles/telemetry_chargeback/files/gen_synth_loki_data.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ def generate_loki_data(
140140
logger.debug(f"Time range in epoch seconds: {start_epoch} to {end_epoch}")
141141

142142
log_data_list = [] # This list will hold all our data points
143-
last_end_of_step_epoch = None # Track last entry's end epoch
144143

145144
# Loop through the time range and generate data points
146145
for current_epoch in range(
@@ -167,13 +166,13 @@ def generate_loki_data(
167166
"end_time": end_str
168167
})
169168

170-
# Track the last end epoch
171-
last_end_of_step_epoch = end_of_step_epoch
172-
173169
# Add final entry that ends at end_epoch (current time)
174-
if log_data_list and end_epoch > start_epoch and last_end_of_step_epoch:
170+
if log_data_list and end_epoch > start_epoch:
175171
# Calculate start of final entry based on end of last generated entry
176-
final_start_epoch = last_end_of_step_epoch + 1
172+
last_entry_end = log_data_list[-1]["end_time"]
173+
# Parse the last entry's end time to get the epoch
174+
last_end_dt = datetime.fromisoformat(last_entry_end)
175+
final_start_epoch = int(last_end_dt.timestamp()) + 1
177176
final_nanoseconds = int(final_start_epoch * 1_000_000_000)
178177

179178
# Only add if the final entry would have a valid duration
@@ -225,11 +224,8 @@ def generate_loki_data(
225224

226225
# Validate required fields
227226
# metadata is optional for generation; name is not a log-type field
228-
required_for_item = [
229-
f for f in required_fields
230-
if f not in ("name", "metadata")
231-
]
232-
missing = [f for f in required_for_item if f not in log_type_config]
227+
required_for_item = set(required_fields) - {"name", "metadata"}
228+
missing = required_for_item - set(log_type_config)
233229
if missing:
234230
logger.error(
235231
f"Missing required fields in {type_key!r} config: {missing}"

roles/telemetry_chargeback/vars/main.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
---
2-
cloudkitty_synth_script: "{{ role_path }}/files/gen_synth_loki_data.py"
3-
cloudkitty_data_template: "{{ role_path }}/templates/loki_data_templ.j2"
4-
ck_data_config: "{{ role_path }}/files/test_static.yml"
5-
ck_output_file_local: "{{ artifacts_dir_zuul }}/loki_synth_data.json"
6-
ck_output_file_remote: "{{ logs_dir_zuul }}/gen_loki_synth_data.log"
7-
82
# Scenario and script paths (using role_path)
93
cloudkitty_scenario_dir: "{{ role_path }}/files"
4+
cloudkitty_synth_script: "{{ role_path }}/files/gen_synth_loki_data.py"
5+
cloudkitty_data_template: "{{ role_path }}/templates/loki_data_templ.j2"
106
cloudkitty_summary_script: "{{ role_path }}/files/gen_db_summary.py"
117

128
# File naming conventions (internal standardization)

0 commit comments

Comments
 (0)