Skip to content

Commit 001b7a5

Browse files
pengzhoumlPeng Zhou
andauthored
MLE-14200 Use useLegacyHostnames to fix upgrade backward compatibility issue (#235)
* MLE-14181 Upgrade Bug with group config is set * MLE-14200 Persist the Name Change after Upgrade * update comments about useLegacyHostnames --------- Co-authored-by: Peng Zhou <[email protected]>
1 parent c7cfdd7 commit 001b7a5

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ Following table lists all the parameters supported by the latest MarkLogic Helm
107107
| `updateStrategy.type` | Update strategy for MarkLogic pods | `OnDelete` |
108108
| `terminationGracePeriod` | Seconds the MarkLogic Pod terminate gracefully | `120` |
109109
| `clusterDomain` | Domain for the Kubernetes cluster | `cluster.local` |
110-
| `allowLongHostnames` | Allow deployment with hostname over 64 characters | `false` |∂
110+
| `allowLongHostnames` | Allow deployment with hostname over 64 characters | `false` |
111+
| `useLegacyHostnames` | Use the lagecy hostnames that is used before 1.1.0 version. | `false` |
111112
| `group.name` | Group name for joining MarkLogic cluster | `Default` |
112113
| `group.enableXdqpSsl` | SSL encryption for XDQP | `true` |
113114
| `bootstrapHostName` | Host name of MarkLogic bootstrap host (to join a cluster) | `""` |

charts/templates/_helpers.tpl

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,38 @@ oldFullname is the name used before 1.1.x release
3737
{{- if .Release.IsInstall -}}
3838
{{- true }}
3939
{{- else }}
40-
{{- if .Values.fullnameOverride -}}
41-
{{- $overridenName := trim .Values.fullnameOverride -}}
42-
{{- $labels := (lookup "apps/v1" "StatefulSet" .Release.Namespace $overridenName).metadata.labels -}}
43-
{{- $chartVersionFull := get $labels "helm.sh/chart" -}}
44-
{{- $chartVersionString := trimPrefix "marklogic-" $chartVersionFull -}}
45-
{{- $chartVersionString := $chartVersionString | replace "." "" -}}
46-
{{- $chartVersionDigit := int $chartVersionString}}
47-
{{- if lt $chartVersionDigit 110 -}}
40+
{{- if eq .Values.useLegacyHostnames true -}}
4841
{{- false }}
4942
{{- else }}
5043
{{- true }}
5144
{{- end }}
52-
{{- else }}
53-
{{- $newCm := (lookup "apps/v1" "StatefulSet" .Release.Namespace (include "marklogic.newFullname" .)) }}
54-
{{- if $newCm }}
55-
{{- true }}
56-
{{- else }}
57-
{{- false }}
5845
{{- end }}
5946
{{- end }}
47+
48+
{{- define "marklogic.checkUpgradeError" -}}
49+
{{- if and .Release.IsUpgrade (ne .Values.useLegacyHostnames true) -}}
50+
{{- $stsName := trim (include "marklogic.oldFullname" .) -}}
51+
{{- if .Values.fullnameOverride -}}
52+
{{- $stsName := trim .Values.fullnameOverride -}}
53+
{{- end }}
54+
{{- $sts := lookup "apps/v1" "StatefulSet" .Release.Namespace $stsName }}
55+
{{- if $sts }}
56+
{{- $labels := $sts.metadata.labels }}
57+
{{- $chartVersionFull := get $labels "helm.sh/chart" }}
58+
{{- if $chartVersionFull }}
59+
{{- $chartVersionWithDot := trimPrefix "marklogic-" $chartVersionFull }}
60+
{{- $chartVersionString := $chartVersionWithDot | replace "." "" }}
61+
{{- $chartVersionDigit := int $chartVersionString }}
62+
{{- if lt $chartVersionDigit 110 -}}
63+
{{- $errorMessage := printf "New hostnames has been introduced since version 1.1.0. You are upgrading from version %s to version %s. To make the upgrade successful, please set the following configuration in values file to keep using the legacy hostname: \n\nuseLegacyHostnames: true\n" $chartVersionWithDot .Chart.Version }}
64+
{{- fail $errorMessage }}
65+
{{- end }}
66+
{{- end }}
67+
{{- end }}
68+
{{- end }}
69+
{{- end }}
70+
71+
{{/*
6072
{{- end }}
6173
{{- end }}
6274

charts/templates/statefulset.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- include "marklogic.checkUpgradeError" . -}}
12
{{- include "marklogic.checkInputError" . }}
23
apiVersion: apps/v1
34
kind: StatefulSet

charts/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ clusterDomain: cluster.local
2121
## There is a limit of 64 characters for CN in the certificate
2222
allowLongHostnames: false
2323

24+
## This flag facilitates upgrading from version 1.0.x of the chart while retaining the use of legacy hostnames.
25+
## When upgrading from version 1.0.x to any version above 1.1.0, this flag must be set to true.
26+
## It should remain true for all future upgrades. For new installations, this flag should be set to false.
27+
useLegacyHostnames: false
28+
2429
## Group related settings
2530
group:
2631
## the group name of the current Marklogic Helm Deployment

0 commit comments

Comments
 (0)