Skip to content

Commit 0bdb1ce

Browse files
authored
[COST-7104] Fix node aggregation (#5845)
1 parent bde58ec commit 0bdb1ce

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

koku/api/report/ocp/provider_map.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,11 @@ def __init__(self, provider, report_type, schema_name):
905905
),
906906
"gpu_count_units": Value("GPUs", output_field=CharField()),
907907
},
908+
"aggregate_ranks_exclusions": [
909+
"gpu_model",
910+
"gpu_vendor",
911+
"node",
912+
], # _aggregate_ranks_over_limit
908913
"delta_key": {},
909914
"filter": [],
910915
"group_by": ["gpu_name"],

koku/api/report/queries.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,6 @@ def is_aws(self):
234234
"""Determine if we are working with an AWS API."""
235235
return "aws" in self.parameters.request.path
236236

237-
@property
238-
def is_gpu(self):
239-
"""Determine if we are working with a GPU API."""
240-
return "gpu" in self.parameters.request.path
241-
242237
def initialize_totals(self):
243238
"""Initialize the total response column values."""
244239
query_sum = {}
@@ -1472,7 +1467,10 @@ def _aggregate_ranks_over_limit(self, data_frame, group_by):
14721467
drop_columns = group_by + ["rank", "source_uuid"]
14731468
groups = ["date"]
14741469

1475-
skip_columns = ["source_uuid", "gcp_project_alias", "clusters", "gpu_vendor", "gpu_model"]
1470+
skip_columns = ["source_uuid", "gcp_project_alias", "clusters"]
1471+
aggregate_ranks_exclusions = self._mapper.report_type_map.get("aggregate_ranks_exclusions", [])
1472+
skip_columns.extend(aggregate_ranks_exclusions)
1473+
14761474
aggs = {
14771475
col: ["max"] if "units" in col else ["sum"] for col in self.report_annotations if col not in skip_columns
14781476
}
@@ -1509,10 +1507,8 @@ def _aggregate_ranks_over_limit(self, data_frame, group_by):
15091507
others_data_frame["source_uuid"] = [source_uuids] * len(others_data_frame)
15101508
if self.is_openshift:
15111509
others_data_frame["clusters"] = [clusters] * len(others_data_frame)
1512-
if self.is_gpu:
1513-
others_data_frame["gpu_model"] = other_str
1514-
others_data_frame["gpu_vendor"] = other_str
1515-
1510+
for column in aggregate_ranks_exclusions:
1511+
others_data_frame[column] = other_str
15161512
return others_data_frame
15171513

15181514
def date_group_data(self, data_list):

0 commit comments

Comments
 (0)