nextcloud / nextcloud/docker

Automated upgrade fails on Nextcloud instance that uses Postgres with sslmode=require

Open
#2,317 4 comments 0 reactions 0 assignees View on GitHub

@joshtrichards is already working on this.

Since Oct 19, 2024.

  • #2318 by @joshtrichards — open
bug feature: auto config (environment variables) feature: auto config (hooks)
Dominant language
Shell
Stars
7.4k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

This issue only occurs on upgrade, normal nextcloud operation works fine.
My setup is that i use Postgres sslmode=require, which means that SSL needs to be used, but the certificate is not verified.
The upgrade script seems to try to verify the certificate, which it shouldn't do pg docs.

config.php snippet:

  'dbtype' => 'pgsql',
  'dbname' => 'nextcloud',
  'dbhost' => 'tools-pg-pooler:5432;sslmode=require',
  'dbport' => '',
  'dbtableprefix' => 'oc_',

Logs of failure:

Defaulted container "nextcloud" out of: nextcloud, nextcloud-cron
Configuring Redis as session handler
Initializing nextcloud 30.0.1.2 ...
Upgrading nextcloud from 29.0.7.1 ...
=> Searching for scripts (*.sh) to run, located in the folder: /docker-entrypoint-hooks.d/pre-upgrade
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] connection to server at "tools-pg-pooler" (10.43.28.253), port 5432 failed: could not open certificate file "/root/.postgresql/postgresql.crt": Permission denied
connection to server at "tools-pg-pooler" (10.43.28.253), port 5432 failed: FATAL:  SSL required in /var/www/html/lib/private/DB/Connection.php:233
Stack trace:
#0 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(453): OC\DB\Connection->connect()
#1 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(411): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(318): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /var/www/html/lib/private/DB/Connection.php(899): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /var/www/html/lib/private/DB/ConnectionAdapter.php(235): OC\DB\Connection->getDatabaseProvider()
#5 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(96): OC\DB\ConnectionAdapter->getDatabaseProvider()
#6 /var/www/html/lib/private/AppConfig.php(1211): OC\DB\QueryBuilder\QueryBuilder->expr()
#7 /var/www/html/lib/private/AppConfig.php(237): OC\AppConfig->loadConfig(false)
#8 /var/www/html/lib/private/AppConfig.php(1351): OC\AppConfig->searchValues('enabled', false, 2)
#9 /var/www/html/lib/private/App/AppManager.php(126): OC\AppConfig->getValues(false, 'enabled')
#10 /var/www/html/lib/private/App/AppManager.php(147): OC\App\AppManager->getInstalledAppsValues()
#11 /var/www/html/lib/private/legacy/OC_App.php(191): OC\App\AppManager->getInstalledApps()
#12 /var/www/html/lib/private/AppFramework/Bootstrap/Coordinator.php(48): OC_App::getEnabledApps()
#13 /var/www/html/lib/base.php(657): OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()
#14 /var/www/html/lib/base.php(1132): OC::init()
#15 /var/www/html/console.php(28): require_once('/var/www/html/l...')
#16 /var/www/html/occ(11): require_once('/var/www/html/c...')
#17 {main}⏎                                                                                                                                                                                                                                                                      4m36s ••     

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review open pull request #2318 first, then trace the Docker upgrade path that invokes occ and the database connection setup shown in lib/private/DB/Connection.php. Reproduce the upgrade with PostgreSQL sslmode=require and confirm that the completed behavior preserves SSL without requiring certificate verification.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, postgresql, shell
Domain
databases, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.