Skip to content

Commit 94576a4

Browse files
authored
Merge pull request #87 from numtide/fix-resource-handler-to-match-with-api-change
Fix API mismatch for resource-handler
2 parents c9d0741 + a19042d commit 94576a4

28 files changed

+2420
-1432
lines changed

pkg/resource-handler/controller/cell/cell_controller.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,6 @@ func (r *CellReconciler) updateStatus(ctx context.Context, cell *multigresv1alph
188188
return fmt.Errorf("failed to get MultiGateway Deployment for status: %w", err)
189189
}
190190

191-
// Update status fields
192-
cell.Status.ObservedGeneration = cell.Generation
193-
194191
// Update conditions
195192
cell.Status.Conditions = r.buildConditions(cell, mgDeploy)
196193

pkg/resource-handler/controller/cell/cell_controller_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ func TestCellReconciler_Reconcile(t *testing.T) {
9797
MultiGateway: multigresv1alpha1.StatelessSpec{
9898
Replicas: ptr.To(int32(5)),
9999
},
100-
Images: multigresv1alpha1.CellImagesSpec{
101-
MultiGateway: "custom/multigateway:v1.0.0",
102-
},
100+
MultiGatewayImage: "custom/multigateway:v1.0.0",
103101
},
104102
},
105103
existingObjects: []client.Object{

pkg/resource-handler/controller/cell/integration_test.go

Lines changed: 73 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,18 @@ func TestCellReconciliation(t *testing.T) {
6868
},
6969
Spec: multigresv1alpha1.CellSpec{
7070
Name: "zone1",
71+
Zone: "us-west-1a",
7172
MultiGateway: multigresv1alpha1.StatelessSpec{
7273
Replicas: ptr.To(int32(2)),
7374
},
74-
MultiOrch: multigresv1alpha1.StatelessSpec{
75-
Replicas: ptr.To(int32(2)),
75+
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRef{
76+
Address: "global-topo:2379",
77+
RootPath: "/multigres/global",
78+
Implementation: "etcd2",
7679
},
77-
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRefSpec{
78-
ClientServiceName: "global-topo",
80+
TopoServer: &multigresv1alpha1.LocalTopoServerSpec{
81+
Etcd: &multigresv1alpha1.EtcdSpec{},
7982
},
80-
TopoServer: multigresv1alpha1.CellTopoServerSpec{},
8183
},
8284
},
8385
wantResources: []client.Object{
@@ -101,7 +103,17 @@ func TestCellReconciliation(t *testing.T) {
101103
Containers: []corev1.Container{
102104
{
103105
Name: "multigateway",
104-
Image: "numtide/multigres-operator:latest",
106+
Image: "ghcr.io/multigres/multigres:latest",
107+
Args: []string{
108+
"multigateway",
109+
"--http-port", "15100",
110+
"--grpc-port", "15170",
111+
"--pg-port", "15432",
112+
"--topo-global-server-addresses", "global-topo:2379",
113+
"--topo-global-root", "/multigres/global",
114+
"--topo-implementation", "etcd2",
115+
"--cell", "zone1",
116+
},
105117
Ports: []corev1.ContainerPort{
106118
tcpPort(t, "http", 15100),
107119
tcpPort(t, "grpc", 15170),
@@ -140,16 +152,18 @@ func TestCellReconciliation(t *testing.T) {
140152
},
141153
Spec: multigresv1alpha1.CellSpec{
142154
Name: "zone2",
155+
Zone: "us-west-1b",
143156
MultiGateway: multigresv1alpha1.StatelessSpec{
144157
Replicas: ptr.To(int32(3)),
145158
},
146-
MultiOrch: multigresv1alpha1.StatelessSpec{
147-
Replicas: ptr.To(int32(3)),
159+
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRef{
160+
Address: "global-topo:2379",
161+
RootPath: "/multigres/global",
162+
Implementation: "etcd2",
148163
},
149-
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRefSpec{
150-
ClientServiceName: "global-topo",
164+
TopoServer: &multigresv1alpha1.LocalTopoServerSpec{
165+
Etcd: &multigresv1alpha1.EtcdSpec{},
151166
},
152-
TopoServer: multigresv1alpha1.CellTopoServerSpec{},
153167
},
154168
},
155169
wantResources: []client.Object{
@@ -173,7 +187,17 @@ func TestCellReconciliation(t *testing.T) {
173187
Containers: []corev1.Container{
174188
{
175189
Name: "multigateway",
176-
Image: "numtide/multigres-operator:latest",
190+
Image: "ghcr.io/multigres/multigres:latest",
191+
Args: []string{
192+
"multigateway",
193+
"--http-port", "15100",
194+
"--grpc-port", "15170",
195+
"--pg-port", "15432",
196+
"--topo-global-server-addresses", "global-topo:2379",
197+
"--topo-global-root", "/multigres/global",
198+
"--topo-implementation", "etcd2",
199+
"--cell", "zone2",
200+
},
177201
Ports: []corev1.ContainerPort{
178202
tcpPort(t, "http", 15100),
179203
tcpPort(t, "grpc", 15170),
@@ -211,21 +235,20 @@ func TestCellReconciliation(t *testing.T) {
211235
Namespace: "default",
212236
},
213237
Spec: multigresv1alpha1.CellSpec{
214-
Name: "zone3",
215-
Images: multigresv1alpha1.CellImagesSpec{
216-
MultiGateway: "custom/multigateway:v1.0.0",
217-
MultiOrch: "custom/multiorch:v1.0.0",
218-
},
238+
Name: "zone3",
239+
Zone: "us-west-1c",
240+
MultiGatewayImage: "custom/multigateway:v1.0.0",
219241
MultiGateway: multigresv1alpha1.StatelessSpec{
220242
Replicas: ptr.To(int32(2)),
221243
},
222-
MultiOrch: multigresv1alpha1.StatelessSpec{
223-
Replicas: ptr.To(int32(2)),
244+
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRef{
245+
Address: "global-topo:2379",
246+
RootPath: "/multigres/global",
247+
Implementation: "etcd2",
224248
},
225-
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRefSpec{
226-
ClientServiceName: "global-topo",
249+
TopoServer: &multigresv1alpha1.LocalTopoServerSpec{
250+
Etcd: &multigresv1alpha1.EtcdSpec{},
227251
},
228-
TopoServer: multigresv1alpha1.CellTopoServerSpec{},
229252
},
230253
},
231254
wantResources: []client.Object{
@@ -250,6 +273,16 @@ func TestCellReconciliation(t *testing.T) {
250273
{
251274
Name: "multigateway",
252275
Image: "custom/multigateway:v1.0.0",
276+
Args: []string{
277+
"multigateway",
278+
"--http-port", "15100",
279+
"--grpc-port", "15170",
280+
"--pg-port", "15432",
281+
"--topo-global-server-addresses", "global-topo:2379",
282+
"--topo-global-root", "/multigres/global",
283+
"--topo-implementation", "etcd2",
284+
"--cell", "zone3",
285+
},
253286
Ports: []corev1.ContainerPort{
254287
tcpPort(t, "http", 15100),
255288
tcpPort(t, "grpc", 15170),
@@ -288,6 +321,7 @@ func TestCellReconciliation(t *testing.T) {
288321
},
289322
Spec: multigresv1alpha1.CellSpec{
290323
Name: "zone4",
324+
Zone: "us-west-1d",
291325
MultiGateway: multigresv1alpha1.StatelessSpec{
292326
Replicas: ptr.To(int32(2)),
293327
Affinity: &corev1.Affinity{
@@ -308,30 +342,14 @@ func TestCellReconciliation(t *testing.T) {
308342
},
309343
},
310344
},
311-
MultiOrch: multigresv1alpha1.StatelessSpec{
312-
Replicas: ptr.To(int32(2)),
313-
Affinity: &corev1.Affinity{
314-
PodAntiAffinity: &corev1.PodAntiAffinity{
315-
PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{
316-
{
317-
Weight: 100,
318-
PodAffinityTerm: corev1.PodAffinityTerm{
319-
LabelSelector: &metav1.LabelSelector{
320-
MatchLabels: map[string]string{
321-
"app.kubernetes.io/component": "multiorch",
322-
},
323-
},
324-
TopologyKey: "kubernetes.io/hostname",
325-
},
326-
},
327-
},
328-
},
329-
},
345+
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRef{
346+
Address: "global-topo:2379",
347+
RootPath: "/multigres/global",
348+
Implementation: "etcd2",
330349
},
331-
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRefSpec{
332-
ClientServiceName: "global-topo",
350+
TopoServer: &multigresv1alpha1.LocalTopoServerSpec{
351+
Etcd: &multigresv1alpha1.EtcdSpec{},
333352
},
334-
TopoServer: multigresv1alpha1.CellTopoServerSpec{},
335353
},
336354
},
337355
wantResources: []client.Object{
@@ -355,7 +373,17 @@ func TestCellReconciliation(t *testing.T) {
355373
Containers: []corev1.Container{
356374
{
357375
Name: "multigateway",
358-
Image: "numtide/multigres-operator:latest",
376+
Image: "ghcr.io/multigres/multigres:latest",
377+
Args: []string{
378+
"multigateway",
379+
"--http-port", "15100",
380+
"--grpc-port", "15170",
381+
"--pg-port", "15432",
382+
"--topo-global-server-addresses", "global-topo:2379",
383+
"--topo-global-root", "/multigres/global",
384+
"--topo-implementation", "etcd2",
385+
"--cell", "zone4",
386+
},
359387
Ports: []corev1.ContainerPort{
360388
tcpPort(t, "http", 15100),
361389
tcpPort(t, "grpc", 15170),

pkg/resource-handler/controller/cell/multigateway.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
DefaultMultiGatewayReplicas int32 = 2
2323

2424
// DefaultMultiGatewayImage is the default MultiGateway container image
25-
DefaultMultiGatewayImage = "numtide/multigres-operator:latest"
25+
DefaultMultiGatewayImage = "ghcr.io/multigres/multigres:latest"
2626

2727
// MultiGatewayHTTPPort is the default port for HTTP connections
2828
MultiGatewayHTTPPort int32 = 15100
@@ -45,8 +45,8 @@ func BuildMultiGatewayDeployment(
4545
}
4646

4747
image := DefaultMultiGatewayImage
48-
if cell.Spec.Images.MultiGateway != "" {
49-
image = cell.Spec.Images.MultiGateway
48+
if cell.Spec.MultiGatewayImage != "" {
49+
image = cell.Spec.MultiGatewayImage
5050
}
5151

5252
name := cell.Name + "-multigateway"
@@ -70,9 +70,19 @@ func BuildMultiGatewayDeployment(
7070
Spec: corev1.PodSpec{
7171
Containers: []corev1.Container{
7272
{
73-
Name: "multigateway",
74-
Image: image,
75-
Resources: cell.Spec.MultiGateway.ResourceRequirements,
73+
Name: "multigateway",
74+
Image: image,
75+
Args: []string{
76+
"multigateway",
77+
"--http-port", fmt.Sprintf("%d", MultiGatewayHTTPPort),
78+
"--grpc-port", fmt.Sprintf("%d", MultiGatewayGRPCPort),
79+
"--pg-port", fmt.Sprintf("%d", MultiGatewayPostgresPort),
80+
"--topo-global-server-addresses", cell.Spec.GlobalTopoServer.Address,
81+
"--topo-global-root", cell.Spec.GlobalTopoServer.RootPath,
82+
"--topo-implementation", cell.Spec.GlobalTopoServer.Implementation,
83+
"--cell", cell.Spec.Name,
84+
},
85+
Resources: cell.Spec.MultiGateway.Resources,
7686
Ports: []corev1.ContainerPort{
7787
{
7888
Name: "http",

0 commit comments

Comments
 (0)