Skip to content

Commit 9aaa2c1

Browse files
authored
Use drives from config for formatting in ydbd_slice (ydb-platform#3729)
1 parent 00d677a commit 9aaa2c1

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

ydb/tools/ydbd_slice/handlers.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ def __str__(self):
2020
)
2121

2222

23-
def format_drivers(nodes):
24-
cmd = r"sudo find /dev/disk/ -path '*/by-partlabel/kikimr_*' " \
25-
r"-exec dd if=/dev/zero of={} bs=1M count=1 status=none \;"
26-
nodes.execute_async(cmd)
27-
28-
2923
class Slice:
3024
def __init__(self, components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider):
3125
self.slice_kikimr_path = '/Berkanavt/kikimr/bin/kikimr'
@@ -56,9 +50,30 @@ def _clear_logs(self):
5650
"sudo service rsyslog start;"
5751
self.nodes.execute_async(cmd)
5852

53+
def _get_all_drives(self):
54+
result = []
55+
for host in self.cluster_details.hosts:
56+
for drive in host.drives:
57+
result.append((host.hostname, drive.path))
58+
return result
59+
60+
def _format_drives(self):
61+
tasks = []
62+
for (host_name, drive_path) in self._get_all_drives():
63+
cmd = "dd if=/dev/zero of={} bs=1M count=1 status=none conv=notrunc".format(drive_path)
64+
tasks.extend(self.nodes.execute_async_ret(cmd, nodes=[host_name]))
65+
self.nodes._check_async_execution(tasks)
66+
67+
def _check_drives_exist(self):
68+
tasks = []
69+
for (host_name, drive_path) in self._get_all_drives():
70+
cmd = "echo 'Check existance of drive' && test -f {}".format(drive_path)
71+
tasks.extend(self.nodes.execute_async_ret(cmd, nodes=[host_name]))
72+
self.nodes._check_async_execution(tasks)
73+
5974
def slice_format(self):
6075
self.slice_stop()
61-
format_drivers(self.nodes)
76+
self._format_drives()
6277
self.slice_start()
6378

6479
def slice_clear(self):
@@ -69,7 +84,7 @@ def slice_clear(self):
6984
self._clear_slot(slot)
7085

7186
if 'kikimr' in self.components:
72-
format_drivers(self.nodes)
87+
self._format_drives()
7388

7489
def _invoke_scripts(self, dynamic_cfg_path, scripts):
7590
for script_name in scripts:
@@ -117,7 +132,8 @@ def slice_install(self):
117132
self._clear_logs()
118133

119134
if 'kikimr' in self.components:
120-
format_drivers(self.nodes)
135+
self._check_drives_exist()
136+
self._format_drives()
121137

122138
if 'bin' in self.components.get('kikimr', []):
123139
self._update_kikimr(self.nodes, self.configurator.kikimr_bin, self.configurator.kikimr_compressed_bin)

ydb/tools/ydbd_slice/kube/handlers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ def slice_nodeclaim_format(api_client, project_path, manifests):
231231
return
232232
node_list = nodes.Nodes(node_list)
233233
handlers.format_drivers(node_list)
234+
cmd = r"sudo find /dev/disk/ -path '*/by-partlabel/kikimr_*' " \
235+
r"-exec dd if=/dev/zero of={} bs=1M count=1 status=none \;"
236+
nodes.execute_async(cmd)
234237

235238

236239
def slice_nodeclaim_delete(api_client, project_path, manifests):

0 commit comments

Comments
 (0)