Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drupal/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: drupal
version: 1.30.0
version: 1.31.0
dependencies:
- name: mariadb
version: 7.5.x
Expand Down
25 changes: 24 additions & 1 deletion drupal/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,10 @@ wait
set -e

INSTALLING_FILE="{{ include "drupal.installing-file" . }}"

rm -f "$INSTALLING_FILE" || true

trap 'rm -f "$INSTALLING_FILE" || true' EXIT

{{ if and .Release.IsInstall .Values.referenceData.enabled -}}
{{ include "drupal.import-reference-files" . }}
{{- end }}
Expand Down Expand Up @@ -708,6 +709,10 @@ fi
ls -lh /backups/*
{{- end }}

{{- define "drupal.cleanup-job" }}
rm -f "{{ include "drupal.installing-file" . }}" || true
{{- end }}

{{- define "mariadb.db-validation" -}}

set -e
Expand Down Expand Up @@ -739,6 +744,24 @@ fi

{{- end }}

{{- define "drupal.pre-release-command" -}}
set -e

{{- include "drupal.wait-for-db-command" . }}

{{- if .Values.elasticsearch.enabled }}
{{ include "drupal.wait-for-elasticsearch-command" . }}
{{ end }}

{{- if .Values.php.preupgrade.backup }}
{{- include "drupal.backup-command" . }}
{{- end }}

{{- if .Values.php.preupgrade.command }}
{{- .Values.php.preupgrade.command }}
{{- end }}
{{- end }}

{{- define "cert-manager.api-version" }}
{{- if ( .Capabilities.APIVersions.Has "cert-manager.io/v1" ) }}
cert-manager.io/v1
Expand Down
2 changes: 1 addition & 1 deletion drupal/templates/backup-volume.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.backup.enabled }}
{{- if or .Values.backup.enabled ( or (ne .Values.php.preupgrade.command "") .Values.php.preupgrade.backup ) }}
{{- if eq .Values.backup.storageClassName "silta-shared" }}
{{- if eq ( include "silta-cluster.rclone.has-provisioner" $ ) "false" }}
apiVersion: v1
Expand Down
4 changes: 4 additions & 0 deletions drupal/templates/drupal-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,10 @@ data:

# Prevent requests during the site installation process.
if [ {{ include "drupal.installation-in-progress-test" $ }} ]; then
PID=$(pgrep -o php-fpm || true)
if [ -n "$PID" ]; then
echo "Installation in progress, failing health check." > /proc/$PID/fd/2;
fi
exit 1;
fi

Expand Down
27 changes: 27 additions & 0 deletions drupal/templates/pre-release-cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}-cleanup"
labels:
{{- include "drupal.release_labels" . | nindent 4 }}
spec:
ttlSecondsAfterFinished: 0
template:
metadata:
labels:
{{- include "drupal.release_labels" . | nindent 8 }}
spec:
enableServiceLinks: false
restartPolicy: Never
containers:
- name: cleanup
{{- include "drupal.php-container" . | nindent 8 }}
command: ["/bin/bash", "-c"]
args:
- |
{{- include "drupal.cleanup-job" . | nindent 12 }}
volumeMounts:
{{- include "drupal.volumeMounts" . | nindent 12 }}
serviceAccountName: {{ include "drupal.serviceAccountName" . }}
volumes:
{{- include "drupal.volumes" . | nindent 8 }}
60 changes: 60 additions & 0 deletions drupal/templates/pre-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{{- if or (ne .Values.php.preupgrade.command "") .Values.php.preupgrade.backup }}
{{- $claimName := printf "%s-backup" .Release.Name }}
{{- if and ( eq $.Values.backup.storageClassName "silta-shared" ) ( eq ( include "silta-cluster.rclone.has-provisioner" $ ) "true" ) }}
{{- $claimName = printf "%s-backup2" .Release.Name }}
{{- end }}
{{- if lookup "v1" "PersistentVolumeClaim" .Release.Namespace $claimName }}
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}-pre-release"
labels:
{{- include "drupal.release_labels" . | nindent 4 }}
annotations:
# This is what defines this resource as a hook. Without this line, the
# job is considered part of the release.
"helm.sh/hook": "pre-upgrade"
"helm.sh/hook-delete-policy": "before-hook-creation"
spec:
completions: 1
backoffLimit: 0
template:
metadata:
labels:
{{- include "drupal.release_labels" . | nindent 8 }}
spec:
restartPolicy: Never
enableServiceLinks: false
containers:
- name: pre-release
{{- include "drupal.php-container" . | nindent 8 }}
command: ["/bin/bash", "-c"]
args:
- |
{{- include "drupal.pre-release-command" . | nindent 12 }}
volumeMounts:
{{- include "drupal.volumeMounts" . | nindent 10 }}
{{- if .Values.php.preupgrade.backup }}
- name: {{ .Release.Name }}-backup
mountPath: /backups
{{- end }}
resources:
{{- .Values.php.preupgrade.resources | toYaml | nindent 10 }}
nodeSelector:
{{- .Values.php.preupgrade.nodeSelector | toYaml | nindent 8 }}
tolerations:
{{- include "drupal.tolerations" .Values.php.preupgrade.nodeSelector | nindent 8 }}
serviceAccountName: {{ include "drupal.serviceAccountName" . }}
volumes:
{{- include "drupal.volumes" . | nindent 8 }}
{{- if .Values.php.preupgrade.backup }}
- name: {{ .Release.Name }}-backup
persistentVolumeClaim:
{{- if and ( eq $.Values.backup.storageClassName "silta-shared" ) ( eq ( include "silta-cluster.rclone.has-provisioner" $ ) "true" ) }}
claimName: {{ .Release.Name }}-backup2
{{- else }}
claimName: {{ .Release.Name }}-backup
{{- end }}
{{- end }}
{{- end }}
{{- end }}
4 changes: 2 additions & 2 deletions drupal/templates/shell-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
mountPath: /etc/ssh/authorized_keys
subPath: authorizedKeys
readOnly: true
{{- if .Values.backup.enabled }}
{{- if or .Values.backup.enabled ( or (ne .Values.php.preupgrade.command "") .Values.php.preupgrade.backup ) }}
- name: {{ .Release.Name }}-backup
mountPath: /backups
readOnly: true
Expand Down Expand Up @@ -119,7 +119,7 @@ spec:
- name: shell-configmap
configMap:
name: {{ .Release.Name }}-shell
{{- if .Values.backup.enabled }}
{{- if or .Values.backup.enabled ( or (ne .Values.php.preupgrade.command "") .Values.php.preupgrade.backup ) }}
- name: {{ .Release.Name }}-backup
persistentVolumeClaim:
{{- if and ( eq $.Values.backup.storageClassName "silta-shared" ) ( eq ( include "silta-cluster.rclone.has-provisioner" $ ) "true" ) }}
Expand Down
31 changes: 30 additions & 1 deletion drupal/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,35 @@
}
}
},
"preupgrade": {
"type": "object",
"additionalProperties": false,
"properties": {
"backup": { "type": "boolean" },
"command": { "type": "string" },
"nodeSelector": { "type": "object" },
"resources": {
"type": "object",
"additionalProperties": false,
"properties": {
"requests": {
"type": "object",
"properties": {
"cpu": { "type": ["integer", "string"] },
"memory": { "type": "string" }
}
},
"limits": {
"type": "object",
"properties": {
"cpu": { "type": ["integer", "string"] },
"memory": { "type": "string" }
}
}
}
}
}
},
"postupgrade": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -582,7 +611,7 @@
}
}
}
},
},
"mariadb": {
"type": "object",
"properties": {
Expand Down
11 changes: 11 additions & 0 deletions drupal/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,17 @@ php:
afterCommand: |


# Executes before the environment is installed. Could be useful for backups before environment is upgraded.
preupgrade:
backup: false
command: ""
resources:
requests:
cpu: 500m
memory: 488Mi
limits:
memory: 488Mi

# Pass additional environment variables to all php containers as key-value pairs.
env: {}

Expand Down
Loading