Skip to content

Commit

Permalink
Add CI job for testing db upgrade from postgres to sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
harishsurf committed Jul 10, 2024
1 parent fd850a5 commit 93116b4
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 2 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- "*"
pull_request_target:
types: [labeled]
branches:
Expand Down Expand Up @@ -184,6 +187,42 @@ jobs:
- name: Uninstall Registry
run: ./mirror-registry uninstall -u jonathan -H quay --autoApprove -v -k /home/runner/.ssh/id_rsa

- name: Download old mirror-registry tarball that runs quay with postgres
run: wget -O mirror-registry-postgres.tar.gz https://github.com/quay/mirror-registry/releases/download/v1.3.10/mirror-registry-online.tar.gz

- name: Create extraction directory for old mirror-registry binary
run: mkdir -p ./mirror-registry-postgres

- name: Extract tarball into the folder
run: tar -xzf mirror-registry-postgres.tar.gz -C ./mirror-registry-postgres

- name: Install postgres backed quay registry
run: ./mirror-registry-postgres/mirror-registry install -u jonathan -r /home/jonathan/quay-install -H quay -v --initPassword password -k /home/runner/.ssh/id_rsa

- name: Podman login to quay registry
run: podman login -u init -p password quay:8443 --tls-verify=false

- name: Pull busybox image from Docker Hub
run: podman pull docker.io/library/busybox

- name: Tag busybox image for Quay
run: podman tag docker.io/library/busybox quay:8443/init/busybox:latest

- name: Push busybox image to Quay
run: podman push quay:8443/init/busybox:latest --tls-verify=false

- name: Use latest binary to test upgrade cmd to ensure db migration from old postgres to sqlite
run: ./mirror-registry upgrade -u jonathan -r /home/jonathan/quay-install -H quay -v --initPassword password -k /home/runner/.ssh/id_rsa

- name: Pull already pushed busybox image from quay registry
run: podman pull quay:8443/init/busybox:latest

- name: Verify busybox image is pulled successfully
run: podman images | grep -q quay:8443/init/busybox:latest

- name: Uninstall Registry
run: ./mirror-registry uninstall -u jonathan -H quay --autoApprove -v -k /home/runner/.ssh/id_rsa

- name: Terraform Destroy
run: terraform destroy --auto-approve
shell: bash
Expand Down Expand Up @@ -292,6 +331,45 @@ jobs:
- name: Uninstall Quay
run: ssh jonathan@quay './mirror-registry uninstall --autoApprove -v'

- name: Download old mirror-registry tarball that runs quay with postgres
run: wget -O mirror-registry-postgres.tar.gz https://github.com/quay/mirror-registry/releases/download/v1.3.10/mirror-registry-online.tar.gz

- name: SCP old tarball to VM
run: scp mirror-registry-postgres.tar.gz jonathan@quay:~/mirror-registry-postgres.tar.gz

- name: Create extraction directory for old mirror-registry binary
run: ssh jonathan@quay 'mkdir -p ./mirror-registry-postgres'

- name: Extract tarball into the folder
run: ssh jonathan@quay 'tar -xzf mirror-registry-postgres.tar.gz -C ./mirror-registry-postgres'

- name: Install postgres backed quay registry
run: ssh jonathan@quay './mirror-registry-postgres/mirror-registry install -u jonathan -r /home/jonathan/quay-install -H quay -v --initPassword password -k /home/runner/.ssh/id_rsa'

- name: Podman login to quay registry
run: ssh jonathan@quay 'podman login -u init -p password quay:8443 --tls-verify=false'

- name: Pull busybox image from Docker Hub
run: ssh jonathan@quay 'podman pull docker.io/library/busybox'

- name: Tag busybox image for Quay
run: ssh jonathan@quay 'podman tag docker.io/library/busybox quay:8443/init/busybox:latest'

- name: Push busybox image to Quay
run: ssh jonathan@quay 'podman push quay:8443/init/busybox:latest --tls-verify=false'

- name: Use latest binary to test upgrade cmd to ensure db migration from old postgres to sqlite
run: ssh jonathan@quay './mirror-registry upgrade -u jonathan -r /home/jonathan/quay-install -H quay -v --initPassword password -k /home/runner/.ssh/id_rsa'

- name: Pull already pushed busybox image from quay registry
run: ssh jonathan@quay 'podman pull quay:8443/init/busybox:latest'

- name: Verify busybox image was pulled successfully
run: ssh jonathan@quay 'podman images | grep -q quay:8443/init/busybox:latest'

- name: Uninstall Quay
run: ssh jonathan@quay './mirror-registry uninstall --autoApprove -v'

- name: Terraform Destroy
run: terraform destroy --auto-approve
shell: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@
ansible.builtin.set_fact:
quay_config_file: "{{ remote_yaml_file['content'] | b64decode | from_yaml }}"

- name: Set facts for the pre-existing secrets only if they are a string and not a jinja2 variable in the config.yaml.
- name: Set facts for the existing redis secrets only if they are a string and not a jinja2 variable in the config.yaml.
ansible.builtin.set_fact:
REDIS_PASSWORD : "{{ quay_config_file['USER_EVENTS_REDIS']['password'] }}"
when: quay_config_file['DATABASE_SECRET_KEY'] is string and quay_config_file['USER_EVENTS_REDIS']['password'] is string

- name: Check if quay-postgres container is running
command: podman ps -q -f name=quay-postgres
register: postgres_container_status
changed_when: false

- name: Set facts for existing postgres secrets only if they are a string and not a jinja2 variable in the config.yaml.
ansible.builtin.set_fact:
PGDB_PASSWORD : "{{ quay_config_file['DB_URI'].split('@')[0].split(':')[2] }}"
when: quay_config_file['DATABASE_SECRET_KEY'] is string and quay_config_file['USER_EVENTS_REDIS']['password'] is string and quay_config_file['DB_URI'] is string
when: postgres_container_status.stdout != "" and quay_config_file['DATABASE_SECRET_KEY'] is string and quay_config_file['DB_URI'] is string
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
- name: Autodetect existing Secrets in config.yaml
include_tasks: upgrade-config-vars.yaml

- name: Check if quay-postgres container is running
command: podman ps -q -f name=quay-postgres
register: postgres_container_status
changed_when: false

- name: Migrate postgres db to sqlite for Quay
include_tasks: migrate.yaml
when: postgres_container_status.stdout != ""

- name: Autodetect Image Archive
include_tasks: autodetect-image-archive.yaml
Expand Down

0 comments on commit 93116b4

Please sign in to comment.