Skip to content

Commit 19750dc

Browse files
authored
Clarified pgstac initial database permissions. (#240)
1 parent 327b911 commit 19750dc

File tree

4 files changed

+47
-51
lines changed

4 files changed

+47
-51
lines changed

.github/workflows/helm-tests.yml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -91,59 +91,59 @@ jobs:
9191
9292
exit $?
9393
94-
- name: debug pgstac-eoapiuser-permissions-upgrade job failure
94+
- name: debug pgstac-eoapi-superuser-init-db job failure
9595
if: steps.helm-render-install-eoapi-templates.outcome == 'failure'
9696
continue-on-error: true
9797
run: |
98-
echo "Extracting pgstac-eoapiuser-permissions-upgrade job info and logs for debugging..."
99-
98+
echo "Extracting pgstac-eoapi-superuser-init-db job info and logs for debugging..."
99+
100100
# Get job details
101-
echo "===== pgstac-eoapiuser-permissions-upgrade Job Details ====="
102-
kubectl get job pgstac-eoapiuser-permissions-upgrade -o yaml || echo "Could not get job details"
103-
101+
echo "===== pgstac-eoapi-superuser-init-db Job Details ====="
102+
kubectl get job pgstac-eoapi-superuser-init-db -o yaml || echo "Could not get job details"
103+
104104
# Get pod details
105105
echo "===== Pod Details ====="
106-
kubectl get pods --selector=app=pgstac-eoapiuser-permissions-upgrade -o wide || echo "Could not find pods"
107-
106+
kubectl get pods --selector=app=pgstac-eoapi-superuser-init-db -o wide || echo "Could not find pods"
107+
108108
# Extract logs from pods
109109
echo "===== Pod Logs ====="
110-
PODS=$(kubectl get pods --selector=app=pgstac-eoapiuser-permissions-upgrade -o jsonpath='{.items[*].metadata.name}' 2>/dev/null)
110+
PODS=$(kubectl get pods --selector=app=pgstac-eoapi-superuser-init-db -o jsonpath='{.items[*].metadata.name}' 2>/dev/null)
111111
if [ -n "$PODS" ]; then
112112
for POD in $PODS; do
113113
echo "--- Logs from pod $POD ---"
114114
kubectl logs $POD --previous || true # Get logs from previous container if it exists
115115
kubectl logs $POD || echo "Could not get logs from pod $POD"
116116
done
117117
else
118-
echo "No pods found for pgstac-eoapiuser-permissions-upgrade job"
118+
echo "No pods found for pgstac-eoapi-superuser-init-db job"
119119
fi
120-
120+
121121
# Get pod descriptions for more details
122122
echo "===== Pod Descriptions ====="
123-
kubectl describe pods --selector=app=pgstac-eoapiuser-permissions-upgrade || echo "Could not describe pods"
124-
123+
kubectl describe pods --selector=app=pgstac-eoapi-superuser-init-db || echo "Could not describe pods"
124+
125125
# Check the configmap contents
126126
echo "===== initdb ConfigMap Contents ====="
127127
kubectl get configmap initdb -o yaml || echo "Could not get initdb configmap"
128-
128+
129129
# Check for any related events
130130
echo "===== Related Kubernetes Events ====="
131-
kubectl get events | grep -E "pgstac-eoapiuser-permissions-upgrade|initdb" || echo "No relevant events found"
131+
kubectl get events | grep -E "pgstac-eoapi-superuser-init-db|initdb" || echo "No relevant events found"
132132
133133
- name: debug pgstac-migrate job failure
134134
if: steps.helm-render-install-eoapi-templates.outcome == 'failure'
135135
continue-on-error: true
136136
run: |
137137
echo "Extracting pgstac-migrate job info and logs for debugging..."
138-
138+
139139
# Get job details
140140
echo "===== pgstac-migrate Job Details ====="
141141
kubectl get job pgstac-migrate -o yaml || echo "Could not get pgstac-migrate job details"
142-
142+
143143
# Get pod details
144144
echo "===== pgstac-migrate Pod Details ====="
145145
kubectl get pods -l app=pgstac-migrate --all-namespaces || echo "Could not find pgstac-migrate pods"
146-
146+
147147
# Extract logs from pgstac-migrate pod(s)
148148
echo "===== pgstac-migrate Pod Logs ====="
149149
echo "Looking for completed pods from pgstac-migrate job..."
@@ -157,14 +157,14 @@ jobs:
157157
else
158158
echo "No completed pods found for pgstac-migrate job"
159159
fi
160-
160+
161161
# Get details about the database pods/services
162162
echo "===== Database Pod/Service Details ====="
163163
# Find database service
164164
kubectl get svc | grep "db" || echo "Could not find database services"
165165
# Find database pods
166166
kubectl get pods | grep "db-" || echo "Could not find database pods"
167-
167+
168168
# Check for any events related to the job or pods
169169
echo "===== Related Kubernetes Events ====="
170170
kubectl get events | grep -E "pgstac|db" || echo "No relevant events found"
@@ -195,31 +195,31 @@ jobs:
195195
if: steps.watchservices.outcome == 'failure'
196196
run: |
197197
echo "The watchservices step failed or timed out. Extracting pod logs for debugging..."
198-
198+
199199
# Get and display all pods status
200200
echo "===== Pod Status ====="
201201
kubectl get pods
202-
202+
203203
# Extract logs from raster pod init container (wait-for-pgstacbootstrap)
204204
echo "===== Raster Pod Init Container Logs (wait-for-pgstacbootstrap) ====="
205205
kubectl get pod | grep "^raster-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} -c wait-for-pgstacbootstrap --tail=100 || echo "Could not get raster init container logs"
206-
206+
207207
# Extract logs from raster pod main container
208208
echo "===== Raster Pod Main Container Logs ====="
209209
kubectl get pod | grep "^raster-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get raster main container logs"
210-
210+
211211
# Extract logs from vector pod
212212
echo "===== Vector Pod Logs ====="
213213
kubectl get pod | grep "^vector-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get vector logs"
214-
214+
215215
# Extract logs from stac pod
216216
echo "===== STAC Pod Logs ====="
217217
kubectl get pod | grep "^stac-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get STAC logs"
218-
218+
219219
# Check if pods are in pending state or have issues
220220
echo "===== Pod Descriptions for Troubleshooting ====="
221221
kubectl get pod | grep "$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl describe pod/{} || echo "Could not describe pods"
222-
222+
223223
# force GH action to show failed result
224224
exit 128
225225
@@ -263,31 +263,31 @@ jobs:
263263
if: steps.testrunner.outcome == 'failure'
264264
run: |
265265
echo "The tests failed. Extracting pod logs for debugging..."
266-
266+
267267
# Get and display all pods status
268268
echo "===== Pod Status ====="
269269
kubectl get pods
270-
270+
271271
# Extract logs from raster pod init container (wait-for-pgstacbootstrap)
272272
echo "===== Raster Pod Init Container Logs (wait-for-pgstacbootstrap) ====="
273273
kubectl get pod | grep "^raster-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} -c wait-for-pgstacbootstrap --tail=100 || echo "Could not get raster init container logs"
274-
274+
275275
# Extract logs from raster pod main container
276276
echo "===== Raster Pod Main Container Logs ====="
277277
kubectl get pod | grep "^raster-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get raster main container logs"
278-
278+
279279
# Extract logs from vector pod
280280
echo "===== Vector Pod Logs ====="
281281
kubectl get pod | grep "^vector-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get vector logs"
282-
282+
283283
# Extract logs from stac pod
284284
echo "===== STAC Pod Logs ====="
285285
kubectl get pod | grep "^stac-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get STAC logs"
286-
286+
287287
# Check if pods are in pending state or have issues
288288
echo "===== Pod Descriptions for Troubleshooting ====="
289289
kubectl get pod | grep "$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl describe pod/{} || echo "Could not describe pods"
290-
290+
291291
# force GH action to show failed result
292292
exit 128
293293

docs/upgrade.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ helm list -n eoapi
9696
kubectl get pods -n eoapi
9797
9898
# For subchart users, check the upgrade job status:
99-
kubectl get jobs -n eoapi | grep eoapiuser-permissions-upgrade
99+
kubectl get jobs -n eoapi | grep eoapi-superuser-init-db
100100
```
101101

102102
### Troubleshooting
@@ -105,7 +105,7 @@ If you encounter issues during the upgrade:
105105

106106
1. For subchart users, check the upgrade job logs:
107107
```bash
108-
kubectl logs -n eoapi -l app=pgstac-eoapiuser-permissions-upgrade
108+
kubectl logs -n eoapi -l app=pgstac-eoapi-superuser-init-db
109109
```
110110

111111
2. Verify database permissions:

helm-chart/eoapi/templates/pgstacbootstrap/eoapiuser-permissions-upgrade.yaml renamed to helm-chart/eoapi/templates/pgstacbootstrap/eoap-superuser-initdb.yaml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
{{- if and .Values.postgrescluster.enabled .Values.pgstacBootstrap.enabled }}
22
---
3-
# This job is part of the upgrade process from pre-0.7.0 versions.
4-
# Prior to 0.7.0, database schema updates were run with superuser privileges.
5-
# This job ensures proper permissions are granted to the eoapi user during upgrade.
6-
# TODO: Remove with the next mayor verson and add to documentation that one needs to
7-
# through 0.7.x when upgrading.
3+
# The eoapi database user runs normally pgstac migrate.
4+
# But before some initial grants need to be given with a super user.
5+
# https://stac-utils.github.io/pgstac/pypgstac/#option-2-create-user-with-initial-grants
86
apiVersion: batch/v1
97
kind: Job
108
metadata:
11-
name: pgstac-eoapiuser-permissions-upgrade
9+
name: pgstac-eoapi-superuser-init-db
1210
labels:
13-
app: pgstac-eoapiuser-permissions-upgrade
11+
app: pgstac-eoapi-superuser-init-db
1412
annotations:
15-
helm.sh/hook: "post-upgrade"
13+
helm.sh/hook: "post-install,post-upgrade"
1614
helm.sh/hook-weight: "-7"
1715
helm.sh/hook-delete-policy: "before-hook-creation"
1816
spec:
1917
template:
2018
metadata:
2119
labels:
22-
app: pgstac-eoapiuser-permissions-upgrade
20+
app: pgstac-eoapi-superuser-init-db
2321
spec:
2422
restartPolicy: Never
2523
containers:
@@ -33,11 +31,9 @@ spec:
3331
# Exit immediately if a command exits with a non-zero status
3432
set -e
3533
36-
# Run permission setup with superuser
37-
echo "Applying superuser permissions for upgrade from version {{ .Values.previousVersion }}..."
34+
# Run the initial setup with superuser
3835
PGUSER=postgres psql -f /opt/sql/initdb.sql
3936
40-
echo "Permissions upgrade complete"
4137
resources:
4238
{{- toYaml .Values.pgstacBootstrap.settings.resources | nindent 12 }}
4339
volumeMounts:

helm-chart/eoapi/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ comment_db: >
6969
postgresql:
7070
# Management type: "postgrescluster" (default), "external-plaintext", or "external-secret"
7171
type: "postgrescluster"
72-
72+
7373
# Configuration for external PostgreSQL (used when type is "external-plaintext" or "external-secret")
7474
external:
7575
# Connection information
7676
host: ""
7777
port: "5432"
7878
database: "eoapi"
79-
79+
8080
# Credentials configuration (used when type is "external-plaintext")
8181
credentials:
8282
username: ""
8383
password: ""
84-
84+
8585
# Secret reference (used when type is "external-secret")
8686
existingSecret:
8787
name: ""

0 commit comments

Comments
 (0)