Skip to content

Commit

Permalink
Force drop of pr database
Browse files Browse the repository at this point in the history
  • Loading branch information
TimCsaky committed Oct 30, 2024
2 parents b684f7e + 51b3708 commit 921154d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/on-pr-closed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
CRUNCHY_PG_PRIMARY_POD_NAME=$(oc get pods -l postgres-operator.crunchydata.com/role=master -o json | jq -r '.items[0].metadata.name')
echo "${CRUNCHY_PG_PRIMARY_POD_NAME}"
oc exec "${CRUNCHY_PG_PRIMARY_POD_NAME}" -- psql -c "DROP DATABASE \"pr-${{ github.event.number }}\" --cascade"
oc exec "${CRUNCHY_PG_PRIMARY_POD_NAME}" -- psql -c "DROP DATABASE \"pr-${{ github.event.number }}\" WITH (FORCE) --cascade"
oc exec "${CRUNCHY_PG_PRIMARY_POD_NAME}" -- psql -c "DROP ROLE \"pr-${{ github.event.number }}\" --cascade"
echo 'database and role deleted'
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/on-pr-opened.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ jobs:
UPDATED_USERS=$(echo "${CURRENT_USERS}" | jq --argjson NEW_USER "${NEW_USER}" '. + [$NEW_USER]')
PATCH_JSON=$(jq -n --argjson users "${UPDATED_USERS}" '{"spec": {"users": $users}}')
# patch echo 'Make PR user owner of PR database'
CRUNCHY_PG_PRIMARY_POD_NAME=$(oc get pods -l postgres-operator.crunchydata.com/role=master -o json | jq -r '.items[0].metadata.name')
oc exec "${CRUNCHY_PG_PRIMARY_POD_NAME}" -- psql -c "ALTER DATABASE \"pr-${{ github.event.number }}\" OWNER TO \"pr-${{ github.event.number }}\""
# oc exec "${CRUNCHY_PG_PRIMARY_POD_NAME}" -- psql -c "ALTER SCHEMA public OWNER TO \"pr-${{ github.event.number }}\""
# oc exec "${CRUNCHY_PG_PRIMARY_POD_NAME}" -- psql -c "ALTER SCHEMA public OWNER TO \"pr-${{ github.event.number }}\""
oc patch PostgresCluster/postgres-master --type=merge -p "${PATCH_JSON}"
# wait for sometime as it takes time to create the user, query the secret and check if it is created, otherwise wait in a loop for 5 rounds
for i in {1..5}; do
Expand All @@ -84,6 +78,12 @@ jobs:
sleep 60
fi
done
# when secret is created in previous step, postgres should be ready
# patch echo 'Make PR user owner of PR database'
CRUNCHY_PG_PRIMARY_POD_NAME=$(oc get pods -l postgres-operator.crunchydata.com/role=master -o json | jq -r '.items[0].metadata.name')
oc exec "${CRUNCHY_PG_PRIMARY_POD_NAME}" -- psql -c "ALTER DATABASE \"pr-${{ github.event.number }}\" OWNER TO \"pr-${{ github.event.number }}\""
- name: Checkout
uses: actions/checkout@v4
- name: Deploy to Dev
Expand Down
1 change: 1 addition & 0 deletions app/src/controllers/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const controller = {
});
}

// Future task: give user MANAGE permission on existing sub-folder (bucket) instead (see above)
// Check for existing bucket collision
const bucketCollision = await bucketService.readUnique({
bucket: parentBucket.bucket,
Expand Down

0 comments on commit 921154d

Please sign in to comment.