Merge "Change postgresql socket path to a persistent path"
This commit is contained in:
commit
27e5a710ce
@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
fixes:
|
||||
- |
|
||||
Fix a bug where the postgresql container is unable to recover
|
||||
after a reboot of the Nova instance.
|
||||
`Story 2010599 <https://storyboard.openstack.org/#!/story/2010599>`__
|
@ -19,3 +19,4 @@ DOCKER_NETWORK_NAME = "database-network"
|
||||
DOCKER_HOST_NIC_MODE = "docker-hostnic"
|
||||
DOCKER_BRIDGE_MODE = "bridge"
|
||||
MYSQL_HOST_SOCKET_PATH = "/var/lib/mysqld"
|
||||
POSTGRESQL_HOST_SOCKET_PATH = "/var/lib/postgresql-socket"
|
||||
|
@ -18,6 +18,7 @@ from oslo_log import log as logging
|
||||
from oslo_service import periodic_task
|
||||
|
||||
from trove.common import cfg
|
||||
from trove.common import constants
|
||||
from trove.common import exception
|
||||
from trove.common.notification import EndNotification
|
||||
from trove.common import utils
|
||||
@ -212,8 +213,8 @@ class PostgresManager(manager.Manager):
|
||||
'/var/lib/postgresql/data': {
|
||||
'bind': '/var/lib/postgresql/data', 'mode': 'rw'
|
||||
},
|
||||
"/var/run/postgresql": {"bind": "/var/run/postgresql",
|
||||
"mode": "ro"},
|
||||
constants.POSTGRESQL_HOST_SOCKET_PATH:
|
||||
{"bind": "/var/run/postgresql", "mode": "ro"},
|
||||
}
|
||||
extra_params = f"--pg-wal-archive-dir {service.WAL_ARCHIVE_DIR}"
|
||||
|
||||
|
@ -177,7 +177,8 @@ class PgSqlApp(service.BaseDbApp):
|
||||
user = "%s:%s" % (CONF.database_service_uid, CONF.database_service_uid)
|
||||
|
||||
# Create folders for postgres on localhost
|
||||
for folder in ['/etc/postgresql', '/var/run/postgresql']:
|
||||
for folder in ['/etc/postgresql',
|
||||
constants.POSTGRESQL_HOST_SOCKET_PATH]:
|
||||
operating_system.ensure_directory(
|
||||
folder, user=CONF.database_service_uid,
|
||||
group=CONF.database_service_uid, force=True,
|
||||
@ -185,8 +186,8 @@ class PgSqlApp(service.BaseDbApp):
|
||||
|
||||
volumes = {
|
||||
"/etc/postgresql": {"bind": "/etc/postgresql", "mode": "rw"},
|
||||
"/var/run/postgresql": {"bind": "/var/run/postgresql",
|
||||
"mode": "rw"},
|
||||
constants.POSTGRESQL_HOST_SOCKET_PATH:
|
||||
{"bind": "/var/run/postgresql", "mode": "rw"},
|
||||
"/var/lib/postgresql": {"bind": "/var/lib/postgresql",
|
||||
"mode": "rw"},
|
||||
"/var/lib/postgresql/data": {"bind": "/var/lib/postgresql/data",
|
||||
@ -240,7 +241,8 @@ class PgSqlApp(service.BaseDbApp):
|
||||
LOG.info("Restarting database")
|
||||
|
||||
# Ensure folders permission for database.
|
||||
for folder in ['/etc/postgresql', '/var/run/postgresql']:
|
||||
for folder in ['/etc/postgresql',
|
||||
constants.POSTGRESQL_HOST_SOCKET_PATH]:
|
||||
operating_system.ensure_directory(
|
||||
folder, user=CONF.database_service_uid,
|
||||
group=CONF.database_service_uid, force=True,
|
||||
@ -341,8 +343,8 @@ class PgSqlApp(service.BaseDbApp):
|
||||
image = f'{docker_image}:{CONF.datastore_version}'
|
||||
user = "%s:%s" % (CONF.database_service_uid, CONF.database_service_uid)
|
||||
volumes = {
|
||||
"/var/run/postgresql": {"bind": "/var/run/postgresql",
|
||||
"mode": "rw"},
|
||||
constants.POSTGRESQL_HOST_SOCKET_PATH:
|
||||
{"bind": "/var/run/postgresql", "mode": "rw"},
|
||||
"/var/lib/postgresql": {"bind": "/var/lib/postgresql",
|
||||
"mode": "rw"},
|
||||
"/var/lib/postgresql/data": {"bind": "/var/lib/postgresql/data",
|
||||
@ -746,7 +748,8 @@ class PgSqlAdmin(object):
|
||||
|
||||
|
||||
class PostgresConnection(object):
|
||||
def __init__(self, user, password=None, host='/var/run/postgresql',
|
||||
def __init__(self, user, password=None,
|
||||
host=constants.POSTGRESQL_HOST_SOCKET_PATH,
|
||||
port=5432):
|
||||
"""Utility class to communicate with PostgreSQL.
|
||||
|
||||
|
@ -126,8 +126,8 @@ class PostgresqlReplicationStreaming(base.Replication):
|
||||
'/var/lib/postgresql/data': {
|
||||
'bind': '/var/lib/postgresql/data', 'mode': 'rw'
|
||||
},
|
||||
"/var/run/postgresql": {"bind": "/var/run/postgresql",
|
||||
"mode": "ro"},
|
||||
constants.POSTGRESQL_HOST_SOCKET_PATH:
|
||||
{"bind": "/var/run/postgresql", "mode": "ro"},
|
||||
}
|
||||
extra_params = f"--pg-wal-archive-dir {pg_service.WAL_ARCHIVE_DIR}"
|
||||
service.create_backup(context, snapshot_info,
|
||||
|
Loading…
Reference in New Issue
Block a user