-
Notifications
You must be signed in to change notification settings - Fork 198
Open
Labels
chart( cluster )Related to the cluster chartRelated to the cluster chart
Description
Fix: resolve null error for standalone mode in cluster chart
/charts/cluster/templates/_external_clusters.tpl
{{- define "cluster.externalClusters" -}}
{{- if eq .Values.mode "standalone" }}
externalClusters: []
{{- else if eq .Values.mode "recovery" }}
externalClusters:
{{- if eq .Values.recovery.method "pg_basebackup" }}
- name: pgBaseBackupSource
{{- include "cluster.externalSourceCluster" .Values.recovery.pgBaseBackup.source | nindent 4 }}
{{- else if eq .Values.recovery.method "import" }}
- name: importSource
{{- include "cluster.externalSourceCluster" .Values.recovery.import.source | nindent 4 }}
{{- else if eq .Values.recovery.method "object_store" }}
- name: objectStoreRecoveryCluster
barmanObjectStore:
serverName: {{ .Values.recovery.clusterName }}
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}}
{{- include "cluster.barmanObjectStoreConfig" $d | nindent 4 }}
{{- end }}
{{- else if eq .Values.mode "replica" }}
externalClusters:
- name: originCluster
{{- if not (empty .Values.replica.origin.objectStore.provider) }}
barmanObjectStore:
serverName: {{ .Values.replica.origin.objectStore.clusterName }}
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.replica.origin.objectStore "secretPrefix" "origin" -}}
{{- include "cluster.barmanObjectStoreConfig" $d | nindent 4 -}}
{{- end }}
{{- if not (empty .Values.replica.origin.pg_basebackup.host) }}
{{- include "cluster.externalSourceCluster" .Values.replica.origin.pg_basebackup | nindent 4 }}
{{- end }}
{{- else }}
{{ fail "Invalid cluster mode!" }}
{{- end }}
{{ end }}
This fix resolves a null error that occurred when installing the cluster chart in standalone mode. The issue was caused by the externalClusters key being defined outside of the conditional blocks in the _external_clusters.tpl template, which resulted in an improperly structured YAML output. The fix moves the externalClusters definition inside each conditional block and explicitly initializes it as an empty array ([]) for standalone mode, ensuring proper YAML structure and preventing null reference errors during chart installation.
ArnaudTA and 0xsan-z
Metadata
Metadata
Assignees
Labels
chart( cluster )Related to the cluster chartRelated to the cluster chart