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

Add unleash flag to skip trino tag matched get logic #5436

Merged
merged 5 commits into from
Jan 7, 2025
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
7 changes: 7 additions & 0 deletions koku/masu/processor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,10 @@ def is_customer_cost_model_large(account): # pragma: no cover
account = convert_account(account)
context = {"schema": account}
return UNLEASH_CLIENT.is_enabled("cost-management.backend.large-customer-cost-model", context)


def is_tag_processing_disabled(account): # pragma: no cover
"""Flag the customer as tag processing disabled."""
account = convert_account(account)
context = {"schema": account}
return UNLEASH_CLIENT.is_enabled("cost-management.backend.is_tag_processing_disabled", context)
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from masu.database.gcp_report_db_accessor import GCPReportDBAccessor
from masu.database.ocp_report_db_accessor import OCPReportDBAccessor
from masu.database.report_manifest_db_accessor import ReportManifestDBAccessor
from masu.processor import is_tag_processing_disabled
from masu.processor.ocp.ocp_cloud_updater_base import OCPCloudUpdaterBase
from masu.processor.parquet.parquet_report_processor import OPENSHIFT_REPORT_TYPE
from masu.processor.parquet.parquet_report_processor import PARQUET_EXT
Expand Down Expand Up @@ -172,6 +173,10 @@ def get_matched_tags(self, ocp_provider_uuids):
matched_tags = self.db_accessor.get_openshift_on_cloud_matched_tags(self.bill_id)
if not matched_tags and enabled_tags:
LOG.info(log_json(msg="matched tags not available via Postgres", context=ctx))
# This flag is specifically for disabling trino tag matching for specific customers.
if is_tag_processing_disabled(self.schema_name):
LOG.info(log_json(msg="trino tag matching disabled for customer", context=ctx))
return []
LOG.info(log_json(msg="getting matching tags from Trino", context=ctx))
matched_tags = self.db_accessor.get_openshift_on_cloud_matched_tags_trino(
self.provider_uuid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,17 @@ def test_get_matched_tags_trino(self, mock_has_enabled, mock_matching_enabled, m
self.report_processor.get_matched_tags([])
mock_get_tags.assert_not_called()

@patch.object(AWSReportDBAccessor, "check_for_matching_enabled_keys", return_value=True)
@patch.object(OCPCloudParquetReportProcessor, "has_enabled_ocp_labels", return_value=True)
@patch.object(AWSReportDBAccessor, "get_openshift_on_cloud_matched_tags", return_value=None)
@patch("masu.processor.parquet.ocp_cloud_parquet_report_processor.is_tag_processing_disabled", return_value=True)
def test_get_matched_tags_trino_disabled(
self, mock_unleash, mock_pg_tags, mock_has_enabled, mock_matching_enabled
):
"""Test that we skip trino matched tag queries if disabled in unleash."""
result = self.report_processor.get_matched_tags([])
self.assertEqual(result, [])

def test_instantiating_processor_without_manifest_id(self):
"""Assert that report_status exists and is None."""
report_processor = OCPCloudParquetReportProcessor(
Expand Down