@@ -49,57 +49,46 @@ def get_tag(tag: str | None) -> str:
49
49
return tag
50
50
51
51
52
- def get_orchestratord_data ( ) -> dict [str , Any ]:
52
+ def get_pod_data ( labels : dict [ str , str ], namespace = "materialize-environment" ) -> dict [str , Any ]:
53
53
return json .loads (
54
54
spawn .capture (
55
55
[
56
56
"kubectl" ,
57
57
"get" ,
58
58
"pod" ,
59
59
"-l" ,
60
- "app.kubernetes.io/instance=operator" ,
60
+ "," . join ( f" { key } = { value } " for key , value in labels . items ()) ,
61
61
"-n" ,
62
- "materialize" ,
62
+ namespace ,
63
63
"-o" ,
64
64
"json" ,
65
65
]
66
66
)
67
67
)
68
68
69
69
70
+ def get_orchestratord_data () -> dict [str , Any ]:
71
+ return get_pod_data (
72
+ labels = {"app.kubernetes.io/instance" : "operator" },
73
+ namespace = "materialize" ,
74
+ )
75
+
76
+
70
77
def get_balancerd_data () -> dict [str , Any ]:
71
- return json .loads (
72
- spawn .capture (
73
- [
74
- "kubectl" ,
75
- "get" ,
76
- "pod" ,
77
- "-l" ,
78
- "app=balancerd" ,
79
- "-n" ,
80
- "materialize-environment" ,
81
- "-o" ,
82
- "json" ,
83
- ]
84
- )
78
+ return get_pod_data (
79
+ labels = {"materialize.cloud/app" : "balancerd" },
80
+ )
81
+
82
+
83
+ def get_console_data () -> dict [str , Any ]:
84
+ return get_pod_data (
85
+ labels = {"materialize.cloud/app" : "console" },
85
86
)
86
87
87
88
88
89
def get_environmentd_data () -> dict [str , Any ]:
89
- return json .loads (
90
- spawn .capture (
91
- [
92
- "kubectl" ,
93
- "get" ,
94
- "pod" ,
95
- "-l" ,
96
- "app=environmentd" ,
97
- "-n" ,
98
- "materialize-environment" ,
99
- "-o" ,
100
- "json" ,
101
- ]
102
- )
90
+ return get_pod_data (
91
+ labels = {"materialize.cloud/app" : "environmentd" },
103
92
)
104
93
105
94
@@ -515,6 +504,53 @@ def validate(self, mods: dict[type[Modification], Any]) -> None:
515
504
), f"Expected no { expected } in environmentd args, but found it: { args } "
516
505
517
506
507
+ class BalancerdReplicas (Modification ):
508
+ @classmethod
509
+ def values (cls ) -> list [Any ]:
510
+ return [None , 1 , 2 ]
511
+
512
+ @classmethod
513
+ def default (cls ) -> Any :
514
+ return None
515
+
516
+ def modify (self , definition : dict [str , Any ]) -> None :
517
+ if self .value is not None :
518
+ definition ["materialize" ]["spec" ]["balancerdReplicas" ] = self .value
519
+
520
+ def validate (self , mods : dict [type [Modification ], Any ]) -> None :
521
+ def check_replicas ():
522
+ balancerd = get_balancerd_data ()
523
+ num_pods = len (balancerd ["items" ])
524
+ expected = self .value if self .value is not None else 2
525
+ assert num_pods == expected , f"Expected { expected } balancerd pods, but found { num_pods } "
526
+
527
+ retry (check_replicas , 5 )
528
+
529
+
530
+ class ConsoleReplicas (Modification ):
531
+ @classmethod
532
+ def values (cls ) -> list [Any ]:
533
+ return [None , 1 , 2 ]
534
+
535
+ @classmethod
536
+ def default (cls ) -> Any :
537
+ return None
538
+
539
+ def modify (self , definition : dict [str , Any ]) -> None :
540
+ if self .value is not None :
541
+ definition ["materialize" ]["spec" ]["consoleReplicas" ] = self .value
542
+
543
+ def validate (self , mods : dict [type [Modification ], Any ]) -> None :
544
+ def check_replicas ():
545
+ console = get_console_data ()
546
+ num_pods = len (console ["items" ])
547
+ expected = self .value if self .value is not None else 2
548
+ assert num_pods == expected , f"Expected { expected } console pods, but found { num_pods } "
549
+
550
+ # console doesn't get launched until last
551
+ retry (check_replicas , 120 )
552
+
553
+
518
554
def validate_cluster_replica_size (
519
555
size : dict [str , Any ], swap_enabled : bool , storage_class_name_set : bool
520
556
):
@@ -558,24 +594,6 @@ def validate_container_resources(
558
594
assert resources ["requests" ]["memory" ] == resources ["limits" ]["memory" ]
559
595
560
596
561
- def get_pod_data (labels : dict [str , str ]) -> dict [str , Any ]:
562
- return json .loads (
563
- spawn .capture (
564
- [
565
- "kubectl" ,
566
- "get" ,
567
- "pod" ,
568
- "-l" ,
569
- "," .join (f"{ key } ={ value } " for key , value in labels .items ()),
570
- "-n" ,
571
- "materialize-environment" ,
572
- "-o" ,
573
- "json" ,
574
- ]
575
- )
576
- )
577
-
578
-
579
597
class SwapEnabledGlobal (Modification ):
580
598
@classmethod
581
599
def values (cls ) -> list [Any ]:
0 commit comments