Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions images/tiler-imposm/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,38 @@ function monitorImposmErrors() {
done
}

function importMissingLayers() {
# Layers added after the initial import have no table yet and "imposm run" fails on them.
local missing_layers
missing_layers=$(psql "$PG_CONNECTION" -At -c "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';" | python3 -c '
import glob, json, sys
existing = set(sys.stdin.read().split())
mapped = json.load(open("./config/imposm3.json"))["tables"]
layers = [p.split("/")[-1][:-5] for p in sorted(glob.glob("./config/layers/*.json"))
if any(t in mapped and "osm_" + t not in existing for t in json.load(open(p))["tables"])]
print(" ".join(layers))')

if [ -n "$missing_layers" ]; then
log_message "Importing missing layers: $missing_layers"
getData
if ! ./scripts/reimport_layer.sh $missing_layers; then
log_message "ERROR: Failed to import missing layers: $missing_layers"
exit 1
fi
touch "$WORKDIR/mviews_pending"
fi

# The marker survives a restart in the middle of create_mviews.sh, so the views get retried.
if [ -f "$WORKDIR/mviews_pending" ] && [ "$RECREATE_MVIEWS_ON_UPDATE" != "true" ]; then
./scripts/create_mviews.sh && rm -f "$WORKDIR/mviews_pending"
fi
}

function updateData() {
log_message "Starting database update process..."

importMissingLayers

# Step 0: Recreate materialized views if RECREATE_MVIEWS_ON_UPDATE is enabled
if [ "$RECREATE_MVIEWS_ON_UPDATE" = "true" ]; then
log_message "Recreating materialized views before update..."
Expand Down
4 changes: 2 additions & 2 deletions values.k3s.production.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ osm-seed:
mountPath: /var/lib/postgresql/data
subPath: postgresql-data
staticHostPath: true
localVolumeHostPath: /mnt/tiler-db-data-v6
localVolumeHostPath: /mnt/tiler-db-data-v7
resources:
enabled: false
postgresqlConfig:
Expand Down Expand Up @@ -160,7 +160,7 @@ osm-seed:
accessMode: ReadWriteOnce
mountPath: /mnt/data
staticHostPath: true
localVolumeHostPath: /mnt/tiler-imposm-data-v6
localVolumeHostPath: /mnt/tiler-imposm-data-v7
resources:
enabled: true
nodeSelector:
Expand Down
Loading