Skip to content

Commit

Permalink
Upgrade to postgres:15 (ansible#14230)
Browse files Browse the repository at this point in the history
* Upgrade to postgres:15
* Changed postgres:15 to quay.io/sclorg/postgresql-15-c9s
  • Loading branch information
john-westcott-iv authored and djyasin committed Sep 11, 2024
1 parent 123277f commit dd1e6bc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,6 @@ clean-elk:
docker rm tools_elasticsearch_1
docker rm tools_kibana_1

psql-container:
docker run -it --net tools_default --rm postgres:12 sh -c 'exec psql -h "postgres" -p "5432" -U postgres'

VERSION:
@echo "awx: $(VERSION)"

Expand Down
6 changes: 4 additions & 2 deletions awx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ def manage():
from django.conf import settings
from django.core.management import execute_from_command_line

# enforce the postgres version is equal to 12. if not, then terminate program with exit code of 1
# enforce the postgres version is a minimum of 12 (we need this for partitioning); if not, then terminate program with exit code of 1
# In the future if we require a feature of a version of postgres > 12 this should be updated to reflect that.
# The return of connection.pg_version is something like 12013
if not os.getenv('SKIP_PG_VERSION_CHECK', False) and not MODE == 'development':
if (connection.pg_version // 10000) < 12:
sys.stderr.write("Postgres version 12 is required\n")
sys.stderr.write("At a minimum, postgres version 12 is required\n")
sys.exit(1)

if len(sys.argv) >= 2 and sys.argv[1] in ('version', '--version'): # pragma: no cover
Expand Down
2 changes: 1 addition & 1 deletion awx/main/analytics/collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def query(event_data):
resolved_action,
resolved_role,
-- '-' operator listed here:
-- https://www.postgresql.org/docs/12/functions-json.html
-- https://www.postgresql.org/docs/15/functions-json.html
-- note that operator is only supported by jsonb objects
-- https://www.postgresql.org/docs/current/datatype-json.html
(CASE WHEN event = 'playbook_on_stats' THEN {event_data} - 'artifact_data' END) as playbook_on_stats,
Expand Down
3 changes: 1 addition & 2 deletions tools/ansible/roles/dockerfile/templates/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ RUN for dir in \
/var/lib/awx/.local/share/containers/storage \
/var/run/awx-rsyslog \
/var/log/nginx \
/var/lib/postgresql \
/var/lib/pgsql \
/var/run/supervisor \
/var/run/awx-receptor \
/var/lib/nginx ; \
Expand Down Expand Up @@ -300,7 +300,6 @@ RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
{% endif %}

ENV HOME="/var/lib/awx"
ENV PATH="/usr/pgsql-12/bin:${PATH}"

{% if build_dev|bool %}
ENV PATH="/var/lib/awx/venv/awx/bin/:${PATH}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,16 @@ services:
# context: ../../docker-compose
# dockerfile: Dockerfile-logstash
postgres:
image: postgres:12
image: quay.io/sclorg/postgresql-15-c9s
container_name: tools_postgres_1
# additional logging settings for postgres can be found https://www.postgresql.org/docs/current/runtime-config-logging.html
command: postgres -c log_destination=stderr -c log_min_messages=info -c log_min_duration_statement={{ pg_log_min_duration_statement|default(1000) }} -c max_connections={{ pg_max_connections|default(1024) }}
command: run-postgresql -c log_destination=stderr -c log_min_messages=info -c log_min_duration_statement={{ pg_log_min_duration_statement|default(1000) }} -c max_connections={{ pg_max_connections|default(1024) }}
environment:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_USER: {{ pg_username }}
POSTGRES_DB: {{ pg_database }}
POSTGRES_PASSWORD: {{ pg_password }}
POSTGRESQL_USER: {{ pg_username }}
POSTGRESQL_DATABASE: {{ pg_database }}
POSTGRESQL_PASSWORD: {{ pg_password }}
volumes:
- "awx_db:/var/lib/postgresql/data"
- "awx_db_15:/var/lib/pgsql/data"
networks:
- awx
ports:
Expand Down Expand Up @@ -305,8 +304,9 @@ services:
{% endif %}

volumes:
awx_db:
name: tools_awx_db
{# For the postgres 15 db upgrade we changed the mount name because 15 can't load a 12 DB #}
awx_db_15:
name: tools_awx_db_15
{% for i in range(control_plane_node_count|int) -%}
{% set container_postfix = loop.index %}
redis_socket_{{ container_postfix }}:
Expand Down

0 comments on commit dd1e6bc

Please sign in to comment.