diff --git a/koku/api/report/ocp/provider_map.py b/koku/api/report/ocp/provider_map.py index 00a400346a..57f6cd4655 100644 --- a/koku/api/report/ocp/provider_map.py +++ b/koku/api/report/ocp/provider_map.py @@ -19,6 +19,7 @@ from api.models import Provider from api.report.provider_map import ProviderMap +from masu.processor import is_feature_cost_3083_all_labels_enabled from providers.provider_access import ProviderAccessor from reporting.models import OCPUsageLineItemDailySummary from reporting.provider.ocp.models import OCPCostSummaryByNodeP @@ -34,6 +35,12 @@ class OCPProviderMap(ProviderMap): """OCP Provider Map.""" + @cached_property + def check_unleash_for_tag_column_cost_3038(self): + if is_feature_cost_3083_all_labels_enabled(self._schema_name): + return "all_labels" + return "pod_labels" + def __cost_model_cost(self, cost_model_rate_type=None): """Return ORM term for cost model cost""" if cost_model_rate_type: @@ -165,7 +172,7 @@ def __init__(self, provider, report_type, schema_name): "tag_column": "pod_labels", # default for if a report type does not have a tag_column "report_type": { "costs": { - "tag_column": "all_labels", + "tag_column": self.check_unleash_for_tag_column_cost_3038, "tables": {"query": OCPUsageLineItemDailySummary}, "aggregates": { "sup_raw": Sum(Value(0, output_field=DecimalField())), @@ -215,7 +222,7 @@ def __init__(self, provider, report_type, schema_name): "sum_columns": ["cost_total", "infra_total", "sup_total"], }, "costs_by_project": { - "tag_column": "all_labels", + "tag_column": self.check_unleash_for_tag_column_cost_3038, "tables": {"query": OCPUsageLineItemDailySummary}, "aggregates": { "sup_raw": Sum(Value(0, output_field=DecimalField())), diff --git a/koku/api/report/test/ocp/test_views.py b/koku/api/report/test/ocp/test_views.py index 036e38dc26..21c3e25f48 100644 --- a/koku/api/report/test/ocp/test_views.py +++ b/koku/api/report/test/ocp/test_views.py @@ -1114,7 +1114,8 @@ def test_execute_query_with_tag_filter(self): result = data_totals.get(key, {}).get("value") self.assertEqual(result, expected) - def test_execute_costs_query_with_tag_filter(self): + @patch("api.report.ocp.provider_map.is_feature_cost_3083_all_labels_enabled", return_value=True) + def test_execute_costs_query_with_tag_filter(self, mock_unleash): """Test that data is filtered by tag key.""" url = "?filter[type]=pod&filter[time_scope_value]=-10&filter[enabled]=true" query_params = self.mocked_query_params(url, OCPTagView) diff --git a/koku/masu/processor/__init__.py b/koku/masu/processor/__init__.py index b3f0ccc036..722ef31c16 100644 --- a/koku/masu/processor/__init__.py +++ b/koku/masu/processor/__init__.py @@ -151,3 +151,11 @@ def is_feature_cost_3592_tag_mapping_enabled(account): account = convert_account(account) context = {"schema": account} return UNLEASH_CLIENT.is_enabled(unleash_flag, context, fallback_development_true) + + +def is_feature_cost_3083_all_labels_enabled(account): + """Should all labels column be enabled.""" + unleash_flag = "cost-management.backend.feature-cost-3083-all-labels" + account = convert_account(account) + context = {"schema": account} + return UNLEASH_CLIENT.is_enabled(unleash_flag, context, fallback_development_true) diff --git a/koku/providers/provider_errors.py b/koku/providers/provider_errors.py index f08961f2ba..ec69587b8d 100644 --- a/koku/providers/provider_errors.py +++ b/koku/providers/provider_errors.py @@ -103,7 +103,7 @@ class ProviderErrors: "The provided client secret keys for this source are expired. " "In Azure, refresh your client secret and try again." ) - AZURE_INCORRECT_CLIENT_SECRET_MESSAGE = ( + AZURE_CLIENT_SECRET_INCORRECT_MESSAGE = ( "A problem has been detected with the Azure client secret for this source. " "Refer to the Microsoft Azure troubleshooting guide in the cost management documentation for details." ) diff --git a/koku/sources/sources_error_message.py b/koku/sources/sources_error_message.py index 3c124a98ab..c9cbf24857 100644 --- a/koku/sources/sources_error_message.py +++ b/koku/sources/sources_error_message.py @@ -23,7 +23,7 @@ def azure_client_errors(self, message): """Azure client error messages.""" scrubbed_message = ProviderErrors.AZURE_GENERAL_CLIENT_ERROR_MESSAGE if any(test in message for test in ["http error: 401", "Authentication failed", "(401) Unauthorized"]): - scrubbed_message = ProviderErrors.AZURE_INCORRECT_CLIENT_SECRET_MESSAGE + scrubbed_message = ProviderErrors.AZURE_CLIENT_SECRET_INCORRECT_MESSAGE if "AADSTS700016" in message: scrubbed_message = ProviderErrors.AZURE_INCORRECT_CLIENT_ID_MESSAGE if "AADSTS90002" in message: diff --git a/koku/sources/test/test_sources_error_message.py b/koku/sources/test/test_sources_error_message.py index b4645a3624..eee9304a29 100644 --- a/koku/sources/test/test_sources_error_message.py +++ b/koku/sources/test/test_sources_error_message.py @@ -52,12 +52,12 @@ def test_azure_errors(self): { "key": ProviderErrors.AZURE_CLIENT_ERROR, "internal_message": ", AdalError: Get Token request returned http error: 401 and server response:", - "expected_message": ProviderErrors.AZURE_INCORRECT_CLIENT_SECRET_MESSAGE, + "expected_message": ProviderErrors.AZURE_CLIENT_SECRET_INCORRECT_MESSAGE, }, { "key": ProviderErrors.AZURE_CLIENT_ERROR, "internal_message": "Authentication failed", - "expected_message": ProviderErrors.AZURE_INCORRECT_CLIENT_SECRET_MESSAGE, + "expected_message": ProviderErrors.AZURE_CLIENT_SECRET_INCORRECT_MESSAGE, }, { "key": ProviderErrors.AZURE_CLIENT_ERROR, @@ -65,7 +65,7 @@ def test_azure_errors(self): "(401) Unauthorized. Request ID: cca1a5a4-4107-4e7a-b3b4-b88f31e6a674\n" "Code: 401\nMessage: Unauthorized. Request ID: cca1a5a4-4107-4e7a-b3b4-b88f31e6a674" ), - "expected_message": ProviderErrors.AZURE_INCORRECT_CLIENT_SECRET_MESSAGE, + "expected_message": ProviderErrors.AZURE_CLIENT_SECRET_INCORRECT_MESSAGE, }, { "key": ProviderErrors.AZURE_CLIENT_ERROR,