Skip to content

Commit 92feac6

Browse files
committed
resource-handler: fix API mismatch
1 parent 7c2d82e commit 92feac6

25 files changed

+621
-834
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: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,12 @@ func TestCellReconciliation(t *testing.T) {
7171
MultiGateway: multigresv1alpha1.StatelessSpec{
7272
Replicas: ptr.To(int32(2)),
7373
},
74-
MultiOrch: multigresv1alpha1.StatelessSpec{
75-
Replicas: ptr.To(int32(2)),
76-
},
77-
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRefSpec{
78-
ClientServiceName: "global-topo",
74+
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRef{
75+
Address: "global-topo:2379",
76+
RootPath: "/vitess/global",
77+
Implementation: "etcd2",
7978
},
80-
TopoServer: multigresv1alpha1.CellTopoServerSpec{},
79+
TopoServer: &multigresv1alpha1.LocalTopoServerSpec{},
8180
},
8281
},
8382
wantResources: []client.Object{
@@ -143,13 +142,12 @@ func TestCellReconciliation(t *testing.T) {
143142
MultiGateway: multigresv1alpha1.StatelessSpec{
144143
Replicas: ptr.To(int32(3)),
145144
},
146-
MultiOrch: multigresv1alpha1.StatelessSpec{
147-
Replicas: ptr.To(int32(3)),
145+
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRef{
146+
Address: "global-topo:2379",
147+
RootPath: "/vitess/global",
148+
Implementation: "etcd2",
148149
},
149-
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRefSpec{
150-
ClientServiceName: "global-topo",
151-
},
152-
TopoServer: multigresv1alpha1.CellTopoServerSpec{},
150+
TopoServer: &multigresv1alpha1.LocalTopoServerSpec{},
153151
},
154152
},
155153
wantResources: []client.Object{
@@ -211,21 +209,17 @@ func TestCellReconciliation(t *testing.T) {
211209
Namespace: "default",
212210
},
213211
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-
},
212+
Name: "zone3",
213+
MultiGatewayImage: "custom/multigateway:v1.0.0",
219214
MultiGateway: multigresv1alpha1.StatelessSpec{
220215
Replicas: ptr.To(int32(2)),
221216
},
222-
MultiOrch: multigresv1alpha1.StatelessSpec{
223-
Replicas: ptr.To(int32(2)),
224-
},
225-
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRefSpec{
226-
ClientServiceName: "global-topo",
217+
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRef{
218+
Address: "global-topo:2379",
219+
RootPath: "/vitess/global",
220+
Implementation: "etcd2",
227221
},
228-
TopoServer: multigresv1alpha1.CellTopoServerSpec{},
222+
TopoServer: &multigresv1alpha1.LocalTopoServerSpec{},
229223
},
230224
},
231225
wantResources: []client.Object{
@@ -308,30 +302,12 @@ func TestCellReconciliation(t *testing.T) {
308302
},
309303
},
310304
},
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-
},
330-
},
331-
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRefSpec{
332-
ClientServiceName: "global-topo",
305+
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRef{
306+
Address: "global-topo:2379",
307+
RootPath: "/vitess/global",
308+
Implementation: "etcd2",
333309
},
334-
TopoServer: multigresv1alpha1.CellTopoServerSpec{},
310+
TopoServer: &multigresv1alpha1.LocalTopoServerSpec{},
335311
},
336312
},
337313
wantResources: []client.Object{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
@@ -72,7 +72,7 @@ func BuildMultiGatewayDeployment(
7272
{
7373
Name: "multigateway",
7474
Image: image,
75-
Resources: cell.Spec.MultiGateway.ResourceRequirements,
75+
Resources: cell.Spec.MultiGateway.Resources,
7676
Ports: []corev1.ContainerPort{
7777
{
7878
Name: "http",

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,8 @@ func TestBuildMultiGatewayDeployment(t *testing.T) {
206206
UID: "image-uid",
207207
},
208208
Spec: multigresv1alpha1.CellSpec{
209-
Name: "zone3",
210-
Images: multigresv1alpha1.CellImagesSpec{
211-
MultiGateway: "custom/multigateway:v1.2.3",
212-
},
209+
Name: "zone3",
210+
MultiGatewayImage: "custom/multigateway:v1.2.3",
213211
},
214212
},
215213
scheme: scheme,
@@ -417,7 +415,7 @@ func TestBuildMultiGatewayDeployment(t *testing.T) {
417415
Spec: multigresv1alpha1.CellSpec{
418416
Name: "zone5",
419417
MultiGateway: multigresv1alpha1.StatelessSpec{
420-
ResourceRequirements: corev1.ResourceRequirements{
418+
Resources: corev1.ResourceRequirements{
421419
Requests: corev1.ResourceList{
422420
corev1.ResourceCPU: resource.MustParse("100m"),
423421
corev1.ResourceMemory: resource.MustParse("128Mi"),

pkg/resource-handler/controller/shard/containers.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var sidecarRestartPolicy = corev1.ContainerRestartPolicyAlways
4141
// This runs pgctld binary (which wraps postgres) and mounts persistent data storage.
4242
func buildPostgresContainer(
4343
shard *multigresv1alpha1.Shard,
44-
pool multigresv1alpha1.ShardPoolSpec,
44+
pool multigresv1alpha1.PoolSpec,
4545
) corev1.Container {
4646
image := DefaultPostgresImage
4747
if shard.Spec.Images.Postgres != "" {
@@ -70,7 +70,7 @@ func buildPostgresContainer(
7070
// restartPolicy: Always (K8s 1.28+).
7171
func buildMultiPoolerSidecar(
7272
shard *multigresv1alpha1.Shard,
73-
pool multigresv1alpha1.ShardPoolSpec,
73+
pool multigresv1alpha1.PoolSpec,
7474
poolName string,
7575
) corev1.Container {
7676
image := DefaultMultiPoolerImage
@@ -87,9 +87,9 @@ func buildMultiPoolerSidecar(
8787
"--http-port", "15200",
8888
"--grpc-port", "15270",
8989
"--topo-implementation", "etcd2",
90-
"--cell", pool.Cell,
91-
"--database", pool.Database,
92-
"--table-group", pool.TableGroup,
90+
"--cell", cell,
91+
"--database", shard.Spec.DatabaseName,
92+
"--table-group", shard.Spec.TableGroupName,
9393
"--service-id", getPoolServiceID(shard.Name, poolName),
9494
"--pgctld-addr", "localhost:15470",
9595
"--pg-port", "5432",
@@ -100,7 +100,7 @@ func buildMultiPoolerSidecar(
100100
Image: image,
101101
Args: args,
102102
Ports: buildMultiPoolerContainerPorts(),
103-
Resources: pool.MultiPooler.Resources,
103+
Resources: pool.Multipooler.Resources,
104104
RestartPolicy: &sidecarRestartPolicy,
105105
}
106106
}
@@ -127,8 +127,8 @@ func buildPgctldInitContainer(shard *multigresv1alpha1.Shard) corev1.Container {
127127
// buildMultiOrchContainer creates the MultiOrch container spec.
128128
func buildMultiOrchContainer(shard *multigresv1alpha1.Shard) corev1.Container {
129129
image := DefaultMultiOrchImage
130-
if shard.Spec.MultiOrch.Image != "" {
131-
image = shard.Spec.MultiOrch.Image
130+
if shard.Spec.Images.MultiOrch != "" {
131+
image = shard.Spec.Images.MultiOrch
132132
}
133133

134134
// TODO: Add remaining command line arguments:
@@ -162,16 +162,6 @@ func buildPgctldVolume() corev1.Volume {
162162
}
163163
}
164164

165-
// buildDataVolumeClaimTemplate creates the PVC template for PostgreSQL data.
166-
func buildDataVolumeClaimTemplate(
167-
pool multigresv1alpha1.ShardPoolSpec,
168-
) corev1.PersistentVolumeClaim {
169-
// Use the pool's DataVolumeClaimTemplate directly if provided
170-
return corev1.PersistentVolumeClaim{
171-
Spec: pool.DataVolumeClaimTemplate,
172-
}
173-
}
174-
175165
// getPoolServiceID generates a unique service ID for a pool.
176166
// This is used in multipooler and pgctld arguments.
177167
func getPoolServiceID(shardName string, poolName string) string {

0 commit comments

Comments
 (0)