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

Chore: database migration cleanup #127

Merged
merged 4 commits into from
Nov 29, 2024
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
42 changes: 16 additions & 26 deletions dags/cas_metabase_dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,10 @@

TWO_DAYS_AGO = datetime.now() - timedelta(days=2)

namespace = os.getenv('GGIRCS_NAMESPACE')
namespace = os.getenv("GGIRCS_NAMESPACE")

default_args = {
**default_dag_args,
'start_date': TWO_DAYS_AGO
}
default_args = {**default_dag_args, "start_date": TWO_DAYS_AGO}

"""
###############################################################################
# #
# DAG triggering the wal-g backup job #
# #
###############################################################################
"""

metabase_full_backup_dag = DAG('walg_backup_metabase_full', default_args=default_args,
schedule_interval='0 8 * * *', is_paused_upon_creation=False)

create_backup_task(metabase_full_backup_dag,
namespace, 'cas-metabase-patroni')

"""
###############################################################################
Expand All @@ -45,21 +29,27 @@
"""
If we're in the test namespace, dag first restores data from prod and then fixes the db connection passwords to be for the test db.
"""
prod_test_restore_dag = DAG('cas_metabase_prod_test_restore', schedule_interval=None,
default_args=default_args)
prod_test_restore_dag = DAG(
"cas_metabase_prod_test_restore", schedule_interval=None, default_args=default_args
)


def prod_test_restore(dag):
return PythonOperator(
python_callable=trigger_k8s_cronjob,
task_id='metabase-prod-test-restore',
op_args=['cas-metabase-prod-test-restore', namespace],
dag=dag)
task_id="metabase-prod-test-restore",
op_args=["cas-metabase-prod-test-restore", namespace],
dag=dag,
)


def fix_db_pass(dag):
return PythonOperator(
python_callable=trigger_k8s_cronjob,
task_id='metabase-db-pass',
op_args=['cas-metabase-db-pass', namespace],
dag=dag)
task_id="metabase-db-pass",
op_args=["cas-metabase-db-pass", namespace],
dag=dag,
)


prod_test_restore(prod_test_restore_dag) >> fix_db_pass(prod_test_restore_dag)
10 changes: 2 additions & 8 deletions helm/cas-metabase/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
dependencies:
- name: cas-postgres
repository: https://bcgov.github.io/cas-postgres/
version: 0.9.1
- name: cas-airflow-dag-trigger
repository: https://bcgov.github.io/cas-airflow
version: 1.0.8
- name: cas-airflow-dag-trigger
repository: https://bcgov.github.io/cas-airflow
version: 1.0.8
- name: patroni-migration
repository: https://bcgov.github.io/cas-postgres/
version: 0.0.21
digest: sha256:b24eca55f781142b2afe9c684fe02330889e858601f90f343648d12c0694768f
generated: "2024-08-20T14:43:06.807086-07:00"
digest: sha256:9259b8b6692bb60692c7a16c6d9edf60168e1594d9774ceccf5cdcc9d0a3500c
generated: "2024-08-21T10:22:52.870377-07:00"
6 changes: 0 additions & 6 deletions helm/cas-metabase/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ type: application
version: 0.4.0
appVersion: 0.49.6
dependencies:
- name: cas-postgres
version: 0.9.1
repository: https://bcgov.github.io/cas-postgres/
- name: cas-airflow-dag-trigger
version: 1.0.8
repository: https://bcgov.github.io/cas-airflow
Expand All @@ -17,6 +14,3 @@ dependencies:
repository: https://bcgov.github.io/cas-airflow
alias: prod-test-restore
condition: prod-test-restore.enable
- name: patroni-migration
version: 1.0.1
repository: https://bcgov.github.io/cas-postgres/
4 changes: 0 additions & 4 deletions helm/cas-metabase/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,3 @@ cas-postgres:
route:
enable: true
host: cas-metabase-dev.apps.silver.devops.gov.bc.ca

patroni-migration:
from:
host: cas-metabase-patroni.9212c9-dev.svc.cluster.local
4 changes: 0 additions & 4 deletions helm/cas-metabase/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,3 @@ metabaseHPA:
enable: true
minReplicas: 2
maxReplicas: 5

patroni-migration:
from:
host: cas-metabase-patroni.9212c9-prod.svc.cluster.local
4 changes: 0 additions & 4 deletions helm/cas-metabase/values-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,3 @@ prod-test-restore:
dagId: cas_metabase_prod_test_restore
helm:
hook: ""

patroni-migration:
from:
host: cas-metabase-patroni.9212c9-test.svc.cluster.local
55 changes: 0 additions & 55 deletions helm/cas-metabase/values.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
cas-postgres:
patroni:
resources:
limits:
cpu: 500m
memory: 2Gi
requests:
cpu: 15m
memory: 600Mi
persistentVolume:
storageClass: netapp-block-standard
size: 5Gi
replicaCount: 3
env:
ALLOW_NOSSL: true
USE_WALG_BACKUP: "true"
USE_WALG_RESTORE: "true"
walE:
enable: true
# the GCS bucket name should be {{ namespace }}-{{ gcs.bucketSuffix }}
gcsBucket:
# kubernetesSecret should be gcp-{{ namespace }}-{{ gcs.bucketSuffix }}-service-account-key
kubernetesSecret:
# options below are required if walE.enable is true
namespace:
gcs:
bucketSuffix:

replicaCount: 2
image:
repository: metabase/metabase
Expand All @@ -37,9 +9,6 @@ database:
metabaseUserSecretName: cas-metabase-db-cas-postgres-cluster-pguser-metabase
superuserSecretName: cas-metabase-db-cas-postgres-cluster-pguser-postgres
dbname: metabase
existingSecret: cas-metabase
existingSecretUsernameKey: database-user
existingSecretPasswordKey: database-password
resources:
limits:
cpu: 500m
Expand Down Expand Up @@ -86,27 +55,3 @@ download-cas-metabase-dags:
dagId: fetch_and_save_dag_from_github
helm:
hook: "pre-install,pre-upgrade"

patroni-migration:
migrationJob:
ignoreRoles:
- metabase
- postgres

deployment:
name: cas-metabase
# for the KNP
sourceReleaseName: cas-metabase
targetReleaseName: cas-metabase-db

from:
secretName: cas-metabase-patroni
host: ~
passwordSecretKey: password-superuser
port: 5432
user: postgres
db: metabase

to:
superuserSecretName: cas-metabase-db-cas-postgres-cluster-pguser-postgres
appuserSecretName: cas-metabase-db-cas-postgres-cluster-pguser-metabase