Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postrgresql need to be started first while using externalDatabase #42

Closed
Skallwar opened this issue Nov 17, 2020 · 1 comment · Fixed by #89
Closed

Postrgresql need to be started first while using externalDatabase #42

Skallwar opened this issue Nov 17, 2020 · 1 comment · Fixed by #89

Comments

@Skallwar
Copy link

I found that if Postgresql is not running before the nextcloud docker image is launched, I get some weird issues:

Initializing nextcloud 19.0.3.1 ...
Initializing finished
New nextcloud instance
Installing with PostgreSQL database
starting nextcloud installation
PostgreSQL username and/or password not valid
 -> You need to enter details of an existing account.
retrying install...
An unhandled exception has been thrown:
OC\DatabaseException: An exception occurred while executing 'SHOW SERVER_VERSION':
Failed to connect to the database: An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused
	Is the server running on host "nextcloud-postgresql.nextcloud" (10.43.125.77) and accepting
	TCP/IP connections on port 5432? in /var/www/html/lib/private/legacy/OC_DB.php:73
Stack trace:
#0 /var/www/html/lib/private/legacy/OC_DB.php(139): OC_DB::prepare('SHOW SERVER_VER...', NULL, NULL)
#1 /var/www/html/lib/private/legacy/OC_Util.php(971): OC_DB::executeAudited(Array)
#2 /var/www/html/lib/private/legacy/OC_Util.php(951): OC_Util::checkDatabaseVersion()
#3 /var/www/html/lib/private/Console/Application.php(161): OC_Util::checkServer(Object(OC\SystemConfig))
#4 /var/www/html/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/html/occ(11): require_once('/var/www/html/c...')
#6 {main}retrying install...
An unhandled exception has been thrown:
OC\DatabaseException: An exception occurred while executing 'SHOW SERVER_VERSION':
Failed to connect to the database: An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused
	Is the server running on host "nextcloud-postgresql.nextcloud" (10.43.125.77) and accepting
	TCP/IP connections on port 5432? in /var/www/html/lib/private/legacy/OC_DB.php:73
Stack trace:
#0 /var/www/html/lib/private/legacy/OC_DB.php(139): OC_DB::prepare('SHOW SERVER_VER...', NULL, NULL)
#1 /var/www/html/lib/private/legacy/OC_Util.php(971): OC_DB::executeAudited(Array)
#2 /var/www/html/lib/private/legacy/OC_Util.php(951): OC_Util::checkDatabaseVersion()
#3 /var/www/html/lib/private/Console/Application.php(161): OC_Util::checkServer(Object(OC\SystemConfig))
#4 /var/www/html/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/html/occ(11): require_once('/var/www/html/c...')
#6 {main}retrying install...

nextcloud-values.yml:

...
externalDatabase:
  enabled: true
  type: postgresql
  host: nextcloud-postgresql.nextcloud:5432
  user: CHANGEME
  password: CHANGEME
  database: nextcloud


postgresql:
  enabled: true
  image:
    registry: docker.io
    repository: postgres
    tag: 13.1
    debug: true
  ...
...

Sometimes I get the setup screen of nextcloud (asking to create a new admin account), sometimes I just get an error code 503 indefinitely.

If I take the same value and I deploy the bitnami postgresql chart manualy (using the same config) and then I deploy nextcloud (with postgresql.enable = false this time) everything works great.
Currently, I have a script which does 2 deployments with a sleep in between to resolve this issue

helm install postgresql bitnami/postgresql --values ./postgresql-values.yml -n nextcloud
sleep 60
helm install nextcloud nextcloud/nextcloud --values ./nextcloud-values.yml -n nextcloud
@lukasmrtvy
Copy link

lukasmrtvy commented Dec 28, 2020

I can confirm, nextcloud installation is broken if external postgresql deployed with this chart is used.
Probably migration script will fail if postgresql is not ready, that will cause problems ^. Something like initContainer with psql and mariadb client that will wait for DB readiness would do the trick, a lot of charts are using this ..

@billimek ping

wrboyce added a commit to wrboyce/nextcloud-helm that referenced this issue Feb 24, 2021
wrboyce added a commit to wrboyce/nextcloud-helm that referenced this issue Feb 24, 2021
Fixes nextcloud#42

Signed-off-by: Will Boyce <me@willboyce.com>
menardorama pushed a commit to menardorama/helm that referenced this issue May 13, 2021
Fixes nextcloud#42

Signed-off-by: Will Boyce <me@willboyce.com>
Signed-off-by: Thomas Menard <menardorama@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants