Skip to content

Commit

Permalink
Clean up parameter names
Browse files Browse the repository at this point in the history
  • Loading branch information
myersCody committed Dec 16, 2024
1 parent f72ec71 commit 8f563a5
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 102 deletions.
2 changes: 1 addition & 1 deletion dev/scripts/load_test_customer_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ trigger_ocp_ingest() {
has_data=$(echo "$response" | jq -r --arg source_name "$source_name" '.data[] | select(.name == $source_name) | .has_data')
}

local max_retries=100
local max_retries=50
local retries=0

while [ "$retries" -lt "$max_retries" ]; do
Expand Down
37 changes: 20 additions & 17 deletions koku/masu/database/aws_report_db_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import logging
import pkgutil
import uuid
from typing import Any
from typing import List

from dateutil.parser import parse
from django.db import connection
Expand All @@ -22,6 +24,7 @@
from masu.database import OCP_REPORT_TABLE_MAP
from masu.database.report_db_accessor_base import ReportDBAccessorBase
from masu.processor import is_feature_unattributed_storage_enabled_aws
from masu.processor.parquet.managed_flow_params import ManagedSqlMetadata
from reporting.models import OCP_ON_ALL_PERSPECTIVES
from reporting.models import OCP_ON_AWS_PERSPECTIVES
from reporting.models import OCP_ON_AWS_TEMP_MANAGED_TABLES
Expand Down Expand Up @@ -477,41 +480,41 @@ def populate_ec2_compute_summary_table_trino(self, source_uuid, start_date, bill

self._execute_trino_raw_sql_query(sql, sql_params=sql_params, log_ref=f"{table_name}.sql")

def verify_populate_ocp_on_cloud_daily_trino(self, managed_params, verification_tags):
def verify_populate_ocp_on_cloud_daily_trino(self, verification_tags: List[str], sql_metadata: ManagedSqlMetadata):
"""
Verify the managed trino table population went successfully.
"""
verification_params = managed_params.build_params(["schema", "cloud_source_uuid", "year", "month"])
verification_params["matched_tag_array"] = verification_tags
params = sql_metadata.build_params(["schema", "cloud_source_uuid", "year", "month"])
params["matched_tag_array"] = verification_tags
verification_sql = pkgutil.get_data("masu.database", "trino_sql/verify/managed_ocp_on_aws_verification.sql")
verification_sql = verification_sql.decode("utf-8")
LOG.info(log_json(msg="running verification for managed OCP on AWS daily SQL", **verification_params))
result = self._execute_trino_multipart_sql_query(verification_sql, bind_params=verification_params)
LOG.info(log_json(msg="running verification for managed OCP on AWS daily SQL", **params))
result = self._execute_trino_multipart_sql_query(verification_sql, bind_params=params)
if False in result[0]:
LOG.error(log_json(msg="Verification failed", **verification_params))
LOG.error(log_json(msg="Verification failed", **params))
else:
LOG.info(log_json(msg="Verification successful", **verification_params))
LOG.info(log_json(msg="Verification successful", **params))

def populate_ocp_on_cloud_daily_trino(self, managed_params):
def populate_ocp_on_cloud_daily_trino(self, sql_metadata: ManagedSqlMetadata) -> Any:
"""Populate the managed_aws_openshift_daily trino table for OCP on AWS.
Args:
managed_params: object of ManagedFlowSQLParams class
sql_metadata: object of ManagedSqlMetadata class
Returns
(None)
"""
verification_tags = []
for ocp_provider_uuid in managed_params.ocp_source_uuids:
matched_tags_result = self.find_openshift_keys_expected_values(ocp_provider_uuid, managed_params)
for ocp_provider_uuid in sql_metadata.ocp_source_uuids:
matched_tags_result = self.find_openshift_keys_expected_values(ocp_provider_uuid, sql_metadata)
verification_tags.extend(matched_tags_result)
self.delete_ocp_on_aws_hive_partition_by_day(
managed_params.days_tup,
managed_params.cloud_provider_uuid,
sql_metadata.days_tup,
sql_metadata.cloud_provider_uuid,
ocp_provider_uuid,
managed_params.year,
managed_params.month,
sql_metadata.year,
sql_metadata.month,
TRINO_MANAGED_OCP_AWS_DAILY_TABLE,
)
summary_sql_params = managed_params.build_params(
summary_sql_params = sql_metadata.build_params(
["schema", "start_date", "year", "month", "days", "end_date", "cloud_provider_uuid"]
)
summary_sql_params["ocp_source_uuid"] = ocp_provider_uuid
Expand All @@ -521,4 +524,4 @@ def populate_ocp_on_cloud_daily_trino(self, managed_params):
summary_sql = summary_sql.decode("utf-8")
self._execute_trino_multipart_sql_query(summary_sql, bind_params=summary_sql_params)
verification_tags = list(dict.fromkeys(verification_tags))
self.verify_populate_ocp_on_cloud_daily_trino(managed_params, verification_tags)
self.verify_populate_ocp_on_cloud_daily_trino(verification_tags, sql_metadata)
37 changes: 20 additions & 17 deletions koku/masu/database/azure_report_db_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import logging
import pkgutil
import uuid
from typing import Any
from typing import List

from dateutil.parser import parse
from django.db import connection
Expand All @@ -22,6 +24,7 @@
from masu.database import OCP_REPORT_TABLE_MAP
from masu.database.report_db_accessor_base import ReportDBAccessorBase
from masu.processor import is_feature_unattributed_storage_enabled_azure
from masu.processor.parquet.managed_flow_params import ManagedSqlMetadata
from reporting.models import OCP_ON_ALL_PERSPECTIVES
from reporting.models import OCP_ON_AZURE_PERSPECTIVES
from reporting.models import OCP_ON_AZURE_TEMP_MANAGED_TABLES
Expand Down Expand Up @@ -426,41 +429,41 @@ def check_for_matching_enabled_keys(self):
return False
return True

def verify_populate_ocp_on_cloud_daily_trino(self, managed_params, verification_tags):
def verify_populate_ocp_on_cloud_daily_trino(self, verification_tags: List[str], sql_metadata: ManagedSqlMetadata):
"""
Verify the managed trino table population went successfully.
"""
verification_params = managed_params.build_params(["schema", "cloud_source_uuid", "year", "month"])
verification_params["matched_tag_array"] = verification_tags
params = sql_metadata.build_params(["schema", "cloud_source_uuid", "year", "month"])
params["matched_tag_array"] = verification_tags
verification_sql = pkgutil.get_data("masu.database", "trino_sql/verify/managed_ocp_on_azure_verification.sql")
verification_sql = verification_sql.decode("utf-8")
LOG.info(log_json(msg="running verification for managed OCP on Azure daily SQL", **verification_params))
result = self._execute_trino_multipart_sql_query(verification_sql, bind_params=verification_params)
LOG.info(log_json(msg="running verification for managed OCP on Azure daily SQL", **params))
result = self._execute_trino_multipart_sql_query(verification_sql, bind_params=params)
if False in result[0]:
LOG.error(log_json(msg="Verification failed", **verification_params))
LOG.error(log_json(msg="Verification failed", **params))
else:
LOG.info(log_json(msg="Verification successful", **verification_params))
LOG.info(log_json(msg="Verification successful", **params))

def populate_ocp_on_cloud_daily_trino(self, managed_params):
def populate_ocp_on_cloud_daily_trino(self, sql_metadata: ManagedSqlMetadata) -> Any:
"""Populate the managed_aws_openshift_daily trino table for OCP on Azure.
Args:
managed_params: object of ManagedFlowSQLParams class
sql_metadata: object of ManagedSqlMetadata class
Returns
(None)
"""
verification_tags = []
for ocp_provider_uuid in managed_params.ocp_source_uuids:
matched_tags_result = self.find_openshift_keys_expected_values(ocp_provider_uuid, managed_params)
for ocp_provider_uuid in sql_metadata.ocp_source_uuids:
matched_tags_result = self.find_openshift_keys_expected_values(ocp_provider_uuid, sql_metadata)
verification_tags.extend(matched_tags_result)
self.delete_ocp_on_azure_hive_partition_by_day(
managed_params.days_tup,
managed_params.cloud_provider_uuid,
sql_metadata.days_tup,
sql_metadata.cloud_provider_uuid,
ocp_provider_uuid,
managed_params.year,
managed_params.month,
sql_metadata.year,
sql_metadata.month,
TRINO_MANAGED_OCP_AZURE_DAILY_TABLE,
)
summary_sql_params = managed_params.build_params(
summary_sql_params = sql_metadata.build_params(
["schema", "start_date", "year", "month", "days", "end_date", "cloud_provider_uuid"]
)
summary_sql_params["ocp_source_uuid"] = ocp_provider_uuid
Expand All @@ -472,4 +475,4 @@ def populate_ocp_on_cloud_daily_trino(self, managed_params):
summary_sql = summary_sql.decode("utf-8")
self._execute_trino_multipart_sql_query(summary_sql, bind_params=summary_sql_params)
verification_tags = list(dict.fromkeys(verification_tags))
self.verify_populate_ocp_on_cloud_daily_trino(managed_params, verification_tags)
self.verify_populate_ocp_on_cloud_daily_trino(verification_tags, sql_metadata)
Loading

0 comments on commit 8f563a5

Please sign in to comment.