mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-04 12:02:55 +00:00
## Problem In https://github.com/neondatabase/neon/pull/5299, the new config-v1 tenant config file was added to hold the LocationConf type. We left the old config file in place for forward compat, and because running without generations (therefore without LocationConf) as still useful before the storage controller was ready for prime-time. Closes: https://github.com/neondatabase/neon/issues/5388 ## Summary of changes - Remove code for reading and writing the legacy config file - Remove Generation::Broken: it was unused. - Treat missing config file on disk as an error loading a tenant, rather than defaulting it. We can now remove LocationConf::default, and thereby guarantee that we never construct a tenant with a None generation. - Update some comments + add some assertions to clarify that Generation::None is only used in layer metadata, not in the state of a running tenant. - Update docker compose test to create tenants with a generation
56 lines
1.5 KiB
Bash
Executable File
56 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -eux
|
|
|
|
# Generate a random tenant or timeline ID
|
|
#
|
|
# Takes a variable name as argument. The result is stored in that variable.
|
|
generate_id() {
|
|
local -n resvar=$1
|
|
printf -v resvar '%08x%08x%08x%08x' $SRANDOM $SRANDOM $SRANDOM $SRANDOM
|
|
}
|
|
|
|
PG_VERSION=${PG_VERSION:-14}
|
|
|
|
SPEC_FILE_ORG=/var/db/postgres/specs/spec.json
|
|
SPEC_FILE=/tmp/spec.json
|
|
|
|
echo "Waiting pageserver become ready."
|
|
while ! nc -z pageserver 6400; do
|
|
sleep 1;
|
|
done
|
|
echo "Page server is ready."
|
|
|
|
echo "Create a tenant and timeline"
|
|
generate_id tenant_id
|
|
PARAMS=(
|
|
-X PUT
|
|
-H "Content-Type: application/json"
|
|
-d "{\"mode\": \"AttachedSingle\", \"generation\": 1, \"tenant_conf\": {}}"
|
|
"http://pageserver:9898/v1/tenant/${tenant_id}/location_config"
|
|
)
|
|
result=$(curl "${PARAMS[@]}")
|
|
echo $result | jq .
|
|
|
|
generate_id timeline_id
|
|
PARAMS=(
|
|
-sb
|
|
-X POST
|
|
-H "Content-Type: application/json"
|
|
-d "{\"new_timeline_id\": \"${timeline_id}\", \"pg_version\": ${PG_VERSION}}"
|
|
"http://pageserver:9898/v1/tenant/${tenant_id}/timeline/"
|
|
)
|
|
result=$(curl "${PARAMS[@]}")
|
|
echo $result | jq .
|
|
|
|
echo "Overwrite tenant id and timeline id in spec file"
|
|
sed "s/TENANT_ID/${tenant_id}/" ${SPEC_FILE_ORG} > ${SPEC_FILE}
|
|
sed -i "s/TIMELINE_ID/${timeline_id}/" ${SPEC_FILE}
|
|
|
|
cat ${SPEC_FILE}
|
|
|
|
echo "Start compute node"
|
|
/usr/local/bin/compute_ctl --pgdata /var/db/postgres/compute \
|
|
-C "postgresql://cloud_admin@localhost:55433/postgres" \
|
|
-b /usr/local/bin/postgres \
|
|
-S ${SPEC_FILE}
|