diff options
author | Lingxian Kong <anlin.kong@gmail.com> | 2021-06-18 11:30:03 +1200 |
---|---|---|
committer | Lingxian Kong <anlin.kong@gmail.com> | 2021-06-22 19:10:14 +1200 |
commit | b050996b9f6df738a0f68ac36a5b5f17f8bb2bc2 (patch) | |
tree | 13a5124d6ea4b9d13e892601034bc5ac004284dc /backup | |
parent | 6d2ab68a8aa0406ee6320e778b8e290827c9e730 (diff) | |
download | trove-b050996b9f6df738a0f68ac36a5b5f17f8bb2bc2.tar.gz |
Use bridge network for db container
- Changed the network mode of database container to "bridge" and exposed
the service ports.
- Use socket file to connect with the database.
- Upgrade the backup container image for postgressql.
Change-Id: Id5b119f8a474befc3a2cd6e061bbffc4ae5f7bb6
Diffstat (limited to 'backup')
-rw-r--r-- | backup/Dockerfile | 2 | ||||
-rw-r--r-- | backup/utils/postgresql.py | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/backup/Dockerfile b/backup/Dockerfile index f60149c7..3827bfc7 100644 --- a/backup/Dockerfile +++ b/backup/Dockerfile @@ -18,7 +18,7 @@ WORKDIR /opt/trove/backup RUN ./install.sh $DATASTORE RUN apt-get update \ - && apt-get install $APTOPTS build-essential python3-setuptools python3-all python3-all-dev python3-pip libffi-dev libssl-dev libxml2-dev libxslt1-dev libyaml-dev \ + && apt-get install $APTOPTS build-essential python3-setuptools python3-all python3-all-dev python3-pip libffi-dev libssl-dev libxml2-dev libxslt1-dev libyaml-dev libpq-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ && pip3 --no-cache-dir install -U -r requirements.txt \ diff --git a/backup/utils/postgresql.py b/backup/utils/postgresql.py index 033652f0..e43570e9 100644 --- a/backup/utils/postgresql.py +++ b/backup/utils/postgresql.py @@ -15,7 +15,17 @@ import psycopg2 class PostgresConnection(object): - def __init__(self, user, password='', host='localhost', port=5432): + def __init__(self, user, password='', host='/var/run/postgresql', + port=5432): + """Utility class to communicate with PostgreSQL. + + Connect with socket rather than IP or localhost address to avoid + manipulation of pg_hba.conf when the database is running inside + container with bridge network. + + This class is consistent with PostgresConnection in + trove/guestagent/datastore/postgres/service.py + """ self.user = user self.password = password self.host = host |