Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm-chart: make sure database migrations are only run by one process #6780

Merged
merged 1 commit into from
Sep 4, 2023
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- TDB

### Changed
- TDB
- \[Helm\] Database migrations now run in a separate job instead of the server pod,
in order to avoid data corruption when multiple replicas of the server are used
(<https://github.com/opencv/cvat/pull/6780>)

### Deprecated
- TDB
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.9.1
version: 0.10.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
72 changes: 72 additions & 0 deletions helm-chart/templates/cvat_backend/initializer/job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
apiVersion: batch/v1
kind: Job
metadata:
# Jobs are mostly immutable, so Helm can't update them when the user upgrades
# a release. Work around this by including the revision in the job name, so that
# every upgrade creates a new job.
# See also <https://github.com/helm/helm/issues/7082>.
name: {{ .Release.Name }}-backend-initializer-r{{ .Release.Revision }}
namespace: {{ .Release.Namespace }}
labels:
app: cvat-app
tier: backend
component: initializer
{{- include "cvat.labels" . | nindent 4 }}
{{- with .Values.cvat.backend.initializer.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.cvat.backend.initializer.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
template:
metadata:
labels:
app: cvat-app
tier: backend
component: initializer
{{- include "cvat.labels" . | nindent 8 }}
{{- with .Values.cvat.backend.initializer.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.cvat.backend.initializer.annotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
containers:
- name: cvat-app-backend-initializer-container
image: {{ .Values.cvat.backend.image }}:{{ .Values.cvat.backend.tag }}
imagePullPolicy: {{ .Values.cvat.backend.imagePullPolicy }}
{{- with .Values.cvat.backend.initializer.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
args: ["init"]
env:
{{ include "cvat.sharedBackendEnv" . | indent 10 }}
{{- with .Values.cvat.backend.initializer.additionalEnv }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.cvat.backend.initializer.additionalVolumeMounts }}
volumeMounts:
{{- toYaml . | nindent 10 }}
{{- end }}
restartPolicy: OnFailure
{{- with .Values.cvat.backend.initializer.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.cvat.backend.initializer.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.cvat.backend.initializer.additionalVolumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
2 changes: 1 addition & 1 deletion helm-chart/templates/cvat_backend/server/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ spec:
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
args: ["init", "run", "server"]
args: ["run", "server"]
env:
- name: ALLOWED_HOSTS
value: {{ .Values.cvat.backend.server.envs.ALLOWED_HOSTS | squote}}
Expand Down
9 changes: 9 additions & 0 deletions helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ fullnameOverride: ""

cvat:
backend:
initializer:
labels: {}
annotations: {}
resources: {}
affinity: {}
tolerations: []
additionalEnv: []
additionalVolumes: []
additionalVolumeMounts: []
server:
replicas: 1
labels: {}
Expand Down