mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-17 14:58:14 +00:00
reconfigure() only needs to restart the node if something changed
This commit is contained in:
@ -87,7 +87,7 @@ async def test_chk_capability(reactor, request, alice, params_idx, convergence_i
|
|||||||
data = OBJECT_DATA[data_idx]
|
data = OBJECT_DATA[data_idx]
|
||||||
|
|
||||||
# rewrite alice's config to match params and convergence
|
# rewrite alice's config to match params and convergence
|
||||||
await reconfigure(reactor, request, alice, params, convergence)
|
await reconfigure(reactor, request, alice, (1,) + params, convergence)
|
||||||
|
|
||||||
# upload data as a CHK
|
# upload data as a CHK
|
||||||
actual = upload(alice, "chk", data)
|
actual = upload(alice, "chk", data)
|
||||||
|
@ -651,31 +651,50 @@ def insert(item: tuple[α, β], d: dict[α, β]) -> dict[α, β]:
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
async def reconfigure(reactor, request, node: TahoeProcess, params: tuple[int, int], convergence: bytes) -> None:
|
async def reconfigure(reactor, request, node: TahoeProcess, params: tuple[int, int, int], convergence: bytes) -> None:
|
||||||
"""
|
"""
|
||||||
Reconfigure a Tahoe-LAFS node with different ZFEC parameters and
|
Reconfigure a Tahoe-LAFS node with different ZFEC parameters and
|
||||||
convergence secret.
|
convergence secret.
|
||||||
|
|
||||||
|
If the current configuration is different from the specified
|
||||||
|
configuration, the node will be restarted so it takes effect.
|
||||||
|
|
||||||
:param reactor: A reactor to use to restart the process.
|
:param reactor: A reactor to use to restart the process.
|
||||||
:param request: The pytest request object to use to arrange process
|
:param request: The pytest request object to use to arrange process
|
||||||
cleanup.
|
cleanup.
|
||||||
:param node: The Tahoe-LAFS node to reconfigure.
|
:param node: The Tahoe-LAFS node to reconfigure.
|
||||||
:param params: The ``needed`` and ``total`` ZFEC encoding parameters.
|
:param params: The ``happy``, ``needed``, and ``total`` ZFEC encoding
|
||||||
|
parameters.
|
||||||
:param convergence: The convergence secret.
|
:param convergence: The convergence secret.
|
||||||
|
|
||||||
:return: ``None`` after the node configuration has been rewritten, the
|
:return: ``None`` after the node configuration has been rewritten, the
|
||||||
node has been restarted, and the node is ready to provide service.
|
node has been restarted, and the node is ready to provide service.
|
||||||
"""
|
"""
|
||||||
needed, total = params
|
happy, needed, total = params
|
||||||
config = node.get_config()
|
config = node.get_config()
|
||||||
config.set_config("client", "shares.happy", str(1))
|
|
||||||
|
changed = False
|
||||||
|
cur_happy = int(config.get_config("client", "shares.happy"))
|
||||||
|
cur_needed = int(config.get_config("client", "shares.needed"))
|
||||||
|
cur_total = int(config.get_config("client", "shares.total"))
|
||||||
|
|
||||||
|
if (happy, needed, total) != (cur_happy, cur_needed, cur_total):
|
||||||
|
changed = True
|
||||||
|
config.set_config("client", "shares.happy", str(happy))
|
||||||
config.set_config("client", "shares.needed", str(needed))
|
config.set_config("client", "shares.needed", str(needed))
|
||||||
config.set_config("client", "shares.total", str(total))
|
config.set_config("client", "shares.total", str(total))
|
||||||
|
|
||||||
|
cur_convergence = config.get_private_config("convergence").encode("ascii")
|
||||||
|
if base32.a2b(cur_convergence) != convergence:
|
||||||
|
changed = True
|
||||||
config.write_private_config("convergence", base32.b2a(convergence))
|
config.write_private_config("convergence", base32.b2a(convergence))
|
||||||
|
|
||||||
|
if changed:
|
||||||
# restart the node
|
# restart the node
|
||||||
print(f"Restarting {node.node_dir} for ZFEC reconfiguration")
|
print(f"Restarting {node.node_dir} for ZFEC reconfiguration")
|
||||||
await node.restart_async(reactor, request)
|
await node.restart_async(reactor, request)
|
||||||
print("Restarted. Waiting for ready state.")
|
print("Restarted. Waiting for ready state.")
|
||||||
await_client_ready(node)
|
await_client_ready(node)
|
||||||
print("Ready.")
|
print("Ready.")
|
||||||
|
else:
|
||||||
|
print("Config unchanged, not restarting.")
|
||||||
|
Reference in New Issue
Block a user