robjuz / helm-charts

https://robjuz.github.io/helm-charts/index.yaml
34 stars 30 forks source link

[nominatim][feature] Support import continue in init job #44

Open dekzz opened 1 year ago

dekzz commented 1 year ago

Hello @robjuz, thanks for the chart!

Here is an attempt to support import continue option in init job, which might help in some cases when nominatim import fails but can be re-run without repeating all steps from scratch (i.e. osm data is imported but indexing fails for some reason). Motivation for this is my own case of larger dataset (europe) import on low-end infra which took like 5 days and failed on wikimedia import.

Option continue is not really documented (or at least I didn't mange to find it) except for this section. But I've managed to dig out something from source code.

robjuz commented 1 year ago

Hi.

Thx for the PR.

Could you explain me how it use it?

When I remember correctly, the import job gets restarted of error. When do you set the Continue variable?

dekzz commented 1 year ago

Ah, I didn't see the restart policy. The idea was to set continue config property and re-run helm upgrade in case of failure. State/step tracking of nominatim import execution seems a bit complicated to achieve, which is a prerequisite to implement automated continuation.

Also, maybe it makes sense to actually disable restart because only init containers benefit from it, since as soon as the database is created each restart would just get stuck at first command, which is db creation, resulting in pod restart loop (unless you manully drop the nominatim db). This can be detected by checking logs:

Using project directory: /nominatim
Creating database
error createdb: error: database creation failed: ERROR:  database "nominatim" already exists
FATAL Creating new database failed.
Using project directory: /nominatim
Creating database
error createdb: error: database creation failed: ERROR:  database "nominatim" already exists
FATAL Creating new database failed.
Using project directory: /nominatim
Creating database
error createdb: error: database creation failed: ERROR:  database "nominatim" already exists
FATAL Creating new database failed.
dekzz commented 1 year ago

@robjuz any thoughts on this?

robjuz commented 1 year ago

Sorry, was on holidays. I will take a look on this tomorrow

dbt-lucka commented 1 year ago

This is a useful feature for the helm chart. I am running my Germany import since 12 hours now and it turns out 30 Gig of memory is still not enough and crashed in one of the last steps.

I think your ampersands (??) in the markdown is broken though: image

dekzz commented 1 year ago

Thanks for noticing and pointing that out, fixed it.

robjuz commented 1 year ago

@dekzz I think I have an idea.

When I was working on the chart in the first place, I noticed that the redeployment of the chart will not not start the import job.

In the meantime I was working on another chart with a database migration. adding a helm hook annotation to the job metadata will start it on every upgrade:

apiVersion: batch/v1
kind: Job
metadata:
  name: {{ include "nominatim.fullname" . }}-init
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
  annotations:
    "helm.sh/hook": post-install,post-upgrade

Now we can set the restartPolicy to Never and let the user decide what to do

dekzz commented 1 year ago

Hey @robjuz, sorry for late reply.

I've added the hook and disabled restart and I think everything that we discussed is now covered.