Get rid of port to node assumptions and their modulo kludges

We had get_server_number for many years now, there's no reason
to continue using the node_id=port%100//10 thing.

Change-Id: I5357a095110e8e4889c0468c154611209c6e8c07
This commit is contained in:
Pete Zaitcev 2021-09-30 00:02:55 -05:00
parent 6ec20f9929
commit 85d0211279
4 changed files with 19 additions and 23 deletions

View File

@ -634,10 +634,9 @@ class ReplProbeTest(ProbeTest):
def get_container_db_files(self, container):
opart, onodes = self.container_ring.get_nodes(self.account, container)
onode = onodes[0]
db_files = []
for onode in onodes:
node_id = (onode['port'] % 100) // 10
node_id = self.config_number(onode)
device = onode['device']
hash_str = hash_path(self.account, container)
server_conf = readconf(self.configs['container-server'][node_id])

View File

@ -63,7 +63,7 @@ class TestObjectFailures(ReplProbeTest):
opart, onodes = self.object_ring.get_nodes(
self.account, container, obj)
onode = onodes[0]
node_id = (onode['port'] % 100) // 10
node_id = self.config_number(onode)
device = onode['device']
hash_str = hash_path(self.account, container, obj)
obj_server_conf = readconf(self.configs['object-server'][node_id])

View File

@ -30,8 +30,9 @@ from swift.common import direct_client
from swift.common.exceptions import ClientException
from swift.common.manager import Manager
from swift.common.utils import md5
from test.probe.common import (kill_server, start_server, ReplProbeTest,
ECProbeTest, Body)
from test.probe.common import (
Body, get_server_number, kill_server, start_server,
ReplProbeTest, ECProbeTest)
class TestObjectHandoff(ReplProbeTest):
@ -135,17 +136,14 @@ class TestObjectHandoff(ReplProbeTest):
# Run object replication, ensuring we run the handoff node last so it
# will remove its extra handoff partition
for node in onodes:
try:
port_num = node['replication_port']
except KeyError:
port_num = node['port']
node_id = (port_num % 100) // 10
_, node_id = get_server_number(
(node['ip'], node.get('replication_port', node['port'])),
self.ipport2server)
Manager(['object-replicator']).once(number=node_id)
try:
another_port_num = another_onode['replication_port']
except KeyError:
another_port_num = another_onode['port']
another_num = (another_port_num % 100) // 10
another_port_num = another_onode.get(
'replication_port', another_onode['port'])
_, another_num = get_server_number(
(another_onode['ip'], another_port_num), self.ipport2server)
Manager(['object-replicator']).once(number=another_num)
# Assert the first container/obj primary server now has container/obj
@ -227,13 +225,12 @@ class TestObjectHandoff(ReplProbeTest):
# Run object replication, ensuring we run the handoff node last so it
# will remove its extra handoff partition
for node in onodes:
try:
port_num = node['replication_port']
except KeyError:
port_num = node['port']
node_id = (port_num % 100) // 10
_, node_id = get_server_number(
(node['ip'], node.get('replication_port', node['port'])),
self.ipport2server)
Manager(['object-replicator']).once(number=node_id)
another_node_id = (another_port_num % 100) // 10
_, another_node_id = get_server_number(
(another_onode['ip'], another_port_num), self.ipport2server)
Manager(['object-replicator']).once(number=another_node_id)
# Assert primary node no longer has container/obj

View File

@ -86,7 +86,7 @@ class TestReconstructorRevert(ECProbeTest):
# fire up reconstructor on handoff nodes only
for hnode in hnodes:
hnode_id = (hnode['port'] % 100) // 10
hnode_id = self.config_number(hnode)
self.reconstructor.once(number=hnode_id)
# first three primaries have data again
@ -398,7 +398,7 @@ class TestReconstructorRevert(ECProbeTest):
# fire up reconstructor on handoff node only; commit_window is
# set to zero to ensure the nondurable handoff frag is purged
hnode_id = (hnodes[0]['port'] % 100) // 10
hnode_id = self.config_number(hnodes[0])
self.run_custom_daemon(
ObjectReconstructor, 'object-reconstructor', hnode_id,
{'commit_window': '0'})