Skip to content
Snippets Groups Projects
Commit 126e90c7 authored by Kurdakov Alexander's avatar Kurdakov Alexander Committed by Alexander Kurdakov
Browse files

fix: bug in join rpc

Tier of replicaset if exists must match with tier from arguments of rpc.
parent b3051f51
No related branches found
No related tags found
1 merge request!1290fix: bug in join rpc
Pipeline #50987 passed with warnings
......@@ -201,6 +201,12 @@ pub fn build_instance(
None => choose_replicaset_id(failure_domain, storage, &tier)?,
};
if let Some(replicaset) = storage.replicasets.get(&replicaset_id)? {
if replicaset.tier != tier.name {
return Err(Error::other(format!("tier mismatch: instance {instance_id} is from tier: '{}', but replicaset {replicaset_id} is from tier: '{}'", tier.name, replicaset.tier)));
}
}
let instance = Instance::new(
Some(raft_id),
Some(instance_id),
......
......@@ -533,3 +533,32 @@ def test_join_with_duplicate_instance_id(cluster: Cluster):
except ProcessDead:
assert lc.matched
assert sole_survivor
def test_tier_mismatch_while_joining_by_the_same_replicaset_id(cluster: Cluster):
cluster.set_config_file(
yaml="""
cluster:
cluster_id: test
tier:
default:
router:
"""
)
_ = cluster.add_instance(replicaset_id="r1")
_ = cluster.add_instance(replicaset_id="r2")
instance = cluster.add_instance(
replicaset_id="r2", tier="router", wait_online=False
)
msg = "tier mismatch: instance i3 is from tier: 'router', \
but replicaset r2 is from tier: 'default'"
lc = log_crawler(instance, msg)
with pytest.raises(
ProcessDead,
):
instance.start()
instance.wait_online()
lc.wait_matched()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment