Skip to content

Commit

Permalink
Remove costanalysis preview, it is GA now (#7851)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthchr committed Aug 6, 2024
1 parent 5ac5e72 commit 36e479b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 133 deletions.
6 changes: 3 additions & 3 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ def load_arguments(self, _):
c.argument("grafana_resource_id", validator=validate_grafanaresourceid)
c.argument("enable_windows_recording_rules", action="store_true")
c.argument("enable_azure_monitor_app_monitoring", is_preview=True, action="store_true")
c.argument("enable_cost_analysis", is_preview=True, action="store_true")
c.argument("enable_cost_analysis", action="store_true")
c.argument('enable_ai_toolchain_operator', is_preview=True, action='store_true')
# azure container storage
c.argument(
Expand Down Expand Up @@ -1312,8 +1312,8 @@ def load_arguments(self, _):
action="store_true",
is_preview=True,
)
c.argument("enable_cost_analysis", is_preview=True, action="store_true")
c.argument("disable_cost_analysis", is_preview=True, action="store_true")
c.argument("enable_cost_analysis", action="store_true")
c.argument("disable_cost_analysis", action="store_true")
c.argument('enable_ai_toolchain_operator', is_preview=True, action='store_true')
c.argument('disable_ai_toolchain_operator', is_preview=True, action='store_true')
# azure container storage
Expand Down
98 changes: 0 additions & 98 deletions src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2689,41 +2689,6 @@ def get_nodepool_initialization_taints(self) -> Union[List[str], None]:
"""
return self.agentpool_context.get_node_initialization_taints()

def _get_enable_cost_analysis(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_cost_analysis.
When enabled, if both enable_cost_analysis and disable_cost_analysis are
specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
enable_cost_analysis = self.raw_param.get("enable_cost_analysis")

# This parameter does not need dynamic completion.
if enable_validation:
if enable_cost_analysis and self.get_disable_cost_analysis():
raise MutuallyExclusiveArgumentError(
"Cannot specify --enable-cost-analysis and --disable-cost-analysis at the same time."
)

return enable_cost_analysis

def get_enable_cost_analysis(self) -> bool:
"""Obtain the value of enable_cost_analysis.
:return: bool
"""
return self._get_enable_cost_analysis(enable_validation=True)

def get_disable_cost_analysis(self) -> bool:
"""Obtain the value of disable_cost_analysis.
:return: bool
"""
# Note: No need to check for mutually exclusive parameter with enable-cost-analysis here
# because it's already checked in _get_enable_cost_analysis
return self.raw_param.get("disable_cost_analysis")

def get_keyvault_id(self) -> str:
"""Obtain the value of keyvault_id.
Expand Down Expand Up @@ -3519,31 +3484,6 @@ def set_up_k8s_support_plan(self, mc: ManagedCluster) -> ManagedCluster:
mc.support_plan = support_plan
return mc

def set_up_cost_analysis(self, mc: ManagedCluster) -> ManagedCluster:
self._ensure_mc(mc)

if self.context.get_enable_cost_analysis():
if mc.metrics_profile is None:
mc.metrics_profile = self.models.ManagedClusterMetricsProfile() # pylint: disable=no-member
if mc.metrics_profile.cost_analysis is None:
mc.metrics_profile.cost_analysis = (
self.models.ManagedClusterCostAnalysis() # pylint: disable=no-member
)

# set enabled
mc.metrics_profile.cost_analysis.enabled = True

# Default is disabled so no need to worry about that here

return mc

def set_up_metrics_profile(self, mc: ManagedCluster) -> ManagedCluster:
self._ensure_mc(mc)

mc = self.set_up_cost_analysis(mc)

return mc

def set_up_node_provisioning_mode(self, mc: ManagedCluster) -> ManagedCluster:
self._ensure_mc(mc)

Expand Down Expand Up @@ -3684,8 +3624,6 @@ def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) ->
mc = self.set_up_k8s_support_plan(mc)
# set up azure monitor profile
mc = self.set_up_azure_monitor_profile(mc)
# set up metrics profile
mc = self.set_up_metrics_profile(mc)
# set up AI toolchain operator
mc = self.set_up_ai_toolchain_operator(mc)
# set up for azure container storage
Expand Down Expand Up @@ -5070,29 +5008,6 @@ def update_nodepool_initialization_taints_mc(self, mc: ManagedCluster) -> Manage
agent_profile.node_initialization_taints = nodepool_initialization_taints
return mc

def update_cost_analysis(self, mc: ManagedCluster) -> ManagedCluster:
self._ensure_mc(mc)

if self.context.get_enable_cost_analysis():
if mc.metrics_profile is None:
mc.metrics_profile = self.models.ManagedClusterMetricsProfile() # pylint: disable=no-member
if mc.metrics_profile.cost_analysis is None:
mc.metrics_profile.cost_analysis = self.models.ManagedClusterCostAnalysis() # pylint: disable=no-member

# set enabled
mc.metrics_profile.cost_analysis.enabled = True

if self.context.get_disable_cost_analysis():
if mc.metrics_profile is None:
mc.metrics_profile = self.models.ManagedClusterMetricsProfile() # pylint: disable=no-member
if mc.metrics_profile.cost_analysis is None:
mc.metrics_profile.cost_analysis = self.models.ManagedClusterCostAnalysis() # pylint: disable=no-member

# set disabled
mc.metrics_profile.cost_analysis.enabled = False

return mc

def update_node_provisioning_mode(self, mc: ManagedCluster) -> ManagedCluster:
self._ensure_mc(mc)

Expand All @@ -5108,17 +5023,6 @@ def update_node_provisioning_mode(self, mc: ManagedCluster) -> ManagedCluster:

return mc

def update_metrics_profile(self, mc: ManagedCluster) -> ManagedCluster:
"""Updates the metricsProfile field of the managed cluster
:return: the ManagedCluster object
"""
self._ensure_mc(mc)

mc = self.update_cost_analysis(mc)

return mc

# pylint: disable=too-many-branches
def update_app_routing_profile(self, mc: ManagedCluster) -> ManagedCluster:
"""Update app routing profile for the ManagedCluster object.
Expand Down Expand Up @@ -5439,8 +5343,6 @@ def update_mc_profile_preview(self) -> ManagedCluster:
mc = self.update_enable_advanced_network_observability_in_network_profile(mc)
# update kubernetes support plan
mc = self.update_k8s_support_plan(mc)
# update metrics profile
mc = self.update_metrics_profile(mc)
# update AI toolchain operator
mc = self.update_ai_toolchain_operator(mc)
# update azure container storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7996,38 +7996,6 @@ def test_update_upgrade_settings(self):
with self.assertRaises(InvalidArgumentValueError):
dec_6.update_upgrade_settings(mc_6)

def test_enable_disable_cost_analysis(self):
# Should not update mc if unset
dec_0 = AKSPreviewManagedClusterUpdateDecorator(
self.cmd,
self.client,
{},
CUSTOM_MGMT_AKS_PREVIEW,
)
mc_0 = self.models.ManagedCluster(
location="test_location",
)
dec_0.context.attach_mc(mc_0)
dec_mc_0 = dec_0.update_metrics_profile(mc_0)
ground_truth_mc_0 = self.models.ManagedCluster(
location="test_location",
)
self.assertEqual(dec_mc_0, ground_truth_mc_0)

# Should error if both set
dec_6 = AKSPreviewManagedClusterUpdateDecorator(
self.cmd,
self.client,
{"disable_cost_analysis": True, "enable_cost_analysis": True},
CUSTOM_MGMT_AKS_PREVIEW,
)
mc_6 = self.models.ManagedCluster(
location="test_location",
)
dec_6.context.attach_mc(mc_6)
with self.assertRaises(MutuallyExclusiveArgumentError):
dec_6.update_metrics_profile(mc_6)

def test_update_addon_autoscaling(self):
# Should not update mc if unset
dec_0 = AKSPreviewManagedClusterUpdateDecorator(
Expand Down

0 comments on commit 36e479b

Please sign in to comment.