Skip to content

Commit d54bb32

Browse files
Merge pull request #380 from numtide/fix/cell-status-and-name-validation
Fix/cell status and name validation
2 parents 3390aea + e01d65c commit d54bb32

File tree

16 files changed

+338
-28
lines changed

16 files changed

+338
-28
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ kubeconfig.yaml
2323
# MacOS
2424
.DS_Store
2525
multigres-operator
26+
27+
# Results of Agent runs
28+
agent-docs/

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,36 @@ kind-up: ## Create a kind cluster for local development
351351
fi
352352
@echo "==> Cluster ready. Use: export KUBECONFIG=$(KIND_KUBECONFIG)"
353353

354+
.PHONY: kind-up-topology
355+
kind-up-topology: ## Create a multi-node kind cluster with topology zone labels
356+
@command -v $(KIND) >/dev/null 2>&1 || { \
357+
echo "ERROR: kind is not installed."; \
358+
echo "Install it from: https://kind.sigs.k8s.io/docs/user/quick-start/"; \
359+
exit 1; \
360+
}
361+
@if $(KIND) get clusters | grep -q "^$(KIND_CLUSTER)$$"; then \
362+
echo "Kind cluster '$(KIND_CLUSTER)' already exists."; \
363+
echo "==> Exporting kubeconfig to $(KIND_KUBECONFIG)"; \
364+
$(KIND) get kubeconfig --name $(KIND_CLUSTER) > $(KIND_KUBECONFIG); \
365+
else \
366+
echo "Creating kind cluster '$(KIND_CLUSTER)' with topology zones..."; \
367+
$(KIND) create cluster --name $(KIND_CLUSTER) --kubeconfig $(KIND_KUBECONFIG) \
368+
--config config/kind/kind-config-topology.yaml; \
369+
fi
370+
@echo "==> Cluster ready (3 workers with zone labels). Use: export KUBECONFIG=$(KIND_KUBECONFIG)"
371+
372+
.PHONY: kind-deploy-topology
373+
kind-deploy-topology: kind-up-topology manifests kustomize kind-load kind-load-images ## Deploy operator to multi-node kind cluster with topology zones
374+
@echo "==> Installing CRDs..."
375+
KUBECONFIG=$(KIND_KUBECONFIG) $(KUSTOMIZE) build config/crd | KUBECONFIG=$(KIND_KUBECONFIG) $(KUBECTL) apply --server-side -f -
376+
@echo "==> Deploying operator..."
377+
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
378+
KUBECONFIG=$(KIND_KUBECONFIG) $(KUSTOMIZE) build config/default | KUBECONFIG=$(KIND_KUBECONFIG) $(KUBECTL) apply --server-side -f -
379+
@git checkout -- config/manager/kustomization.yaml 2>/dev/null || true
380+
@echo "==> Deployment complete!"
381+
@echo "Check status: KUBECONFIG=$(KIND_KUBECONFIG) kubectl get pods -n multigres-operator"
382+
$(MAKE) kind-deploy-observer
383+
354384
.PHONY: kind-load
355385
kind-load: container ## Build and load image into kind cluster
356386
@echo "==> Loading image $(IMG) into kind cluster..."

api/v1alpha1/common_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,22 +212,27 @@ type PgBackRestTLSConfig struct {
212212

213213
// +kubebuilder:validation:MinLength=1
214214
// +kubebuilder:validation:MaxLength=30
215+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
215216
type DatabaseName string
216217

217218
// +kubebuilder:validation:MinLength=1
218219
// +kubebuilder:validation:MaxLength=25
220+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
219221
type TableGroupName string
220222

221223
// +kubebuilder:validation:MinLength=1
222224
// +kubebuilder:validation:MaxLength=25
225+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
223226
type ShardName string
224227

225228
// +kubebuilder:validation:MinLength=1
226229
// +kubebuilder:validation:MaxLength=25
230+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
227231
type PoolName string
228232

229233
// +kubebuilder:validation:MinLength=1
230234
// +kubebuilder:validation:MaxLength=30
235+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
231236
type CellName string
232237

233238
// +kubebuilder:validation:MinLength=1

config/crd/bases/multigres.com_cells.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ spec:
5656
items:
5757
maxLength: 30
5858
minLength: 1
59+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
5960
type: string
6061
maxItems: 50
6162
type: array
@@ -1133,6 +1134,7 @@ spec:
11331134
description: Name is the logical name of the cell.
11341135
maxLength: 30
11351136
minLength: 1
1137+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
11361138
type: string
11371139
observability:
11381140
description: |-

config/crd/bases/multigres.com_multigresclusters.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ spec:
176176
description: Name is the logical name of the cell.
177177
maxLength: 30
178178
minLength: 1
179+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
179180
type: string
180181
overrides:
181182
description: Overrides are applied on top of the template.
@@ -2592,6 +2593,7 @@ spec:
25922593
description: Name is the logical name of the database.
25932594
maxLength: 30
25942595
minLength: 1
2596+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
25952597
type: string
25962598
tablegroups:
25972599
description: TableGroups is a list of table groups.
@@ -2720,6 +2722,7 @@ spec:
27202722
description: Name is the logical name of the table group.
27212723
maxLength: 25
27222724
minLength: 1
2725+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
27232726
type: string
27242727
pvcDeletionPolicy:
27252728
description: |-
@@ -2872,6 +2875,7 @@ spec:
28722875
(e.g., "0", "1").
28732876
maxLength: 25
28742877
minLength: 1
2878+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
28752879
type: string
28762880
x-kubernetes-validations:
28772881
- message: shardName must be strictly equal to '0-inf'
@@ -3865,6 +3869,7 @@ spec:
38653869
items:
38663870
maxLength: 30
38673871
minLength: 1
3872+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
38683873
type: string
38693874
maxItems: 50
38703875
type: array
@@ -4963,6 +4968,7 @@ spec:
49634968
items:
49644969
maxLength: 30
49654970
minLength: 1
4971+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
49664972
type: string
49674973
maxItems: 10
49684974
minItems: 1
@@ -6221,6 +6227,7 @@ spec:
62216227
items:
62226228
maxLength: 30
62236229
minLength: 1
6230+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
62246231
type: string
62256232
maxItems: 50
62266233
type: array
@@ -7319,6 +7326,7 @@ spec:
73197326
items:
73207327
maxLength: 30
73217328
minLength: 1
7329+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
73227330
type: string
73237331
maxItems: 10
73247332
minItems: 1

config/crd/bases/multigres.com_shards.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ spec:
175175
shard belongs to.
176176
maxLength: 30
177177
minLength: 1
178+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
178179
type: string
179180
durabilityPolicy:
180181
description: |-
@@ -1189,6 +1190,7 @@ spec:
11891190
items:
11901191
maxLength: 30
11911192
minLength: 1
1193+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
11921194
type: string
11931195
maxItems: 50
11941196
type: array
@@ -2307,6 +2309,7 @@ spec:
23072309
items:
23082310
maxLength: 30
23092311
minLength: 1
2312+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
23102313
type: string
23112314
maxItems: 10
23122315
minItems: 1
@@ -2597,12 +2600,14 @@ spec:
25972600
"0").
25982601
maxLength: 25
25992602
minLength: 1
2603+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
26002604
type: string
26012605
tableGroupName:
26022606
description: TableGroupName is the name of the table group this shard
26032607
belongs to.
26042608
maxLength: 25
26052609
minLength: 1
2610+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
26062611
type: string
26072612
topologyPruning:
26082613
description: |-
@@ -2634,6 +2639,7 @@ spec:
26342639
items:
26352640
maxLength: 30
26362641
minLength: 1
2642+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
26372643
type: string
26382644
maxItems: 50
26392645
type: array

config/crd/bases/multigres.com_shardtemplates.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,7 @@ spec:
971971
items:
972972
maxLength: 30
973973
minLength: 1
974+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
974975
type: string
975976
maxItems: 50
976977
type: array
@@ -1990,6 +1991,7 @@ spec:
19901991
items:
19911992
maxLength: 30
19921993
minLength: 1
1994+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
19931995
type: string
19941996
maxItems: 10
19951997
minItems: 1

config/crd/bases/multigres.com_tablegroups.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ spec:
171171
description: DatabaseName is the name of the logical database.
172172
maxLength: 30
173173
minLength: 1
174+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
174175
type: string
175176
default:
176177
description: IsDefault indicates if this is the default/unsharded
@@ -1436,6 +1437,7 @@ spec:
14361437
items:
14371438
maxLength: 30
14381439
minLength: 1
1440+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
14391441
type: string
14401442
maxItems: 50
14411443
type: array
@@ -2471,6 +2473,7 @@ spec:
24712473
items:
24722474
maxLength: 30
24732475
minLength: 1
2476+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
24742477
type: string
24752478
maxItems: 10
24762479
minItems: 1
@@ -2765,6 +2768,7 @@ spec:
27652768
description: TableGroupName is the name of this table group.
27662769
maxLength: 25
27672770
minLength: 1
2771+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
27682772
type: string
27692773
topologyPruning:
27702774
description: |-
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
kind: Cluster
2+
apiVersion: kind.x-k8s.io/v1alpha4
3+
nodes:
4+
- role: control-plane
5+
- role: worker
6+
labels:
7+
topology.kubernetes.io/zone: us-east-1a
8+
- role: worker
9+
labels:
10+
topology.kubernetes.io/zone: us-east-1b
11+
- role: worker
12+
labels:
13+
topology.kubernetes.io/zone: us-east-1c

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ func (r *CellReconciler) updateStatus(ctx context.Context, cell *multigresv1alph
257257
r.setConditions(cell, mgDeploy)
258258
cell.Status.GatewayReplicas = mgDeploy.Status.Replicas
259259
cell.Status.GatewayReadyReplicas = mgDeploy.Status.ReadyReplicas
260+
cell.Status.GatewayServiceName = BuildMultiGatewayServiceName(cell)
260261
monitoring.SetCellGatewayReplicas(
261262
cell.Name,
262263
cell.Namespace,

0 commit comments

Comments
 (0)