mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-05 20:42:54 +00:00
Ansible will soon write the node id to `identity.toml` in the work dir for new pageservers. On the pageserver side, we read the node id from the identity file if it is present and use that as the source of truth. If the identity file is missing, cannot be read, or does not deserialise, start-up is aborted. This PR also removes the `--init` mode and the `--config-override` flag from the `pageserver` binary. The neon_local is already not using these flags anymore. Ansible still uses them until the linked change is merged & deployed, so, this PR has to land simultaneously or after the Ansible change due to that. Related Ansible change: https://github.com/neondatabase/aws/pull/1322 Cplane change to remove config-override usages: https://github.com/neondatabase/cloud/pull/13417 Closes: https://github.com/neondatabase/neon/issues/7736 Overall plan: https://www.notion.so/neondatabase/Rollout-Plan-simplified-pageserver-initialization-f935ae02b225444e8a41130b7d34e4ea?pvs=4 Co-authored-by: Christian Schwarz <christian@neon.tech>
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=(
|
|
-sbf
|
|
-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}
|