Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Expose PgSTAC configuration options in Helm chart values (`pgstacBootstrap.settings.pgstacSettings`). These are being dynamically applied via templated SQL during bootstrap.
- Added `queue_timeout`, `use_queue`, and `update_collection_extent` settings for database performance tuning
- Made existing context settings configurable (`context`, `context_estimated_count`, `context_estimated_cost`, `context_stats_ttl`)
- Automatic queue processor CronJob created when `use_queue` is "true" (configurable schedule via `queueProcessor.schedule`)
- Automatic extent updater CronJob created when `update_collection_extent` is "false" (configurable schedule via `extentUpdater.schedule`)

## [0.7.13] - 2025-11-04

### Added
Expand Down
12 changes: 0 additions & 12 deletions charts/eoapi/initdb-data/settings/pgstac-settings.sql

This file was deleted.

26 changes: 26 additions & 0 deletions charts/eoapi/initdb-data/settings/pgstac-settings.sql.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- Apply pgstac settings
-- These settings are configured via Helm values at pgstacBootstrap.settings.pgstacSettings

-- Queue settings
DELETE FROM pgstac.pgstac_settings WHERE name = 'queue_timeout';
INSERT INTO pgstac.pgstac_settings (name, value) VALUES ('queue_timeout', '{{ .Values.pgstacBootstrap.settings.pgstacSettings.queue_timeout }}');

DELETE FROM pgstac.pgstac_settings WHERE name = 'use_queue';
INSERT INTO pgstac.pgstac_settings (name, value) VALUES ('use_queue', '{{ .Values.pgstacBootstrap.settings.pgstacSettings.use_queue }}');

-- Collection extent management
DELETE FROM pgstac.pgstac_settings WHERE name = 'update_collection_extent';
INSERT INTO pgstac.pgstac_settings (name, value) VALUES ('update_collection_extent', '{{ .Values.pgstacBootstrap.settings.pgstacSettings.update_collection_extent }}');

-- Context settings
DELETE FROM pgstac.pgstac_settings WHERE name = 'context';
INSERT INTO pgstac.pgstac_settings (name, value) VALUES ('context', '{{ .Values.pgstacBootstrap.settings.pgstacSettings.context }}');

DELETE FROM pgstac.pgstac_settings WHERE name = 'context_estimated_count';
INSERT INTO pgstac.pgstac_settings (name, value) VALUES ('context_estimated_count', '{{ .Values.pgstacBootstrap.settings.pgstacSettings.context_estimated_count }}');

DELETE FROM pgstac.pgstac_settings WHERE name = 'context_estimated_cost';
INSERT INTO pgstac.pgstac_settings (name, value) VALUES ('context_estimated_cost', '{{ .Values.pgstacBootstrap.settings.pgstacSettings.context_estimated_cost }}');

DELETE FROM pgstac.pgstac_settings WHERE name = 'context_stats_ttl';
INSERT INTO pgstac.pgstac_settings (name, value) VALUES ('context_stats_ttl', '{{ .Values.pgstacBootstrap.settings.pgstacSettings.context_stats_ttl }}');
2 changes: 1 addition & 1 deletion charts/eoapi/templates/pgstacbootstrap/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ metadata:
helm.sh/hook-delete-policy: "before-hook-creation,hook-succeeded"
data:
pgstac-settings.sql: |
{{ $.Files.Get "initdb-data/settings/pgstac-settings.sql" | nindent 4 }}
{{- tpl ($.Files.Get "initdb-data/settings/pgstac-settings.sql.tpl") $ | nindent 4 }}
{{- if (index .Values "eoapi-notifier").enabled }}
{{ $.Files.Get "initdb-data/settings/pgstac-notification-triggers.sql" | nindent 4 }}
{{- end }}
Expand Down
46 changes: 46 additions & 0 deletions charts/eoapi/templates/pgstacbootstrap/extent-updater.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{- if .Values.pgstacBootstrap.enabled }}
{{- if .Values.pgstacBootstrap.settings.pgstacSettings }}
{{- if eq (default "false" .Values.pgstacBootstrap.settings.pgstacSettings.update_collection_extent) "false" }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ .Release.Name }}-pgstac-extent-updater
labels:
{{- include "eoapi.labels" . | nindent 4 }}
app.kubernetes.io/component: pgstac-extents
spec:
schedule: {{ .Values.pgstacBootstrap.settings.extentUpdater.schedule | quote }}
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
metadata:
labels:
{{- include "eoapi.labels" . | nindent 12 }}
app.kubernetes.io/component: pgstac-extents
spec:
restartPolicy: OnFailure
containers:
- name: extent-updater
image: {{ .Values.pgstacBootstrap.image.name }}:{{ .Values.pgstacBootstrap.image.tag }}
imagePullPolicy: IfNotPresent
command:
- "/bin/sh"
- "-c"
- |
psql -c "{{ .Values.pgstacBootstrap.settings.extentUpdater.command }}"
env:
{{- include "eoapi.postgresqlEnv" . | nindent 14 }}
resources:
limits:
cpu: "512m"
memory: "1024Mi"
requests:
cpu: "256m"
memory: "512Mi"
{{- end }}
{{- end }}
{{- end }}
46 changes: 46 additions & 0 deletions charts/eoapi/templates/pgstacbootstrap/queue-processor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{- if .Values.pgstacBootstrap.enabled }}
{{- if .Values.pgstacBootstrap.settings.pgstacSettings }}
{{- if eq (.Values.pgstacBootstrap.settings.pgstacSettings.use_queue | default "true") "true" }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ .Release.Name }}-pgstac-queue-processor
labels:
{{- include "eoapi.labels" . | nindent 4 }}
app.kubernetes.io/component: pgstac-queue
spec:
schedule: {{ .Values.pgstacBootstrap.settings.queueProcessor.schedule | quote }}
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
metadata:
labels:
{{- include "eoapi.labels" . | nindent 12 }}
app.kubernetes.io/component: pgstac-queue
spec:
restartPolicy: OnFailure
containers:
- name: queue-processor
image: {{ .Values.pgstacBootstrap.image.name }}:{{ .Values.pgstacBootstrap.image.tag }}
imagePullPolicy: IfNotPresent
command:
- "/bin/sh"
- "-c"
- |
psql -c "{{ .Values.pgstacBootstrap.settings.queueProcessor.command }}"
env:
{{- include "eoapi.postgresqlEnv" . | nindent 14 }}
resources:
limits:
cpu: "256m"
memory: "512Mi"
requests:
cpu: "128m"
memory: "256Mi"
{{- end }}
{{- end }}
{{- end }}
216 changes: 216 additions & 0 deletions charts/eoapi/tests/pgstac_config_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
suite: pgstac configuration tests
templates:
- templates/pgstacbootstrap/configmap.yaml
- templates/pgstacbootstrap/queue-processor.yaml
- templates/pgstacbootstrap/extent-updater.yaml
tests:
# PgSTAC Settings Tests
- it: should apply custom pgstac settings
set:
pgstacBootstrap:
enabled: true
settings:
pgstacSettings:
queue_timeout: "30 minutes"
use_queue: "false"
update_collection_extent: "true"
context: "on"
context_estimated_count: "50000"
template: templates/pgstacbootstrap/configmap.yaml
documentIndex: 0
asserts:
- matchRegex:
path: data["pgstac-settings.sql"]
pattern: "VALUES \\('queue_timeout', '30 minutes'\\)"
- matchRegex:
path: data["pgstac-settings.sql"]
pattern: "VALUES \\('use_queue', 'false'\\)"
- matchRegex:
path: data["pgstac-settings.sql"]
pattern: "VALUES \\('update_collection_extent', 'true'\\)"
- matchRegex:
path: data["pgstac-settings.sql"]
pattern: "VALUES \\('context_estimated_count', '50000'\\)"

- it: should use default pgstac settings
set:
pgstacBootstrap:
enabled: true
template: templates/pgstacbootstrap/configmap.yaml
documentIndex: 0
asserts:
- matchRegex:
path: data["pgstac-settings.sql"]
pattern: "VALUES \\('queue_timeout', '10 minutes'\\)"
- matchRegex:
path: data["pgstac-settings.sql"]
pattern: "VALUES \\('use_queue', 'true'\\)"
- matchRegex:
path: data["pgstac-settings.sql"]
pattern: "VALUES \\('update_collection_extent', 'false'\\)"

# Queue Processor Tests
- it: should create queue processor when use_queue is true
set:
pgstacBootstrap:
enabled: true
settings:
pgstacSettings:
use_queue: "true"
template: templates/pgstacbootstrap/queue-processor.yaml
asserts:
- hasDocuments:
count: 1
- isKind:
of: CronJob
- equal:
path: metadata.name
value: RELEASE-NAME-pgstac-queue-processor
- equal:
path: spec.schedule
value: "0 * * * *"

- it: should NOT create queue processor when use_queue is false
set:
pgstacBootstrap:
enabled: true
settings:
pgstacSettings:
use_queue: "false"
template: templates/pgstacbootstrap/queue-processor.yaml
asserts:
- hasDocuments:
count: 0

- it: should use custom queue processor schedule
set:
pgstacBootstrap:
enabled: true
settings:
pgstacSettings:
use_queue: "true"
queueProcessor:
schedule: "*/15 * * * *"
command: "SELECT custom_queue_function();"
template: templates/pgstacbootstrap/queue-processor.yaml
asserts:
- equal:
path: spec.schedule
value: "*/15 * * * *"
- matchRegex:
path: spec.jobTemplate.spec.template.spec.containers[0].command[2]
pattern: "SELECT custom_queue_function\\(\\);"

# Extent Updater Tests
- it: should create extent updater when update_collection_extent is false
set:
pgstacBootstrap:
enabled: true
settings:
pgstacSettings:
update_collection_extent: "false"
template: templates/pgstacbootstrap/extent-updater.yaml
asserts:
- hasDocuments:
count: 1
- isKind:
of: CronJob
- equal:
path: metadata.name
value: RELEASE-NAME-pgstac-extent-updater
- equal:
path: spec.schedule
value: "0 2 * * *"

- it: should NOT create extent updater when update_collection_extent is true
set:
pgstacBootstrap:
enabled: true
settings:
pgstacSettings:
update_collection_extent: "true"
template: templates/pgstacbootstrap/extent-updater.yaml
asserts:
- hasDocuments:
count: 0

- it: should use custom extent updater schedule
set:
pgstacBootstrap:
enabled: true
settings:
pgstacSettings:
update_collection_extent: "false"
extentUpdater:
schedule: "0 */6 * * *"
command: "SELECT custom_extent_function();"
template: templates/pgstacbootstrap/extent-updater.yaml
asserts:
- equal:
path: spec.schedule
value: "0 */6 * * *"
- matchRegex:
path: spec.jobTemplate.spec.template.spec.containers[0].command[2]
pattern: "SELECT custom_extent_function\\(\\);"

# Combined scenario tests
- it: should create both cronjobs with proper settings
set:
pgstacBootstrap:
enabled: true
settings:
pgstacSettings:
use_queue: "true"
update_collection_extent: "false"
templates:
- templates/pgstacbootstrap/queue-processor.yaml
- templates/pgstacbootstrap/extent-updater.yaml
asserts:
- hasDocuments:
count: 1
- isKind:
of: CronJob

- it: should not create any cronjobs when disabled
set:
pgstacBootstrap:
enabled: false
templates:
- templates/pgstacbootstrap/queue-processor.yaml
- templates/pgstacbootstrap/extent-updater.yaml
asserts:
- hasDocuments:
count: 0

# Resource limits tests
- it: should set correct resource limits for queue processor
set:
pgstacBootstrap:
enabled: true
settings:
pgstacSettings:
use_queue: "true"
template: templates/pgstacbootstrap/queue-processor.yaml
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].resources.limits.cpu
value: "256m"
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].resources.limits.memory
value: "512Mi"

- it: should set correct resource limits for extent updater
set:
pgstacBootstrap:
enabled: true
settings:
pgstacSettings:
update_collection_extent: "false"
template: templates/pgstacbootstrap/extent-updater.yaml
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].resources.limits.cpu
value: "512m"
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].resources.limits.memory
value: "1024Mi"
Loading