Skip to content

Commit 2ce6d62

Browse files
authoredMar 25, 2025
[COST-6089] - Fix node hour tag rates (#5551)
* [COST-6089] - Fix node hour tag rates
1 parent fe56a4f commit 2ce6d62

10 files changed

+231
-115
lines changed
 

‎koku/api/metrics/constants.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
OCP_METRIC_MEM_GB_EFFECTIVE_USAGE_HOUR: MEM,
3737
OCP_METRIC_STORAGE_GB_USAGE_MONTH: STORAGE,
3838
OCP_METRIC_STORAGE_GB_REQUEST_MONTH: STORAGE,
39-
OCP_NODE_CORE_HOUR: CPU,
4039
OCP_CLUSTER_CORE_HOUR: CPU,
4140
}
4241

@@ -83,9 +82,13 @@
8382
OCP_CLUSTER_CORE_HOUR,
8483
)
8584

86-
COST_MODEL_MONTHLY_RATES = (
85+
COST_MODEL_NODE_RATES = {
8786
OCP_NODE_MONTH,
8887
OCP_NODE_CORE_MONTH,
88+
OCP_NODE_CORE_HOUR,
89+
}
90+
91+
COST_MODEL_MONTHLY_RATES = (
8992
OCP_CLUSTER_MONTH,
9093
OCP_PVC_MONTH,
9194
OCP_VM_MONTH,

‎koku/masu/database/ocp_report_db_accessor.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def populate_monthly_cost_sql(self, cost_type, rate_type, rate, start_date, end_
532532
LOG.info(log_json(msg="populating monthly costs", context=ctx))
533533
self._prepare_and_execute_raw_sql_query(table_name, sql, sql_params, operation="INSERT")
534534

535-
def populate_monthly_tag_cost_sql( # noqa: C901
535+
def populate_tag_cost_sql(
536536
self, cost_type, rate_type, tag_key, case_dict, start_date, end_date, distribution, provider_uuid
537537
):
538538
"""
@@ -563,8 +563,8 @@ def populate_monthly_tag_cost_sql( # noqa: C901
563563
cpu_case, memory_case, volume_case = case_dict.get("cost")
564564
labels = case_dict.get("labels")
565565

566-
if cost_type in ("Node", "Node_Core_Month"):
567-
sql = pkgutil.get_data("masu.database", "sql/openshift/cost_model/monthly_cost_node_by_tag.sql")
566+
if "Node" in cost_type:
567+
sql = pkgutil.get_data("masu.database", "sql/openshift/cost_model/node_cost_by_tag.sql")
568568
elif cost_type == "PVC":
569569
sql = pkgutil.get_data(
570570
"masu.database", "sql/openshift/cost_model/monthly_cost_persistentvolumeclaim_by_tag.sql"
@@ -593,7 +593,7 @@ def populate_monthly_tag_cost_sql( # noqa: C901
593593
sql_params["unallocated_cost_model_memory_cost"] = unallocated_memory_case
594594
sql_params["unallocated_cost_model_volume_cost"] = unallocated_volume_case
595595

596-
LOG.info(log_json(msg="populating monthly tag costs", context=ctx))
596+
LOG.info(log_json(msg="populating tag costs", context=ctx))
597597
self._prepare_and_execute_raw_sql_query(table_name, sql, sql_params, operation="INSERT")
598598

599599
def populate_usage_costs(self, rate_type, rates, start_date, end_date, provider_uuid):

‎koku/masu/database/sql/openshift/cost_model/default_infrastructure_tag_rates.sql

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ FROM (
7979
WHEN {{metric}}='memory_gb_effective_usage_per_hour' THEN sum(lids.pod_effective_usage_memory_gigabyte_hours)
8080
WHEN {{metric}}='storage_gb_usage_per_month' THEN sum(lids.persistentvolumeclaim_usage_gigabyte_months)
8181
WHEN {{metric}}='storage_gb_request_per_month' THEN sum(lids.volume_request_storage_gigabyte_months)
82-
WHEN {{metric}}='node_core_cost_per_hour' THEN sum(lids.pod_effective_usage_cpu_core_hours)
8382
END as usage,
8483
lids.cost_category_id
8584
FROM {{schema | sqlsafe}}.reporting_ocpusagelineitem_daily_summary AS lids

‎koku/masu/database/sql/openshift/cost_model/default_supplementary_tag_rates.sql

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ FROM (
7979
WHEN {{metric}}='memory_gb_effective_usage_per_hour' THEN sum(lids.pod_effective_usage_memory_gigabyte_hours)
8080
WHEN {{metric}}='storage_gb_usage_per_month' THEN sum(lids.persistentvolumeclaim_usage_gigabyte_months)
8181
WHEN {{metric}}='storage_gb_request_per_month' THEN sum(lids.volume_request_storage_gigabyte_months)
82-
WHEN {{metric}}='node_core_cost_per_hour' THEN sum(lids.pod_effective_usage_cpu_core_hours)
8382
END as usage,
8483
lids.cost_category_id
8584
FROM {{schema | sqlsafe}}.reporting_ocpusagelineitem_daily_summary AS lids

‎koku/masu/database/sql/openshift/cost_model/infrastructure_tag_rates.sql

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ FROM (
7878
WHEN {{metric}}='memory_gb_effective_usage_per_hour' THEN sum(lids.pod_effective_usage_memory_gigabyte_hours)
7979
WHEN {{metric}}='storage_gb_usage_per_month' THEN sum(lids.persistentvolumeclaim_usage_gigabyte_months)
8080
WHEN {{metric}}='storage_gb_request_per_month' THEN sum(lids.volume_request_storage_gigabyte_months)
81-
WHEN {{metric}}='node_core_cost_per_hour' THEN sum(lids.pod_effective_usage_cpu_core_hours)
8281
END as usage,
8382
cost_category_id
8483
FROM {{schema | sqlsafe}}.reporting_ocpusagelineitem_daily_summary AS lids

‎koku/masu/database/sql/openshift/cost_model/supplementary_tag_rates.sql

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ FROM (
7878
WHEN {{metric}}='memory_gb_effective_usage_per_hour' THEN sum(lids.pod_effective_usage_memory_gigabyte_hours)
7979
WHEN {{metric}}='storage_gb_usage_per_month' THEN sum(lids.persistentvolumeclaim_usage_gigabyte_months)
8080
WHEN {{metric}}='storage_gb_request_per_month' THEN sum(lids.volume_request_storage_gigabyte_months)
81-
WHEN {{metric}}='node_core_cost_per_hour' THEN sum(lids.pod_effective_usage_cpu_core_hours)
8281
END as usage,
8382
lids.cost_category_id
8483
FROM {{schema | sqlsafe}}.reporting_ocpusagelineitem_daily_summary AS lids

0 commit comments

Comments
 (0)