@@ -2410,9 +2410,23 @@ def test_topology_spread_constraints(self):
24102410 k8s .api .core_v1 .patch_node (master_nodes [0 ], patch_node_label )
24112411 k8s .api .core_v1 .patch_node (replica_nodes [0 ], patch_node_label )
24122412
2413- # Scale-out postgresql pods
2414- k8s .api .custom_objects_api .patch_namespaced_custom_object ("acid.zalan.do" , "v1" , "default" , "postgresqls" , "acid-minimal-cluster" ,
2415- {"spec" : {"numberOfInstances" : 6 }})
2413+ # Patch topologySpreadConstraint and scale-out postgresql pods to postgresqls manifest.
2414+ patch_topologySpreadConstraint_config = {
2415+ "spec" : {
2416+ "numberOfInstances" : 6 ,
2417+ "topologySpreadConstraint" : [
2418+ {
2419+ "maxskew" : 1 ,
2420+ "topologyKey" : "topology.kubernetes.io/zone" ,
2421+ "whenUnsatisfiable" : "DoNotSchedule"
2422+ }
2423+ ]
2424+ }
2425+ }
2426+ k8s .api .custom_objects_api .patch_namespaced_custom_object (
2427+ "acid.zalan.do" , "v1" , "default" ,
2428+ "postgresqls" , "acid-minimal-cluster" ,
2429+ patch_topologySpreadConstraint_config )
24162430 self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
24172431 self .eventuallyEqual (lambda : k8s .count_pods_with_label (cluster_labels ), 6 , "Postgresql StatefulSet are scale to 6" )
24182432 self .eventuallyEqual (lambda : k8s .count_running_pods (), 6 , "All pods are running" )
@@ -2430,9 +2444,17 @@ def test_topology_spread_constraints(self):
24302444 self .assertEqual (worker_node_1 , 3 )
24312445 self .assertEqual (worker_node_2 , 3 )
24322446
2433- # Scale-it postgresql pods to previous replicas
2434- k8s .api .custom_objects_api .patch_namespaced_custom_object ("acid.zalan.do" , "v1" , "default" , "postgresqls" , "acid-minimal-cluster" ,
2435- {"spec" : {"numberOfInstances" : 2 }})
2447+ # Reset configurations
2448+ patch_topologySpreadConstraint_config = {
2449+ "spec" : {
2450+ "numberOfInstances" : 2 ,
2451+ "topologySpreadConstraint" : []
2452+ }
2453+ }
2454+ k8s .api .custom_objects_api .patch_namespaced_custom_object (
2455+ "acid.zalan.do" , "v1" , "default" ,
2456+ "postgresqls" , "acid-minimal-cluster" ,
2457+ patch_topologySpreadConstraint_config )
24362458
24372459 @timeout_decorator .timeout (TEST_TIMEOUT_SEC )
24382460 def test_zz_cluster_deletion (self ):
0 commit comments