-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add logic for upgrading from Postgres 13 to 15 #122
Conversation
7845b42
to
3977146
Compare
I can't figure out why CI is failing when running this line:
@aknochow @dsavineau any ideas? |
I think this comment should have landed on the galaxy-operator repository instead of the eda operator right ? |
not sure if I'm testing this correctly because this should be the same code than awx-operator but the upgrade fails when searching for the previous postgresql pod. TASK [Set info for previous postgres pod] **************************************
task path: /opt/ansible/roles/postgres/tasks/check_postgres_version.yml:22
ok: [localhost] => {
"ansible_facts": {
"sorted_old_postgres_pods": "<list_reverseiterator object at 0x7f539eaa5610>"
},
"changed": false
}
TASK [Set info for previous postgres pod] **************************************
task path: /opt/ansible/roles/postgres/tasks/check_postgres_version.yml:29
"old_postgres_pod": "<"
},
"changed": false
}
(...)
TASK [postgres : Get old PostgreSQL version] ***********************************
task path: /opt/ansible/roles/postgres/tasks/check_postgres_version.yml:56
fatal: [localhost]: FAILED! => {
"msg": "The task includes an option with an undefined variable. The error was: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'metadata'\n\nThe error appears to be in '/opt/ansible/roles/postgres/tasks/check_postgres_version.yml': line 56, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Get old PostgreSQL version\n ^ here\n" Also I noticed that |
alright this seems related to the ansible version (and/or python version) used by the operator
if I switch to v1.34.0 then I don't have the issue anymore. I'll need to look more to understand why it's failing with the old version because we're likely to still use ansible 2.9 downstream |
The |
@rooftopcellist I've pushed some fixes for this PR so don't forget to fetch the changes if you want to push new things With those fixes, the error I'm facing occurs during the postgresql dump/restore on the pg 15 pod pg_restore: error: could not execute query: ERROR: must be member of role "postgres"
Command was: ALTER SCHEMA public OWNER TO postgres;
pg_restore: warning: errors ignored on restore: 1 Note sure why we have this. I'll continue to debug it next week and try to do a similar pg upgrade for the awx operator to see if we don't have the same symptoms |
@rooftopcellist with the latest changes I pushed, I was able to upgrade from 13 to 15 without issue. However, the change about granting the postgres role temporary to the eda postgresql user seems weird to me because we never had to do this in other operators for other postgresql upgrade (12 or 13) |
I have less concerns about the postgresql upgrade from 13 to 15 for the EDA operator because it was already using postgresql image from sclorg as default. |
@kurokobo I tested out a fresh install on k3s following similar steps to what you've shown in your awx-on-k3s repo and was not able to reproduce the permission error in the postgres pod that caused us to add these changes to the awx-operator: I pinned the redis image to Since all of the comments have been addressed and tests are passing in every scenario I can think of, I plan to merge this shortly. TestingOn Openshift: I ran through a fresh install, backup, restore, and upgraded from On k3s: Notes for follow-up:
|
With ansible 2.9.27 (operator-sdk v1.27.0) then the reverse filter returns an iterator so we need to cast it to list. The behavior doesn't exist when using a more recent operator-sdk version like v1.34.0 (ansible-core 2.15.8) but using the list filter on that version works too (even if not needed) "sorted_old_postgres_pods": "<list_reverseiterator object at 0x7f539eaa5610>" Signed-off-by: Dimitri Savineau <[email protected]>
During postgresql upgrade we're scaling down EDA deployments but this requires to have proper permissions configured (patch on deployments/scale) message: deployments.apps "eda-default-worker" is forbidden: User "system:serviceaccount:aap:eda-server-operator-controller-manager" cannot patch resource "deployments/scale" in API group "apps" in the namespace aap reason:Forbidden Signed-off-by: Dimitri Savineau <[email protected]>
The variable for the postgresql version had a typo. It was using supported_postgres_version rather than supported_pg_version. fatal: [localhost]: FAILED! => { "msg": "The task includes an option with an undefined variable. The error was: 'supported_postgres_version' is undefined } Signed-off-by: Dimitri Savineau <[email protected]>
The postgres_keep_pvc_after_upgrade variable wasn't defined in the postgres role leading to the following error: "msg": "The conditional check 'postgres_keep_pvc_after_upgrade' failed. The error was: error while evaluating conditional (postgres_keep_pvc_after_upgrade): 'postgres_keep_pvc_after_upgrade' is undefined Signed-off-by: Dimitri Savineau <[email protected]>
During the postgresql upgrade, we need to grant temporary the postgres role to the eda postgresql user and remove it after the pg_restore is over. pg_restore: error: could not execute query: ERROR: must be member of role "postgres" Command was: ALTER SCHEMA public OWNER TO postgres; Signed-off-by: Dimitri Savineau <[email protected]>
- This was removed because it is not respected by the sclorg PostgreSQL image
@rooftopcellist |
I hadn't seen that yet, thanks for the link! I'll check out the similar one for galaxy. Thanks for checking out the changes! |
@rooftopcellist One concern is that the To reproduce, please follow my guide again, with skipping I think it is a good idea to implement Any thought? |
@kurokobo ahh you are absolutely correct. I did have the chown 26 line in my reproducer script because I saw it in your repo instructions. But I agree, it's better to implement |
SUMMARY
Upgrading from postgres 13 to 15.
Related PR:
ISSUE TYPE