From c6c80fa29e467f47f9f0171aed79e24e1540ea3a Mon Sep 17 00:00:00 2001 From: Samuel Paccoud - FUN MOOC Date: Tue, 17 Dec 2019 16:26:26 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8(apps)=20run=20the=20db=5Fmigrate?= =?UTF-8?q?=20job=20before=20starting=20application=20pods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we run db_migrate after starting the new pod: - the current pod has to be compatible with the state of the db before and after the migration. - the new pod has to be compatible with the state of the database before and after a migration. This is not possible for a new database, and not easy for schema updates. If we run db_migrate before starting a new pod, the new pod only has to be compatible with the state of the database after the migration. --- CHANGELOG.md | 4 ++++ apps/edxapp/templates/services/cms/job_05_db_migrate.yml.j2 | 6 ++++-- apps/edxapp/templates/services/lms/job_04_db_migrate.yml.j2 | 6 ++++-- .../templates/services/app/job_db_migrate.yml.j2 | 6 ++++-- apps/marsha/templates/services/app/job_db_migrate.yml.j2 | 6 ++++-- apps/richie/templates/services/app/job_02_db_migrate.yml.j2 | 6 ++++-- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d533a400..cb93c942e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed + +- Run `db_migrate` jobs before starting new pods in a deployment + ## [4.3.0] - 2019-12-13 ### Added diff --git a/apps/edxapp/templates/services/cms/job_05_db_migrate.yml.j2 b/apps/edxapp/templates/services/cms/job_05_db_migrate.yml.j2 index 0df90d293..51c14634e 100644 --- a/apps/edxapp/templates/services/cms/job_05_db_migrate.yml.j2 +++ b/apps/edxapp/templates/services/cms/job_05_db_migrate.yml.j2 @@ -6,10 +6,12 @@ metadata: namespace: "{{ project_name }}" labels: app: edxapp + deployment_stamp: "{{ deployment_stamp }}" + job_stamp: "{{ job_stamp }}" + # Jobs with the "pre" job type will be executed prior to deployments + job_type: "pre" service: cms version: "{{ edxapp_image_tag }}" - job_stamp: "{{ job_stamp }}" - deployment_stamp: "{{ deployment_stamp }}" spec: template: metadata: diff --git a/apps/edxapp/templates/services/lms/job_04_db_migrate.yml.j2 b/apps/edxapp/templates/services/lms/job_04_db_migrate.yml.j2 index bbfc4b8eb..a164bb232 100644 --- a/apps/edxapp/templates/services/lms/job_04_db_migrate.yml.j2 +++ b/apps/edxapp/templates/services/lms/job_04_db_migrate.yml.j2 @@ -6,10 +6,12 @@ metadata: namespace: "{{ project_name }}" labels: app: edxapp + deployment_stamp: "{{ deployment_stamp }}" + job_stamp: "{{ job_stamp }}" + # Jobs with the "pre" job type will be executed prior to deployments + job_type: "pre" service: lms version: "{{ edxapp_image_tag }}" - job_stamp: "{{ job_stamp }}" - deployment_stamp: "{{ deployment_stamp }}" spec: template: metadata: diff --git a/apps/learninglocker/templates/services/app/job_db_migrate.yml.j2 b/apps/learninglocker/templates/services/app/job_db_migrate.yml.j2 index 7d5682825..e3b1a7180 100644 --- a/apps/learninglocker/templates/services/app/job_db_migrate.yml.j2 +++ b/apps/learninglocker/templates/services/app/job_db_migrate.yml.j2 @@ -7,10 +7,12 @@ metadata: namespace: "{{ project_name }}" labels: app: learninglocker + deployment_stamp: "{{ deployment_stamp }}" + job_stamp: "{{ job_stamp }}" + # Jobs with the "pre" job type will be executed prior to deployments + job_type: "pre" service: learninglocker version: "{{ learninglocker_image_tag }}" - job_stamp: "{{ job_stamp }}" - deployment_stamp: "{{ deployment_stamp }}" spec: template: metadata: diff --git a/apps/marsha/templates/services/app/job_db_migrate.yml.j2 b/apps/marsha/templates/services/app/job_db_migrate.yml.j2 index b504ae090..f6de354fc 100644 --- a/apps/marsha/templates/services/app/job_db_migrate.yml.j2 +++ b/apps/marsha/templates/services/app/job_db_migrate.yml.j2 @@ -5,10 +5,12 @@ metadata: namespace: "{{ project_name }}" labels: app: marsha - service: marsha - version: "{{ marsha_image_tag }}" deployment_stamp: "{{ deployment_stamp }}" job_stamp: "{{ job_stamp }}" + # Jobs with the "pre" job type will be executed prior to deployments + job_type: "pre" + service: marsha + version: "{{ marsha_image_tag }}" spec: template: metadata: diff --git a/apps/richie/templates/services/app/job_02_db_migrate.yml.j2 b/apps/richie/templates/services/app/job_02_db_migrate.yml.j2 index ebbfd674e..fba1b314e 100644 --- a/apps/richie/templates/services/app/job_02_db_migrate.yml.j2 +++ b/apps/richie/templates/services/app/job_02_db_migrate.yml.j2 @@ -5,10 +5,12 @@ metadata: namespace: "{{ project_name }}" labels: app: richie - service: richie - version: "{{ richie_image_tag }}" deployment_stamp: "{{ deployment_stamp }}" job_stamp: "{{ job_stamp }}" + # Jobs with the "pre" job type will be executed prior to deployments + job_type: "pre" + service: richie + version: "{{ richie_image_tag }}" spec: template: metadata: