@@ -1530,35 +1530,31 @@ def compute_diff(self): # noqa: C901
1530
1530
conn_graph_removed_per_key [key ] = self .get_conn_graph_changed_conns (key , old_ip_blocks , False )
1531
1531
conn_graph_added_per_key [key ] = None
1532
1532
for pair in itertools .product (removed_peers , old_ip_blocks ):
1533
- if not self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [0 ], pair [1 ]):
1534
- continue
1535
- lost_conns , _ , _ , _ = self .config1 .allowed_connections (pair [0 ], pair [1 ])
1536
- if lost_conns :
1537
- conn_graph_removed_per_key [key ].add_edge (pair [0 ], pair [1 ], lost_conns )
1533
+ if self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [0 ], pair [1 ]):
1534
+ lost_conns , _ , _ , _ = self .config1 .allowed_connections (pair [0 ], pair [1 ])
1535
+ if lost_conns :
1536
+ conn_graph_removed_per_key [key ].add_edge (pair [0 ], pair [1 ], lost_conns )
1538
1537
1539
- if not self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [1 ], pair [0 ]):
1540
- continue
1541
- lost_conns , _ , _ , _ = self .config1 .allowed_connections (pair [1 ], pair [0 ])
1542
- if lost_conns :
1543
- conn_graph_removed_per_key [key ].add_edge (pair [1 ], pair [0 ], lost_conns )
1538
+ if self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [1 ], pair [0 ]):
1539
+ lost_conns , _ , _ , _ = self .config1 .allowed_connections (pair [1 ], pair [0 ])
1540
+ if lost_conns :
1541
+ conn_graph_removed_per_key [key ].add_edge (pair [1 ], pair [0 ], lost_conns )
1544
1542
1545
1543
# 2.1. lost connections between removed peers and intersected peers
1546
1544
key = 'Lost connections between removed peers and persistent peers'
1547
1545
keys_list .append (key )
1548
1546
conn_graph_removed_per_key [key ] = self .get_conn_graph_changed_conns (key , PeerSet (), False )
1549
1547
conn_graph_added_per_key [key ] = None
1550
1548
for pair in itertools .product (removed_peers , intersected_peers ):
1551
- if not self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [0 ], pair [1 ]):
1552
- continue
1553
- lost_conns , _ , _ , _ = self .config1 .allowed_connections (pair [0 ], pair [1 ])
1554
- if lost_conns :
1555
- conn_graph_removed_per_key [key ].add_edge (pair [0 ], pair [1 ], lost_conns )
1549
+ if self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [0 ], pair [1 ]):
1550
+ lost_conns , _ , _ , _ = self .config1 .allowed_connections (pair [0 ], pair [1 ])
1551
+ if lost_conns :
1552
+ conn_graph_removed_per_key [key ].add_edge (pair [0 ], pair [1 ], lost_conns )
1556
1553
1557
- if not self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [1 ], pair [0 ]):
1558
- continue
1559
- lost_conns , _ , _ , _ = self .config1 .allowed_connections (pair [1 ], pair [0 ])
1560
- if lost_conns :
1561
- conn_graph_removed_per_key [key ].add_edge (pair [1 ], pair [0 ], lost_conns )
1554
+ if self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [1 ], pair [0 ]):
1555
+ lost_conns , _ , _ , _ = self .config1 .allowed_connections (pair [1 ], pair [0 ])
1556
+ if lost_conns :
1557
+ conn_graph_removed_per_key [key ].add_edge (pair [1 ], pair [0 ], lost_conns )
1562
1558
1563
1559
# 3.1. lost/new connections between intersected peers due to changes in policies and labels of pods/namespaces
1564
1560
key = 'Changed connections between persistent peers'
@@ -1600,17 +1596,15 @@ def compute_diff(self): # noqa: C901
1600
1596
conn_graph_removed_per_key [key ] = None
1601
1597
conn_graph_added_per_key [key ] = self .get_conn_graph_changed_conns (key , PeerSet (), True )
1602
1598
for pair in itertools .product (intersected_peers , added_peers ):
1603
- if not self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [0 ], pair [1 ]):
1604
- continue
1605
- new_conns , _ , _ , _ = self .config2 .allowed_connections (pair [0 ], pair [1 ])
1606
- if new_conns :
1607
- conn_graph_added_per_key [key ].add_edge (pair [0 ], pair [1 ], new_conns )
1599
+ if self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [0 ], pair [1 ]):
1600
+ new_conns , _ , _ , _ = self .config2 .allowed_connections (pair [0 ], pair [1 ])
1601
+ if new_conns :
1602
+ conn_graph_added_per_key [key ].add_edge (pair [0 ], pair [1 ], new_conns )
1608
1603
1609
- if not self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [1 ], pair [0 ]):
1610
- continue
1611
- new_conns , _ , _ , _ = self .config2 .allowed_connections (pair [1 ], pair [0 ])
1612
- if new_conns :
1613
- conn_graph_added_per_key [key ].add_edge (pair [1 ], pair [0 ], new_conns )
1604
+ if self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [1 ], pair [0 ]):
1605
+ new_conns , _ , _ , _ = self .config2 .allowed_connections (pair [1 ], pair [0 ])
1606
+ if new_conns :
1607
+ conn_graph_added_per_key [key ].add_edge (pair [1 ], pair [0 ], new_conns )
1614
1608
1615
1609
# 5.1. new connections between added peers
1616
1610
key = 'New connections between added peers'
@@ -1631,17 +1625,15 @@ def compute_diff(self): # noqa: C901
1631
1625
conn_graph_added_per_key [key ] = self .get_conn_graph_changed_conns (key , new_ip_blocks , True )
1632
1626
1633
1627
for pair in itertools .product (added_peers , new_ip_blocks ):
1634
- if not self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [0 ], pair [1 ]):
1635
- continue
1636
- new_conns , _ , _ , _ = self .config2 .allowed_connections (pair [0 ], pair [1 ])
1637
- if new_conns :
1638
- conn_graph_added_per_key [key ].add_edge (pair [0 ], pair [1 ], new_conns )
1639
-
1640
- if not self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [1 ], pair [0 ]):
1641
- continue
1642
- new_conns , _ , _ , _ = self .config2 .allowed_connections (pair [1 ], pair [0 ])
1643
- if new_conns :
1644
- conn_graph_added_per_key [key ].add_edge (pair [1 ], pair [0 ], new_conns )
1628
+ if self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [0 ], pair [1 ]):
1629
+ new_conns , _ , _ , _ = self .config2 .allowed_connections (pair [0 ], pair [1 ])
1630
+ if new_conns :
1631
+ conn_graph_added_per_key [key ].add_edge (pair [0 ], pair [1 ], new_conns )
1632
+
1633
+ if self .determine_whether_to_compute_allowed_conns_for_peer_types (pair [1 ], pair [0 ]):
1634
+ new_conns , _ , _ , _ = self .config2 .allowed_connections (pair [1 ], pair [0 ])
1635
+ if new_conns :
1636
+ conn_graph_added_per_key [key ].add_edge (pair [1 ], pair [0 ], new_conns )
1645
1637
1646
1638
return self .get_results_for_computed_fw_rules (keys_list , conn_graph_removed_per_key ,
1647
1639
conn_graph_added_per_key )
0 commit comments