Skip to content

Commit 2d57ccf

Browse files
myersCodylcouzens
andauthored
[COST-4759] Restore all labels unleash flag (#5002)
--------- Co-authored-by: Luke Couzens <[email protected]>
1 parent a66175a commit 2d57ccf

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

koku/api/report/ocp/provider_map.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from api.models import Provider
2121
from api.report.provider_map import ProviderMap
22+
from masu.processor import is_feature_cost_3083_all_labels_enabled
2223
from providers.provider_access import ProviderAccessor
2324
from reporting.models import OCPUsageLineItemDailySummary
2425
from reporting.provider.ocp.models import OCPCostSummaryByNodeP
@@ -34,6 +35,12 @@
3435
class OCPProviderMap(ProviderMap):
3536
"""OCP Provider Map."""
3637

38+
@cached_property
39+
def check_unleash_for_tag_column_cost_3038(self):
40+
if is_feature_cost_3083_all_labels_enabled(self._schema_name):
41+
return "all_labels"
42+
return "pod_labels"
43+
3744
def __cost_model_cost(self, cost_model_rate_type=None):
3845
"""Return ORM term for cost model cost"""
3946
if cost_model_rate_type:
@@ -165,7 +172,7 @@ def __init__(self, provider, report_type, schema_name):
165172
"tag_column": "pod_labels", # default for if a report type does not have a tag_column
166173
"report_type": {
167174
"costs": {
168-
"tag_column": "all_labels",
175+
"tag_column": self.check_unleash_for_tag_column_cost_3038,
169176
"tables": {"query": OCPUsageLineItemDailySummary},
170177
"aggregates": {
171178
"sup_raw": Sum(Value(0, output_field=DecimalField())),
@@ -215,7 +222,7 @@ def __init__(self, provider, report_type, schema_name):
215222
"sum_columns": ["cost_total", "infra_total", "sup_total"],
216223
},
217224
"costs_by_project": {
218-
"tag_column": "all_labels",
225+
"tag_column": self.check_unleash_for_tag_column_cost_3038,
219226
"tables": {"query": OCPUsageLineItemDailySummary},
220227
"aggregates": {
221228
"sup_raw": Sum(Value(0, output_field=DecimalField())),

koku/api/report/test/ocp/test_views.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,8 @@ def test_execute_query_with_tag_filter(self):
11141114
result = data_totals.get(key, {}).get("value")
11151115
self.assertEqual(result, expected)
11161116

1117-
def test_execute_costs_query_with_tag_filter(self):
1117+
@patch("api.report.ocp.provider_map.is_feature_cost_3083_all_labels_enabled", return_value=True)
1118+
def test_execute_costs_query_with_tag_filter(self, mock_unleash):
11181119
"""Test that data is filtered by tag key."""
11191120
url = "?filter[type]=pod&filter[time_scope_value]=-10&filter[enabled]=true"
11201121
query_params = self.mocked_query_params(url, OCPTagView)

koku/masu/processor/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,11 @@ def is_feature_cost_3592_tag_mapping_enabled(account):
151151
account = convert_account(account)
152152
context = {"schema": account}
153153
return UNLEASH_CLIENT.is_enabled(unleash_flag, context, fallback_development_true)
154+
155+
156+
def is_feature_cost_3083_all_labels_enabled(account):
157+
"""Should all labels column be enabled."""
158+
unleash_flag = "cost-management.backend.feature-cost-3083-all-labels"
159+
account = convert_account(account)
160+
context = {"schema": account}
161+
return UNLEASH_CLIENT.is_enabled(unleash_flag, context, fallback_development_true)

0 commit comments

Comments
 (0)