@@ -56,57 +56,48 @@ def get_image(image: str, tag: str | None) -> str:
56
56
return f'{ image .rsplit (":" , 1 )[0 ]} :{ tag } '
57
57
58
58
59
- def get_orchestratord_data () -> dict [str , Any ]:
59
+ def get_pod_data (
60
+ labels : dict [str , str ], namespace = "materialize-environment"
61
+ ) -> dict [str , Any ]:
60
62
return json .loads (
61
63
spawn .capture (
62
64
[
63
65
"kubectl" ,
64
66
"get" ,
65
67
"pod" ,
66
68
"-l" ,
67
- "app.kubernetes.io/instance=operator" ,
69
+ "," . join ( f" { key } = { value } " for key , value in labels . items ()) ,
68
70
"-n" ,
69
- "materialize" ,
71
+ namespace ,
70
72
"-o" ,
71
73
"json" ,
72
74
]
73
75
)
74
76
)
75
77
76
78
79
+ def get_orchestratord_data () -> dict [str , Any ]:
80
+ return get_pod_data (
81
+ labels = {"app.kubernetes.io/instance" : "operator" },
82
+ namespace = "materialize" ,
83
+ )
84
+
85
+
77
86
def get_balancerd_data () -> dict [str , Any ]:
78
- return json .loads (
79
- spawn .capture (
80
- [
81
- "kubectl" ,
82
- "get" ,
83
- "pod" ,
84
- "-l" ,
85
- "app=balancerd" ,
86
- "-n" ,
87
- "materialize-environment" ,
88
- "-o" ,
89
- "json" ,
90
- ]
91
- )
87
+ return get_pod_data (
88
+ labels = {"materialize.cloud/app" : "balancerd" },
89
+ )
90
+
91
+
92
+ def get_console_data () -> dict [str , Any ]:
93
+ return get_pod_data (
94
+ labels = {"materialize.cloud/app" : "console" },
92
95
)
93
96
94
97
95
98
def get_environmentd_data () -> dict [str , Any ]:
96
- return json .loads (
97
- spawn .capture (
98
- [
99
- "kubectl" ,
100
- "get" ,
101
- "pod" ,
102
- "-l" ,
103
- "app=environmentd" ,
104
- "-n" ,
105
- "materialize-environment" ,
106
- "-o" ,
107
- "json" ,
108
- ]
109
- )
99
+ return get_pod_data (
100
+ labels = {"materialize.cloud/app" : "environmentd" },
110
101
)
111
102
112
103
@@ -528,6 +519,63 @@ def validate(self, mods: dict[type[Modification], Any]) -> None:
528
519
), f"Expected no { expected } in environmentd args, but found it: { args } "
529
520
530
521
522
+ class BalancerdReplicas (Modification ):
523
+ @classmethod
524
+ def values (cls ) -> list [Any ]:
525
+ return [None , 1 , 2 ]
526
+
527
+ @classmethod
528
+ def default (cls ) -> Any :
529
+ return None
530
+
531
+ def modify (self , definition : dict [str , Any ]) -> None :
532
+ if self .value is not None :
533
+ definition ["materialize" ]["spec" ]["balancerdReplicas" ] = self .value
534
+
535
+ def validate (self , mods : dict [type [Modification ], Any ]) -> None :
536
+ if not mods [BalancerdEnabled ]:
537
+ return
538
+
539
+ def check_replicas ():
540
+ balancerd = get_balancerd_data ()
541
+ num_pods = len (balancerd ["items" ])
542
+ expected = self .value if self .value is not None else 2
543
+ assert (
544
+ num_pods == expected
545
+ ), f"Expected { expected } balancerd pods, but found { num_pods } "
546
+
547
+ retry (check_replicas , 120 )
548
+
549
+
550
+ class ConsoleReplicas (Modification ):
551
+ @classmethod
552
+ def values (cls ) -> list [Any ]:
553
+ return [None , 1 , 2 ]
554
+
555
+ @classmethod
556
+ def default (cls ) -> Any :
557
+ return None
558
+
559
+ def modify (self , definition : dict [str , Any ]) -> None :
560
+ if self .value is not None :
561
+ definition ["materialize" ]["spec" ]["consoleReplicas" ] = self .value
562
+
563
+ def validate (self , mods : dict [type [Modification ], Any ]) -> None :
564
+ if not mods [ConsoleEnabled ]:
565
+ return
566
+
567
+ def check_replicas ():
568
+ console = get_console_data ()
569
+ num_pods = len (console ["items" ])
570
+ expected = self .value if self .value is not None else 2
571
+ assert (
572
+ num_pods == expected
573
+ ), f"Expected { expected } console pods, but found { num_pods } "
574
+
575
+ # console doesn't get launched until last
576
+ retry (check_replicas , 120 )
577
+
578
+
531
579
def validate_cluster_replica_size (
532
580
size : dict [str , Any ], swap_enabled : bool , storage_class_name_set : bool
533
581
):
@@ -571,24 +619,6 @@ def validate_container_resources(
571
619
assert resources ["requests" ]["memory" ] == resources ["limits" ]["memory" ]
572
620
573
621
574
- def get_pod_data (labels : dict [str , str ]) -> dict [str , Any ]:
575
- return json .loads (
576
- spawn .capture (
577
- [
578
- "kubectl" ,
579
- "get" ,
580
- "pod" ,
581
- "-l" ,
582
- "," .join (f"{ key } ={ value } " for key , value in labels .items ()),
583
- "-n" ,
584
- "materialize-environment" ,
585
- "-o" ,
586
- "json" ,
587
- ]
588
- )
589
- )
590
-
591
-
592
622
class SwapEnabledGlobal (Modification ):
593
623
@classmethod
594
624
def values (cls ) -> list [Any ]:
0 commit comments