MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / normalizeVolumeName

Function normalizeVolumeName

pkg/specs/podspec_diff.go:146–160  ·  view source on GitHub ↗

normalizeVolumeName maps old unprefixed volume names to the new prefixed scheme (ext- for extensions, tbs- for tablespaces) to avoid spurious pod restarts on upgrade. Names already starting with the correct prefix are left unchanged, which causes one spurious restart for extensions named "ext_*" or

(vol corev1.Volume)

Source from the content-addressed store, hash-verified

144//
145// TODO: delete this function after minor version 1.28 is discontinued
146func normalizeVolumeName(vol corev1.Volume) string {
147 name := vol.Name
148
149 if vol.Image != nil && !strings.HasPrefix(name, "ext-") {
150 return SanitizeExtensionNameForVolume(name)
151 }
152
153 if vol.PersistentVolumeClaim != nil &&
154 strings.Contains(vol.PersistentVolumeClaim.ClaimName, apiv1.TablespaceVolumeInfix) &&
155 !strings.HasPrefix(name, "tbs-") {
156 return "tbs-" + name
157 }
158
159 return name
160}
161
162// normalizeVolumeMountName is the VolumeMount counterpart of
163// normalizeVolumeName, using mount paths to detect the volume type.

Callers 2

compareVolumesFunction · 0.85

Calls 1

Tested by

no test coverage detected