Skip to content

Commit

Permalink
Truncate the statefulset pvc name to be max 63 chars (#799)
Browse files Browse the repository at this point in the history
* Truncate the statefulset pvc name to be max 63 chars
  • Loading branch information
tjhiggins committed Nov 8, 2021
1 parent 9e20ed1 commit 5778495
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions charts/consul/templates/server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ spec:
-config-file=/consul/extra-config/extra-from-values.json \
-server
volumeMounts:
- name: data-{{ .Release.Namespace }}
- name: data-{{ .Release.Namespace | trunc 58 | trimSuffix "-" }}
mountPath: /consul/data
- name: config
mountPath: /consul/config
Expand Down Expand Up @@ -365,7 +365,7 @@ spec:
{{- end }}
volumeClaimTemplates:
- metadata:
name: data-{{ .Release.Namespace }}
name: data-{{ .Release.Namespace | trunc 58 | trimSuffix "-" }}
spec:
accessModes:
- ReadWriteOnce
Expand Down
22 changes: 22 additions & 0 deletions charts/consul/test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,28 @@ load _helpers
[ "${actual}" = "2" ]
}

#--------------------------------------------------------------------
# volumeClaim name

@test "server/StatefulSet: no truncation for namespace <= 58 chars" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-statefulset.yaml \
. | tee /dev/stderr |
yq -r '.spec.volumeClaimTemplates[0].metadata.name' | tee /dev/stderr)
[ "${actual}" = "data-default" ]
}

@test "server/StatefulSet: truncation for namespace > 58 chars" {
cd `chart_dir`
local actual=$(helm template \
-n really-really-really-really-really-really-really-long-namespace \
-s templates/server-statefulset.yaml \
. | tee /dev/stderr |
yq -r '.spec.volumeClaimTemplates[0].metadata.name' | tee /dev/stderr)
[ "${actual}" = "data-really-really-really-really-really-really-really-long-name" ]
}

#--------------------------------------------------------------------
# storageClass

Expand Down

0 comments on commit 5778495

Please sign in to comment.