mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-24 08:30:37 +00:00
storcon: make pageserver AZ id mandatory (#8856)
## Problem https://github.com/neondatabase/neon/pull/8852 introduced a new nullable column for the `nodes` table: `availability_zone_id` ## Summary of changes * Make neon local and the test suite always provide an az id * Make the az id field in the ps registration request mandatory * Migrate the column to non-nullable and adjust in memory state accordingly * Remove the code that was used to populate the az id for pre-existing nodes
This commit is contained in:
@@ -1264,7 +1264,7 @@ impl Service {
|
||||
123,
|
||||
"".to_string(),
|
||||
123,
|
||||
None,
|
||||
"test_az".to_string(),
|
||||
);
|
||||
|
||||
scheduler.node_upsert(&node);
|
||||
@@ -4825,15 +4825,8 @@ impl Service {
|
||||
)
|
||||
.await;
|
||||
|
||||
if register_req.availability_zone_id.is_none() {
|
||||
tracing::warn!(
|
||||
"Node {} registering without specific availability zone id",
|
||||
register_req.node_id
|
||||
);
|
||||
}
|
||||
|
||||
enum RegistrationStatus {
|
||||
Matched(Node),
|
||||
Matched,
|
||||
Mismatched,
|
||||
New,
|
||||
}
|
||||
@@ -4842,7 +4835,7 @@ impl Service {
|
||||
let locked = self.inner.read().unwrap();
|
||||
if let Some(node) = locked.nodes.get(®ister_req.node_id) {
|
||||
if node.registration_match(®ister_req) {
|
||||
RegistrationStatus::Matched(node.clone())
|
||||
RegistrationStatus::Matched
|
||||
} else {
|
||||
RegistrationStatus::Mismatched
|
||||
}
|
||||
@@ -4852,41 +4845,12 @@ impl Service {
|
||||
};
|
||||
|
||||
match registration_status {
|
||||
RegistrationStatus::Matched(node) => {
|
||||
RegistrationStatus::Matched => {
|
||||
tracing::info!(
|
||||
"Node {} re-registered with matching address",
|
||||
register_req.node_id
|
||||
);
|
||||
|
||||
if node.get_availability_zone_id().is_none() {
|
||||
if let Some(az_id) = register_req.availability_zone_id.clone() {
|
||||
tracing::info!("Extracting availability zone id from registration request for node {}: {}",
|
||||
register_req.node_id, az_id);
|
||||
|
||||
// Persist to the database and update in memory state. See comment below
|
||||
// on ordering.
|
||||
self.persistence
|
||||
.set_node_availability_zone_id(register_req.node_id, az_id)
|
||||
.await?;
|
||||
let node_with_az = Node::new(
|
||||
register_req.node_id,
|
||||
register_req.listen_http_addr,
|
||||
register_req.listen_http_port,
|
||||
register_req.listen_pg_addr,
|
||||
register_req.listen_pg_port,
|
||||
register_req.availability_zone_id,
|
||||
);
|
||||
|
||||
let mut locked = self.inner.write().unwrap();
|
||||
let mut new_nodes = (*locked.nodes).clone();
|
||||
|
||||
locked.scheduler.node_upsert(&node_with_az);
|
||||
new_nodes.insert(register_req.node_id, node_with_az);
|
||||
|
||||
locked.nodes = Arc::new(new_nodes);
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
RegistrationStatus::Mismatched => {
|
||||
|
||||
Reference in New Issue
Block a user