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

PHP fails with NOMINATIM_DATABASE_DSN of old format #96

Open
ccrpc-fjunge opened this issue Jan 16, 2025 · 0 comments
Open

PHP fails with NOMINATIM_DATABASE_DSN of old format #96

ccrpc-fjunge opened this issue Jan 16, 2025 · 0 comments

Comments

@ccrpc-fjunge
Copy link
Contributor

What has changed

As of Nominatim version 3.3.0 the format of NOMINATIM_DATABASE_DSN has changed from

pgsql://johndoe:[email protected]:1234/db1

To

pgsql:dbname=db1;host=machine1.domain.com;port=1234;user=johndoe;password=secret

Source: https://nominatim.org/release-docs/latest/admin/Migration/#new-database-connection-string-dsn-format


The error I encountered

I have been attempting to set up an instance of Nominatim with this helm chart and ran into an issue at the very end: the nominatim command line interface worked, and I could connect to the database via psql, but the Nominatim API did not work with the webserver and status.php was returning ERROR: Database connection failed.

Attempting to search resulted in {"error":{"code":500,"message":"Failed to establish database connection:could not find driver"}}

This is with the helm chart setting up the postgresql database.


Testing done

I executed into the pod and in /nominatim/website I created a file called "customstatus.php" with everything the same as "status.php" with the exception that @define('CONST_Database_DSN' is 'pgsql:dbname=nominatim;host=geocode-postgresql;port=5432;user=postgres;password=nominatim'.

When visiting customstatus.php, I get the response "OK".


Solution (ish)

I executed into the pod running Nominatim and ran:

export NOMINATIM_DATABASE_DSN="pgsql:dbname=nominatim;host=geocode-postgresql;port=5432;user=postgres;password=nominatim"
nominatim refresh --website

After that the status page returns "ok" and searching works.

The nominatim command line interface (nominatim search --city Urbana) still works despite the change in ENV variable.

That said this has to be done manually after the pod has already started. This setting is undone if the deployment has to restart for any reason. This is not a long term solution.


Suggestion

In _helpers.tpl create a function

{{/*
Create the database DSN.
*/}}
{{- define "nominatim.databaseDSN" -}}
pgsql:dbname={{ include "nominatim.databaseName" . }};host={{ include "nominatim.databaseHost" . }};port={{ include "nominatim.databasePort" . }};user={{ include "nominatim.databaseUser" . }};password={{ include "nominatim.databasePassword" . }}
{{- end }}

In deployment.yaml rather than referencing databaseURL, reference databaseDSN (on line 165):

{{- else }}
value: {{ include "nominatim.databaseDSN" . }}
{{- end }}

I could create a pull request for this if that would be desirable.


Note

The initJob and updatesJob seem to work fine with the previous format for the DSN, as does the nominatim command line interface.
It seems to be specifically the lib-php which is incompatible.

The ENV in initJob.yaml and updatesJob.yaml could be updated for consistency or left alone.
That is a matter of preference.

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

No branches or pull requests

1 participant