Skip to content

Commit 1bd0d3c

Browse files
committed
Address comments.
1 parent 7c8fa8a commit 1bd0d3c

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

helm/vitess/templates/_helpers.tpl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@
1414
{{- range . }}{{template "format-flags" .}}{{end -}}
1515
{{- end -}}
1616

17-
# Format a shard name, making sure it starts and ends with [A-Za-z0-9].
18-
{{- define "format-shard-name" -}}
17+
# Clean labels, making sure it starts and ends with [A-Za-z0-9].
18+
# This is especially important for shard names, which can start or end with
19+
# '-' (like -80 or 80-), which would be an invalid kubernetes label.
20+
{{- define "clean-label" -}}
21+
{{- $replaced_label := . | replace "_" "-"}}
1922
{{- if hasPrefix "-" . -}}
20-
x{{.}}
23+
x{{$replaced_label}}
2124
{{- else if hasSuffix "-" . -}}
22-
{{.}}x
25+
{{$replaced_label}}x
2326
{{- else -}}
24-
{{.}}
27+
{{$replaced_label}}
2528
{{- end -}}
2629
{{- end -}}
2730

helm/vitess/templates/_vttablet.tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ volumes:
176176
{{- $tablet := index . 4 -}}
177177
{{- with $tablet.vttablet -}}
178178
{{- $0 := $.Values.vttablet -}}
179-
{{- $cellClean := $cell.name | replace "_" "-" -}}
180-
{{- $keyspaceClean := $keyspace.name | replace "_" "-" -}}
181-
{{- $shardClean := include "format-shard-name" $shard.name -}}
179+
{{- $cellClean := include "clean-label" $cell.name -}}
180+
{{- $keyspaceClean := include "clean-label" $keyspace.name -}}
181+
{{- $shardClean := include "clean-label" $shard.name -}}
182182
{{- $setName := printf "%s-%s-%s-%s" $cellClean $keyspaceClean $shardClean $tablet.type | lower -}}
183183
{{- $uid := "$(cat $VTDATAROOT/init/tablet-uid)" }}
184184
# vttablet StatefulSet
@@ -224,7 +224,7 @@ spec:
224224
{{- $cell := index . 1 -}}
225225
{{- $keyspace := index . 2 -}}
226226
{{- $shard := index . 3 -}}
227-
{{- $shardClean := include "format-shard-name" $shard.name -}}
227+
{{- $shardClean := include "clean-label" $shard.name -}}
228228
{{- $tablet := index . 4 -}}
229229
{{- $uid := index . 5 -}}
230230
{{- with $tablet.vttablet -}}

test/cluster/sandbox/initial_reparent.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def initial_reparent(keyspace, master_cell, num_shards, namespace, timeout_s):
2929
if time.time() - start_time > timeout_s:
3030
logging.error('Timed out waiting to find a replica tablet')
3131
return 1
32+
3233
for shard_name in sharding_utils.get_shard_names(num_shards):
3334
if shard_name in master_tablets:
3435
continue
@@ -61,6 +62,7 @@ def initial_reparent(keyspace, master_cell, num_shards, namespace, timeout_s):
6162
if len(successfully_reparented) == num_shards:
6263
logging.info('Done with initial reparent.')
6364
return 0
65+
6466
logging.error('Timed out waiting for initial reparent.')
6567
return 1
6668

0 commit comments

Comments
 (0)