Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[COST-4101] tech debt remove ocp on gcp summarization by node. #4626

Merged
merged 12 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
77 changes: 0 additions & 77 deletions koku/masu/database/gcp_report_db_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,83 +350,6 @@ def delete_line_item_daily_summary_entries_for_date_range(self, source_uuid, sta
count, _ = mini_transaction_delete(select_query)
LOG.info(log_json(msg=f"deleted {count} records", context=ctx))

def populate_ocp_on_gcp_cost_daily_summary_trino_by_node(
self,
start_date,
end_date,
openshift_provider_uuid,
cluster_id,
gcp_provider_uuid,
report_period_id,
bill_id,
markup_value,
distribution,
node,
node_count=None,
):
"""Populate the daily cost aggregated summary for OCP on GCP.

This method is called for each node in the update_gcp_summary_tables
if an unleash flag is enabled.

Args:
start_date (datetime.date) The date to start populating the table.
end_date (datetime.date) The date to end on.

Returns
(None)

"""
year = start_date.strftime("%Y")
month = start_date.strftime("%m")
tables = [
"reporting_ocpgcpcostlineitem_project_daily_summary_temp",
"gcp_openshift_daily_resource_matched_temp",
"gcp_openshift_daily_tag_matched_temp",
]
for table in tables:
self.delete_hive_partition_by_month(table, openshift_provider_uuid, year, month)

days = self.date_helper.list_days(start_date, end_date)
days_tup = tuple(str(day.day) for day in days)
self.delete_ocp_on_gcp_hive_partition_by_day(days_tup, gcp_provider_uuid, openshift_provider_uuid, year, month)

cluster_alias = get_cluster_alias_from_cluster_id(cluster_id)

# Default to cpu distribution
pod_column = "pod_effective_usage_cpu_core_hours"
cluster_column = "cluster_capacity_cpu_core_hours"
if distribution == "memory":
pod_column = "pod_effective_usage_memory_gigabyte_hours"
cluster_column = "cluster_capacity_memory_gigabyte_hours"

sql = pkgutil.get_data(
"masu.database", "trino_sql/gcp/openshift/reporting_ocpgcpcostlineitem_daily_summary_by_node.sql"
)
sql = sql.decode("utf-8")
sql_params = {
"schema": self.schema,
"start_date": start_date,
"year": year,
"month": month,
"days": days_tup,
"end_date": end_date,
"gcp_source_uuid": gcp_provider_uuid,
"ocp_source_uuid": openshift_provider_uuid,
"bill_id": bill_id,
"report_period_id": report_period_id,
"markup": markup_value or 0,
"pod_column": pod_column,
"cluster_column": cluster_column,
"cluster_id": cluster_id,
"cluster_alias": cluster_alias,
"node": node,
"node_count": node_count,
}
ctx = self.extract_context_from_sql_params(sql_params)
LOG.info(log_json(msg="running OCP on GCP SQL (by node)", context=ctx))
self._execute_trino_multipart_sql_query(sql, bind_params=sql_params)

def populate_ocp_on_gcp_cost_daily_summary_trino(
self,
start_date,
Expand Down
Loading
Loading