Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ spec:
readOnly: true
{{- end }}
{{- if or ( not .Values.database.enabled ) ( and .Values.database.enabled .Release.IsUpgrade ) }}
args: [ "-f", "DbScripts_transition", "-r"]
args: [ "-f", "DbScripts_transition", "-r"{{ if .Values.jobs.db.migrationTimeoutSeconds }}, "-t", {{ .Values.jobs.db.migrationTimeoutSeconds | quote }}{{ end }}]
{{- else if .Values.jobs.db.migrationTimeoutSeconds }}
args: [ "-t", {{ .Values.jobs.db.migrationTimeoutSeconds | quote }}]
{{- end }}
restartPolicy: Never
volumes:
Expand Down
3 changes: 3 additions & 0 deletions charts/self-host/templates/pre-install-db-migrator-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ spec:
mountPath: "/mnt/secrets-store"
readOnly: true
{{- end }}
{{- if .Values.jobs.db.migrationTimeoutSeconds }}
args: [ "-t", {{ .Values.jobs.db.migrationTimeoutSeconds | quote }}]
{{- end }}
Comment thread
mimartin12 marked this conversation as resolved.
restartPolicy: Never
volumes:
- name: migrator-extract-dir
Expand Down
3 changes: 3 additions & 0 deletions charts/self-host/templates/pre-install-hook-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ data:
{{- end }}
{{- if .Values.general.knownNetworks }}
globalSettings__knownNetworks: {{ .Values.general.knownNetworks | quote }}
{{- end }}
{{- if .Values.jobs.db.migrationTimeoutSeconds }}
globalSettings__sqlServer__migrationExecutionTimeoutSeconds: {{ .Values.jobs.db.migrationTimeoutSeconds | quote }}
{{- end }}
adminSettings__admins: {{ .Values.general.admins | quote }}
LOCAL_UID: "1000"
Expand Down
11 changes: 11 additions & 0 deletions charts/self-host/tests/configmap_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,14 @@ tests:
- isNull:
path: data.globalSettings__IdentityServer__AbsoluteRefreshTokenLifetimeSeconds
documentIndex: 0

- it: should include the migration timeout when migrationTimeoutSeconds is set
template: templates/pre-install-hook-configmap.yaml
set:
general.domain: "example.com"
jobs.db.migrationTimeoutSeconds: "900"
asserts:
- equal:
path: data.globalSettings__sqlServer__migrationExecutionTimeoutSeconds
value: "900"
documentIndex: 0
28 changes: 28 additions & 0 deletions charts/self-host/tests/post_install_db_migrator_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,31 @@ tests:
asserts:
- hasDocuments:
count: 0

- it: should append the timeout to the transition args when migrationTimeoutSeconds is set
template: templates/post-install-db-migrator-job.yaml
set:
database.enabled: false
jobs.db.migrationTimeoutSeconds: "900"
asserts:
- equal:
path: spec.template.spec.containers[0].args
value: ["-f", "DbScripts_transition", "-r", "-t", "900"]

- it: should pass only the timeout when transition args are not rendered
template: templates/post-install-db-migrator-job.yaml
set:
database.enabled: true
jobs.db.migrationTimeoutSeconds: "900"
asserts:
- equal:
path: spec.template.spec.containers[0].args
value: ["-t", "900"]

- it: should not set args when database is enabled and no timeout is set
template: templates/post-install-db-migrator-job.yaml
set:
database.enabled: true
asserts:
- isNull:
path: spec.template.spec.containers[0].args
55 changes: 55 additions & 0 deletions charts/self-host/tests/pre_install_db_migrator_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
suite: test pre-install db migrator job
templates:
- templates/helpers.tpl
- templates/pre-install-db-migrator-job.yaml
tests:
- it: should pass the timeout when migrationTimeoutSeconds is set
template: templates/pre-install-db-migrator-job.yaml
set:
jobs.db.migrationTimeoutSeconds: "900"
asserts:
- isKind:
of: Job
- equal:
path: metadata.annotations["helm.sh/hook"]
value: pre-upgrade
- equal:
path: spec.template.spec.containers[0].args
value: ["-t", "900"]

- it: should pass the timeout when database is disabled
template: templates/pre-install-db-migrator-job.yaml
set:
database.enabled: false
jobs.db.migrationTimeoutSeconds: "900"
asserts:
- equal:
path: metadata.annotations["helm.sh/hook"]
value: pre-install,pre-upgrade
- equal:
path: spec.template.spec.containers[0].args
value: ["-t", "900"]

- it: should pass the timeout when migrationTimeoutSeconds is "0" for unlimited
template: templates/pre-install-db-migrator-job.yaml
set:
jobs.db.migrationTimeoutSeconds: "0"
asserts:
- equal:
path: spec.template.spec.containers[0].args
value: ["-t", "0"]

- it: should not set args when no timeout is set
template: templates/pre-install-db-migrator-job.yaml
asserts:
- isNull:
path: spec.template.spec.containers[0].args

- it: should not render job when databaseProvider is postgres
template: templates/pre-install-db-migrator-job.yaml
set:
general.databaseProvider: postgres
jobs.db.migrationTimeoutSeconds: "900"
asserts:
- hasDocuments:
count: 0
6 changes: 6 additions & 0 deletions charts/self-host/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3342,6 +3342,12 @@
},
"db": {
"properties": {
"migrationTimeoutSeconds": {
"default": "",
"description": "Timeout seconds for MSSQL migrations.\nDefault: 5 minutes\nA value of \"0\" can be used for unlimited timeout, useful for large databases",
"title": "migrationTimeoutSeconds",
"type": "string"
},
"postInstallMigrator": {
"properties": {
"annotations": {
Expand Down
4 changes: 4 additions & 0 deletions charts/self-host/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,10 @@ jobs:
podSecurityContext: {}

db:
# Timeout seconds for MSSQL migrations.
# Default: 5 minutes
# A value of "0" can be used for unlimited timeout, useful for large databases
migrationTimeoutSeconds: ""
Comment thread
mimartin12 marked this conversation as resolved.
preInstallMigrator:
# Additional job labels
labels: {}
Expand Down