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

Upgrade from PG 13 to PG 15 & move to sclorg images #1069

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions bundle/manifests/pulp-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ spec:
- name: RELATED_IMAGE_PULP_REDIS
value: redis:latest
- name: RELATED_IMAGE_PULP_POSTGRES
value: postgres:13
value: quay.io/sclorg/postgresql-15-c9s:latest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rooftopcellist!

Thank you for your contribution!
By default, this new image will run as user 1000 in vanilla k8s. Because of that, when the bkp-manager container tries to make a copy of /var/lib/pulp/tmp/<worker files> (which has 0700 permission and is owned by user 700), it is getting permission denied error and failing the backup task.

The old image (postgres:13 from dockerhub) had the access permissions because it was running with uid 0 (root).

- name: RELATED_IMAGE_PULP_INIT_GPG_CONTAINER
value: quay.io/centos/centos:stream9
image: quay.io/pulp/pulp-operator:v0.15.0.dev
Expand Down Expand Up @@ -1308,6 +1308,6 @@ spec:
name: pulp-web
- image: redis:latest
name: pulp-redis
- image: postgres:13
- image: quay.io/sclorg/postgresql-15-c9s:latest
name: pulp-postgres
version: 0.15.0
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
- name: RELATED_IMAGE_PULP_REDIS
value: redis:latest
- name: RELATED_IMAGE_PULP_POSTGRES
value: postgres:13
value: quay.io/sclorg/postgresql-15-c9s:latest
- name: RELATED_IMAGE_PULP_INIT_GPG_CONTAINER
value: quay.io/centos/centos:stream9
securityContext:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ spec:
- name: RELATED_IMAGE_PULP_REDIS
value: redis:latest
- name: RELATED_IMAGE_PULP_POSTGRES
value: postgres:13
value: quay.io/sclorg/postgresql-15-c9s:latest
- name: RELATED_IMAGE_PULP_INIT_GPG_CONTAINER
value: quay.io/centos/centos:stream9
image: quay.io/pulp/pulp-operator:devel
Expand Down
3 changes: 2 additions & 1 deletion roles/backup/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ backup_storage_requirements: ''
# Specify storage class to determine how to dynamically create PVC's with
backup_storage_class: ''

postgres_version: 13
postgres_version: 15
_postgres_image: quay.io/sclorg/postgresql-15-c9s:latest

# Secret Names
admin_password_secret: "{{ deployment_name }}-admin-password"
Expand Down
3 changes: 2 additions & 1 deletion roles/backup/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---

deployment_type: "pulp"
_postgres_image: postgres:13
postgres_version: 15
_postgres_image: quay.io/sclorg/postgresql-15-c9s:latest
5 changes: 3 additions & 2 deletions roles/postgres/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
deployment_type: pulp

postgres_version: 13
_postgres_image: postgres:13
postgres_version: 15
old_postgres_pod: []
_postgres_image: quay.io/sclorg/postgresql-15-c9s:latest

postgres_storage_requirements:
requests:
Expand Down
4 changes: 2 additions & 2 deletions roles/postgres/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@
"""
register: _old_pg_version

- name: Upgrade data dir from Postgres 12 to 13 if applicable
- name: Upgrade data dir from old Postgres to {{ postgres_version }} if applicable
include_tasks: upgrade_postgres.yml
when:
- _old_pg_version.stdout | default('0') | trim == '12'
- (_old_pg_version.stdout | default(0) | int ) < supported_pg_version
when:
- managed_database
- this_pulp['resources'][0]['status']['upgradedPostgresVersion'] | default('none') != '12'
Expand Down
36 changes: 28 additions & 8 deletions roles/postgres/tasks/upgrade_postgres.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---

# Upgrade Postgres (Managed Databases only)
# * If postgres version is not 12, and not an external postgres instance (when managed_database is yes),
# then run this playbook with include_tasks from database_configuration.yml
# * If postgres version is not the default/supported postgres_version, and not an
# external postgres instance (when managed_database is yes), then run this playbook
# with include_tasks from database_configuration.yml
# * Data will be streamed via a pg_dump from the postgres 12 pod to the postgres 13
# pod via a pg_restore.

Expand Down Expand Up @@ -42,7 +43,7 @@
status: "False"
lastTransitionTime: "{{ lookup('pipe', 'date --iso-8601=seconds') }}"

- name: Create Database configuration with new -postgres-{{ postgres_version }} hostname
- name: Create Database configuration secret with new -postgres-{{ postgres_version }} hostname
k8s:
apply: true
definition: "{{ lookup('template', 'postgres_upgrade.secret.yaml.j2') }}"
Expand Down Expand Up @@ -123,9 +124,19 @@
set_fact:
postgres_pod_name: "{{ postgres_pod['resources'][0]['metadata']['name'] }}"

- name: Get the name of the service for the old postgres pod
k8s_info:
kind: Service
namespace: "{{ ansible_operator_meta.namespace }}"
label_selectors:
- "app.kubernetes.io/component=database"
- "app.kubernetes.io/instance={{ old_postgres_pod.metadata.labels['app.kubernetes.io/instance'] }}"
- "app.kubernetes.io/managed-by=pulp-operator"
register: old_postgres_svc

- name: Set full resolvable host name for old postgres pod
set_fact:
resolvable_db_host: "{{ ansible_operator_meta.name }}-postgres-svc.{{ ansible_operator_meta.namespace }}.svc.cluster.local" # yamllint disable-line rule:line-length
resolvable_db_host: "{{ old_postgres_svc['resources'][0]['metadata']['name'] }}.{{ ansible_operator_meta.namespace }}.svc.cluster.local" # yamllint disable-line rule:line-length
no_log: "{{ no_log }}"


Expand Down Expand Up @@ -200,7 +211,7 @@

- name: Set flag signifying that this instance has been migrated
set_fact:
upgraded_postgres_version: '13'
upgraded_postgres_version: '{{ postgres_version }}'

- k8s_status:
api_version: "{{ api_version }}"
Expand All @@ -220,9 +231,12 @@
kind: StatefulSet
api_version: v1
namespace: "{{ ansible_operator_meta.namespace }}"
name: "{{ ansible_operator_meta.name }}-postgres"
name: "{{ item }}"
state: absent
wait: true
loop:
- "{{ ansible_operator_meta.name }}-postgres"
- "{{ ansible_operator_meta.name }}-postgres-13"

- k8s_status:
api_version: "{{ api_version }}"
Expand All @@ -241,8 +255,11 @@
kind: Service
api_version: v1
namespace: "{{ ansible_operator_meta.namespace }}"
name: "{{ ansible_operator_meta.name }}-postgres-svc"
name: "{{ item }}"
state: absent
loop:
- "{{ ansible_operator_meta.name }}-postgres-svc"
- "{{ ansible_operator_meta.name }}-postgres-13"

- k8s_status:
api_version: "{{ api_version }}"
Expand All @@ -261,8 +278,11 @@
kind: PersistentVolumeClaim
api_version: v1
namespace: "{{ ansible_operator_meta.namespace }}"
name: "postgres-{{ ansible_operator_meta.name }}-postgres-0"
name: "{{ item }}"
state: absent
loop:
- "postgres-{{ ansible_operator_meta.name }}-postgres-0"
- "postgres-{{ ansible_operator_meta.name }}-postgres-13-0"
when:
- postgres_keep_pvc_after_upgrade is defined
- postgres_keep_pvc_after_upgrade | length
Expand Down
2 changes: 1 addition & 1 deletion roles/restore/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

deployment_type: "pulp"
_postgres_image: postgres:13
_postgres_image: quay.io/sclorg/postgresql-15-c9s:latest

custom_resource_key: '_pulp_pulpproject_org_pulprestore'

Expand Down
Loading