Skip to content

Commit

Permalink
Additional improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
myersCody committed Jun 18, 2024
1 parent 6369174 commit 14c51fb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
1 change: 1 addition & 0 deletions koku/masu/database/ocp_report_db_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ def find_expired_trino_partitions(self, table, source_column, date_str):
FROM "{table}$partitions"
) as partitions
WHERE partitions.partition_date < DATE '{date_str}'
GROUP BY partitions.year, partitions.month, partitions.source
"""
return self._execute_trino_raw_sql_query(sql, log_ref="finding expired partitions")

Check warning on line 304 in koku/masu/database/ocp_report_db_accessor.py

View check run for this annotation

Codecov / codecov/patch

koku/masu/database/ocp_report_db_accessor.py#L304

Added line #L304 was not covered by tests

Expand Down
33 changes: 20 additions & 13 deletions koku/masu/processor/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,18 +508,25 @@ def remove_expired_trino_partitions(self, simulate=False):
Removes expired trino partitions for each account.
"""
async_results = []
for account in Provider.objects.get_accounts():
if account.get("provider_type") == Provider.PROVIDER_OCP:
LOG.info("Calling remove_expired_trino_partitions with account: %s", account)
async_result = remove_expired_trino_partitions.delay(
schema_name=account.get("schema_name"),
provider_type=account.get("provider_type"),
simulate=simulate,
)
schemas = set(

Check warning on line 511 in koku/masu/processor/orchestrator.py

View check run for this annotation

Codecov / codecov/patch

koku/masu/processor/orchestrator.py#L510-L511

Added lines #L510 - L511 were not covered by tests
Provider.objects.filter(type=Provider.PROVIDER_OCP)
.values_list("customer__schema_name", flat=True)
.distinct()
)
# <QuerySet ['org1234567', 'org1234567', 'org1234567', 'org1234567']>
# distinct is not removing duplicates from this list, so using a set to reduce instead

for schema in schemas:
LOG.info("Calling remove_expired_trino_partitions with account: %s", schema)
async_result = remove_expired_trino_partitions.delay(

Check warning on line 521 in koku/masu/processor/orchestrator.py

View check run for this annotation

Codecov / codecov/patch

koku/masu/processor/orchestrator.py#L520-L521

Added lines #L520 - L521 were not covered by tests
schema_name=schema,
provider_type=Provider.PROVIDER_OCP,
simulate=simulate,
)

LOG.info(
"Expired partition removal queued - schema_name: %s, Task ID: %s",
account.get("schema_name"),
str(async_result),
)
LOG.info(

Check warning on line 527 in koku/masu/processor/orchestrator.py

View check run for this annotation

Codecov / codecov/patch

koku/masu/processor/orchestrator.py#L527

Added line #L527 was not covered by tests
"Expired partition removal queued - schema_name: %s, Task ID: %s",
schema,
str(async_result),
)
return async_results

Check warning on line 532 in koku/masu/processor/orchestrator.py

View check run for this annotation

Codecov / codecov/patch

koku/masu/processor/orchestrator.py#L532

Added line #L532 was not covered by tests

0 comments on commit 14c51fb

Please sign in to comment.