Skip to content

swh/production: Add the secondary db configuration for the toolbox

Vincent Sellier requested to merge toolbox-pg-secondary into production

It's necessary to apply the db migration on the secondary db server

Related to swh/infra/sysadm-environment#5152 (closed)

helm diff
[swh] Comparing changes between branches production and toolbox-pg-secondary (per environment)...
Your branch is up to date with 'origin/production'.
[swh] Generate config in production branch for environment staging, namespace swh...
[swh] Generate config in production branch for environment staging, namespace swh-cassandra...
[swh] Generate config in production branch for environment staging, namespace swh-cassandra-next-version...
[swh] Generate config in toolbox-pg-secondary branch for environment staging...
[swh] Generate config in toolbox-pg-secondary branch for environment staging...
[swh] Generate config in toolbox-pg-secondary branch for environment staging...
Your branch is up to date with 'origin/production'.
[swh] Generate config in production branch for environment production, namespace swh...
[swh] Generate config in production branch for environment production, namespace swh-cassandra...
[swh] Generate config in production branch for environment production, namespace swh-cassandra-next-version...
[swh] Generate config in toolbox-pg-secondary branch for environment production...
[swh] Generate config in toolbox-pg-secondary branch for environment production...
[swh] Generate config in toolbox-pg-secondary branch for environment production...


------------- diff for environment staging namespace swh -------------

No differences


------------- diff for environment staging namespace swh-cassandra -------------

No differences


------------- diff for environment staging namespace swh-cassandra-next-version -------------

No differences


------------- diff for environment production namespace swh -------------

--- /tmp/swh-chart.swh.j2LDPslN/production-swh.before	2023-11-15 18:31:31.778174852 +0100
+++ /tmp/swh-chart.swh.j2LDPslN/production-swh.after	2023-11-15 18:31:32.074176076 +0100
@@ -5365,20 +5365,32 @@
 kind: ConfigMap
 metadata:
   name: toolbox-storage-template
   namespace: swh
 data:
   config.yml.template: |
     storage:
       cls: postgresql
       db: host=db.internal.softwareheritage.org port=5432 user=swhstorage dbname=softwareheritage password=${POSTGRESQL_PASSWORD}
 ---
+# Source: swh/templates/toolbox/configmap.yaml
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: toolbox-storage-secondary-template
+  namespace: swh
+data:
+  config.yml.template: |
+    storage:
+      cls: postgresql
+      db: host=massmoca.internal.softwareheritage.org port=5432 user=swhstorage dbname=softwareheritage password=${POSTGRESQL_PASSWORD}
+---
 # Source: swh/templates/toolbox/script-utils-configmap.yaml
 apiVersion: v1
 kind: ConfigMap
 metadata:
   name: toolbox-script-utils
   namespace: swh
 data:
   register-task-types.sh: |
     #!/bin/bash
 
@@ -5530,20 +5542,35 @@
     set -eu
 
     /opt/swh/bin/check-db-version.sh storage
 
   migrate-storage-db-version.sh: |
     #!/bin/bash
 
     set -eu
 
     /opt/swh/bin/migrate-db-version.sh storage
+
+
+  check-storage-secondary-db-version.sh: |
+    #!/bin/bash
+
+    set -eu
+
+    /opt/swh/bin/check-db-version.sh storage-secondary
+
+  migrate-storage-secondary-db-version.sh: |
+    #!/bin/bash
+
+    set -eu
+
+    /opt/swh/bin/migrate-db-version.sh storage-secondary
 ---
 # Source: swh/templates/utils/database-utils.yaml
 apiVersion: v1
 kind: ConfigMap
 metadata:
   name: database-utils
   namespace: swh
 data:
   init-keyspace.py: |
     from swh.core import config
@@ -15885,22 +15912,22 @@
   strategy:
     type: RollingUpdate
     rollingUpdate:
       maxSurge: 1
   template:
     metadata:
       labels:
         app: swh-toolbox
       annotations:
         # Force a rollout upgrade if the configuration changes
-        checksum/config: 42df14c73436ec831db8ade97beda17264fc9630bcfb04ebbef792cf1bee84b3
-        checksum/configScript: b501ac689b17f791ba2e2e36970cbc651b3947ca89b59a3efd667be5ceb13a08
+        checksum/config: b4fac72f5d9637a24d02dd53ea47c84b9a7dddb3a1194a6bd29a1aeac3014127
+        checksum/configScript: 663c64a77cb64ac413bb3014e6a87dbd2c528b0b92f716d79ebaeb200d76c6da
     spec:
       priorityClassName: swh-tools
       
       initContainers:
         - name: prepare-configuration-indexer-storage
           image: debian:bullseye
           imagePullPolicy: IfNotPresent
           command:
           - /bin/bash
           args:
@@ -16085,20 +16112,45 @@
                 key: postgres-swh-storage-password
                 # 'name' secret must exist & include that ^ key
                 optional: false
             
           
           volumeMounts:
           - name: configuration
             mountPath: /etc/swh
           - name: configuration-storage-template
             mountPath: /etc/swh/configuration-template
+        - name: prepare-configuration-storage-secondary
+          image: debian:bullseye
+          imagePullPolicy: IfNotPresent
+          command:
+          - /bin/bash
+          args:
+          - -c
+          - eval echo "\"$(</etc/swh/configuration-template/config.yml.template)\"" > /etc/swh/config-storage-secondary.yml
+          env:
+            
+          
+          - name: POSTGRESQL_PASSWORD
+            valueFrom:
+              secretKeyRef:
+                name: swh-storage-postgresql-common-secret
+                key: postgres-swh-storage-password
+                # 'name' secret must exist & include that ^ key
+                optional: false
+            
+          
+          volumeMounts:
+          - name: configuration
+            mountPath: /etc/swh
+          - name: configuration-storage-secondary-template
+            mountPath: /etc/swh/configuration-template
       containers:
       - name: swh-toolbox
         image: container-registry.softwareheritage.org/swh/infra/swh-apps/toolbox:20231114.2
         imagePullPolicy: IfNotPresent
         resources:
           requests:
             memory: 256Mi
             cpu: 250m
         command:
         - /bin/bash
@@ -16156,20 +16208,28 @@
             path: "config.yml.template"
 
       - name: configuration-storage-template
         configMap:
           name: toolbox-storage-template
           defaultMode: 0777
           items:
           - key: "config.yml.template"
             path: "config.yml.template"
 
+      - name: configuration-storage-secondary-template
+        configMap:
+          name: toolbox-storage-secondary-template
+          defaultMode: 0777
+          items:
+          - key: "config.yml.template"
+            path: "config.yml.template"
+
       - name: toolbox-script-utils
         configMap:
           name: toolbox-script-utils
           defaultMode: 0555
 ---
 # Source: swh/templates/scheduler/update-metrics-cronjob.yaml
 apiVersion: batch/v1
 kind: CronJob
 metadata:
   name: scheduler-update-metrics-cronjob


------------- diff for environment production namespace swh-cassandra -------------

No differences

Merge request reports