Start safekeeper node IDs with 0 and forbid 0 from registering (#11419)

Right now we start safekeeper node ids at 0. However, other code treats
0 as invalid (see #11407). We decided on latter. Therefore, make the
register python tests register safekeepers starting at node id 1 instead
of 0, and forbid safekeepers with id 0 from registering.

Context:
https://github.com/neondatabase/neon/pull/11407#discussion_r2024852328
This commit is contained in:
Arpad Müller
2025-04-02 20:36:50 +02:00
committed by GitHub
parent dd1299f337
commit e3d27b2f68
2 changed files with 8 additions and 0 deletions

View File

@@ -1416,6 +1416,12 @@ async fn handle_upsert_safekeeper(mut req: Request<Body>) -> Result<Response<Bod
)));
}
if id <= 0 {
return Err(ApiError::BadRequest(anyhow::anyhow!(
"id not allowed to be zero or negative: {id}"
)));
}
let req = match maybe_forward(req).await {
ForwardOutcome::Forwarded(res) => {
return res;

View File

@@ -1344,6 +1344,8 @@ class NeonEnv:
and self.storage_controller_config.get("timelines_onto_safekeepers") is True
):
for sk_id, sk in enumerate(self.safekeepers):
# 0 is an invalid safekeeper id
sk_id = sk_id + 1
body = {
"id": sk_id,
"created_at": "2023-10-25T09:11:25Z",