Skip to content

Commit 8482aa6

Browse files
authored
[azure][feat]: Improved AzureComputeDiskTypePricing deletion (#2231)
1 parent 5f83fed commit 8482aa6

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

plugins/azure/fix_plugin_azure/collector.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -276,20 +276,10 @@ def remove_usage_zero_value() -> None:
276276
rm_leaf_nodes(AzurePostgresqlServerType, AzureSubscription)
277277
rm_leaf_nodes(AzureCosmosDBLocation, AzureLocation, check_pred=False)
278278
rm_leaf_nodes(AzureLocation, check_pred=False)
279+
rm_leaf_nodes(AzureComputeDiskTypePricing, AzureSubscription)
279280
remove_usage_zero_value()
280281
self.graph.remove_recursively(builder.nodes(AzureLocation, lambda r: r.compute_region_in_use(builder) is False))
281282

282-
def after_collect(self, builder: GraphBuilder) -> None:
283-
# Filter unnecessary nodes such as AzureComputeDiskTypePricing
284-
nodes_to_remove = []
285-
node_types = (AzureComputeDiskTypePricing,)
286-
287-
for node in self.graph.nodes:
288-
if not isinstance(node, node_types):
289-
continue
290-
nodes_to_remove.append(node)
291-
self._delete_nodes(nodes_to_remove)
292-
293283
def _delete_nodes(self, nodes_to_delete: Any) -> None:
294284
removed = set()
295285
for node in nodes_to_delete:

plugins/azure/test/collector_test.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from fix_plugin_azure.config import AzureCredentials, AzureConfig
1212
from fix_plugin_azure.resource.base import MicrosoftResource, AzureSubscription, GraphBuilder
1313
from fix_plugin_azure.resource.compute import (
14-
AzureComputeDiskTypePricing,
1514
AzureComputeVirtualMachine,
1615
AzureComputeVirtualMachineSize,
1716
AzureComputeDisk,
@@ -65,8 +64,6 @@ def test_filter(credentials: AzureCredentials, builder: GraphBuilder) -> None:
6564
AzureComputeVirtualMachineSize.collect(raw=json.load(f)["value"], builder=builder)
6665
with open(os.path.dirname(__file__) + "/files/compute/virtualMachines.json") as f:
6766
AzureComputeVirtualMachine.collect(raw=json.load(f)["value"], builder=builder)
68-
with open(os.path.dirname(__file__) + "/files/compute/calculator.json") as f:
69-
AzureComputeDiskTypePricing.collect(raw=json.load(f), builder=builder)
7067

7168
collector = collector_with_graph(builder.graph, credentials)
7269

@@ -78,13 +75,6 @@ def test_filter(credentials: AzureCredentials, builder: GraphBuilder) -> None:
7875
num_all_virtual_machine_types
7976
)
8077

81-
pricing_info = list(collector.graph.search("kind", "azure_compute_disk_type_pricing"))
82-
83-
assert len(pricing_info) > 0
84-
85-
collector.after_collect(builder)
86-
assert len(list(collector.graph.search("kind", "azure_compute_disk_type_pricing"))) < len(pricing_info)
87-
8878

8979
def test_collect_cost(credentials: AzureCredentials, builder: GraphBuilder) -> None:
9080
with open(os.path.dirname(__file__) + "/files/compute/vmSizes.json") as f:

0 commit comments

Comments
 (0)