[DRE-maint] Bug#901379: gitlab: postinst script should not call psql if database is not managed by dbconfig-common
Pirate Praveen
praveen at onenetbeyond.org
Sat Dec 12 09:01:22 GMT 2020
On Fri, 11 Dec 2020 23:53:27 +0100 <devel at sumpfralle.de> wrote:
> Hello,
>
> I encounter the same problem (psql directly used in postinst script)
during
> every package upgrade.
>
> The main problem (in my case) is the misdetection of an
uninitialized database
> (see "db_relations" in /usr/lib/gitlab/scripts/rake-tasks.sh).
> The script checks via "psql" (locally), whether the database is
already
> populated. Since the database is empty, the initial database setup
is started
> (this time using rake for interacting with the configured external
database).
> This initialization fails, since the real database is not empty.
> Thus postinst fails.
>
> My current workaround is to run the following loop in a separate
shell:
>
> while sleep 1; do sed -i 's/db_relations"/db_relationsXXX"/' \
> /usr/lib/gitlab/scripts/rake-tasks.sh; done
>
> This overrides the test for an empty database.
> Another approach could be to simply populate the local (unused)
database.
>
> The proper solution would be to use the *configured* database
connection
> instead of running "psql" directly. Maybe this could be done via
rake?
>
> If you could give me any hints in this direction, then I could
propose a patch
> for fixing the database accesses in the postinst other related
scripts.
We can read dbc_dbserver value from /etc/dbconfig-common/gitlab.conf
and use psql -h $dbc_dbserver to check remotely.
More information about the Pkg-ruby-extras-maintainers
mailing list