Skip to content

Instantly share code, notes, and snippets.

@mgagliardo91
Last active January 29, 2020 12:52
Show Gist options
  • Save mgagliardo91/1c53c706869bbf33cbdffd7820749db7 to your computer and use it in GitHub Desktop.
Save mgagliardo91/1c53c706869bbf33cbdffd7820749db7 to your computer and use it in GitHub Desktop.
Jira Schema Migration Plan

Jira Schema Migration Plan

The following migration plan should be carried out in each environment sequentially, starting with dev. It should be easy to roll-back, if any issues surface.

Stop the web service deployment and the Flink topology

Stop the descriptor using the following command:

kubectl scale deployments/injector-jira --replicas=0

Kill the Flink Topology using the URLs outlined in the AWS Infra doc.

At this point, the services will be down and ready to migrate.

Migrate the database

Using a terminal with access to both RDS instances (System of Record and the new Jira instance), run the following commands:

# Creates an intermediate file
PGPASSWORD=<pass> pg_dump -h sor.ph-dev.beescloud.com -p 5432 -U soradmin -C -n 'jira' data > db.sql
PGPASSWORD=<pass> psql  -h sdm-ji-dev.beescloud.com -p 5432 -U soradmin -f db.sql postgres

# OR 

# Without an intermediate file
PGPASSWORD=<pass> pg_dump -h sor.ph-dev.beescloud.com -p 5432 -U soradmin -C -n 'jira' data | PGPASSWORD=<pass> psql  -h sdm-ji-dev.beescloud.com -p 5432 -U soradmin postgres

Domain Names:

  • sor.ph-dev.beescloud.com & sdm-ji-dev.beescloud.com
  • sor.ph.beescloud.com & sdm-ji.beescloud.com
  • sor.ph.cloudbees.com & sdm-ji.cloudbees.com

Once migrated, verify that the tables exist and that data is in each table as expected.

Redeploy the web service (which should redeploy the topology)

Modify the deployment again, this time adjusting the environment variable to point to the metadata database.

kubectl edit deployments.apps/injector-jira

Change the spec.replica to 1 and

# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: apps/v1
kind: Deployment
metadata:
  ...
spec:
  ...
  template:
    metatdata:
      ...
    spec:
      containers:
      - env:
        ...
        - name: METADATA_HOST
          value: sor.ph-dev.beescloud.com <--- CHANGE THIS LINE
        - name: METADATA_PORT
          value: "5432"
        - name: METADATA_DB
          value: data
        - name: QUARKUS_DATASOURCE_URL
          value: jdbc:postgresql://sor.ph-dev.beescloud.com:5432/data?currentSchema=jira <-- CHANGE THIS LINE
        - name: METADATA_USER
          value: injector_jira
        - name: QUARKUS_DATASOURCE_USERNAME
          valueFrom:
            secretKeyRef:
              key: username
              name: injector-jira-db-user
              optional: false
        - name: METADATA_PASS
          value: vault://cloudbees/secret/development/ph-dev/k8s/ph-sor-injector-jira:injector_jira_db_user_password
        - name: QUARKUS_DATASOURCE_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: injector-jira-db-user
              optional: false

Once you save the file, the pod should start creating. View the pod logs to ensure that it redeploys the topology - you can verify in the logs or in the running topology config that the topology has the correct METADATA_HOST host value.

Verify all is working in the environment

We can get support from Jordan/Ryan on this to trigger events and ensure that they flow through correctly.

Repeat in then next environment

@mgagliardo91
Copy link
Author

@ryanwren @jordanglassman for the verification step above, can we either get your help or some advice on how we can verify all is well?

@ryanwren
Copy link

@mgagliardo91 the Jira Connect app is installed on the CloudBees Jira Instance for dev, staging and production. We can verify that all is well by creating / updating / deleting issues & comments, and then verifying that the data is updated as expected by querying for the issue in the GraphQL playgrounds. I can assist with this as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment