aboutsummaryrefslogtreecommitdiff
path: root/scenarios/fragments/garage.py
diff options
context:
space:
mode:
Diffstat (limited to 'scenarios/fragments/garage.py')
-rw-r--r--scenarios/fragments/garage.py35
1 files changed, 27 insertions, 8 deletions
diff --git a/scenarios/fragments/garage.py b/scenarios/fragments/garage.py
index 84ca90a..b291321 100644
--- a/scenarios/fragments/garage.py
+++ b/scenarios/fragments/garage.py
@@ -38,7 +38,7 @@ if 'HOST' in env:
config = storage_path / "garage.toml"
env['GARAGE_CONFIG_FILE'] = str(config)
-def deploy_coord():
+def deploy_coord(gw=None):
destroy()
shared.log("start daemon")
shared.exec(f"{version['path']} --version")
@@ -46,7 +46,7 @@ def deploy_coord():
shared.log("discover nodes")
connect()
shared.log("build layout")
- create_layout()
+ create_layout(gw=gw)
shared.log("create key")
create_key()
shared.log("ready")
@@ -136,26 +136,45 @@ def cluster_info():
def connect():
cinf = cluster_info()
shared.log("start connections...")
- ret = nodes.add_node([n['node_addr'] for n in cinf])
- for st in ret:
- if not st.success:
- raise Exception("Node connect failed", ret)
+ while True:
+ try:
+ ret = nodes.add_node([n['node_addr'] for n in cinf], _request_timeout=3)
+ except:
+ shared.log("not ready, retry in 1sec")
+ time.sleep(1)
+ continue
+
+ for st in ret:
+ if not st.success:
+ continue
+ #raise Exception("Node connect failed", ret)
+ break
+
shared.log("all nodes connected")
-def create_layout():
+def create_layout(gw=None):
+ if gw is None:
+ gw = []
+
v = layout.get_layout().version
cinf = cluster_info()
nlay = dict()
for n in cinf:
+ capa = 1
+ if n['host'] in gw:
+ capa = None
+
nlay[n['node_id']] = NodeClusterInfo(
zone = n['zone'],
- capacity = 1,
+ capacity = capa,
tags = [ n['host'] ],
)
layout.add_layout(nlay)
layout.apply_layout(LayoutVersion(version=v+1))
+ shared.log(layout.get_layout())
+
def create_key():
global key
kinfo = shared.fn_retry(lambda: keys.add_key(AddKeyRequest(name="mknet")))