Skip to content

Commit

Permalink
Use drives from config for formatting in ydbd_slice (ydb-platform#3729)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximyurchuk authored Apr 15, 2024
1 parent 00d677a commit 9aaa2c1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
34 changes: 25 additions & 9 deletions ydb/tools/ydbd_slice/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ def __str__(self):
)


def format_drivers(nodes):
cmd = r"sudo find /dev/disk/ -path '*/by-partlabel/kikimr_*' " \
r"-exec dd if=/dev/zero of={} bs=1M count=1 status=none \;"
nodes.execute_async(cmd)


class Slice:
def __init__(self, components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider):
self.slice_kikimr_path = '/Berkanavt/kikimr/bin/kikimr'
Expand Down Expand Up @@ -56,9 +50,30 @@ def _clear_logs(self):
"sudo service rsyslog start;"
self.nodes.execute_async(cmd)

def _get_all_drives(self):
result = []
for host in self.cluster_details.hosts:
for drive in host.drives:
result.append((host.hostname, drive.path))
return result

def _format_drives(self):
tasks = []
for (host_name, drive_path) in self._get_all_drives():
cmd = "dd if=/dev/zero of={} bs=1M count=1 status=none conv=notrunc".format(drive_path)
tasks.extend(self.nodes.execute_async_ret(cmd, nodes=[host_name]))
self.nodes._check_async_execution(tasks)

def _check_drives_exist(self):
tasks = []
for (host_name, drive_path) in self._get_all_drives():
cmd = "echo 'Check existance of drive' && test -f {}".format(drive_path)
tasks.extend(self.nodes.execute_async_ret(cmd, nodes=[host_name]))
self.nodes._check_async_execution(tasks)

def slice_format(self):
self.slice_stop()
format_drivers(self.nodes)
self._format_drives()
self.slice_start()

def slice_clear(self):
Expand All @@ -69,7 +84,7 @@ def slice_clear(self):
self._clear_slot(slot)

if 'kikimr' in self.components:
format_drivers(self.nodes)
self._format_drives()

def _invoke_scripts(self, dynamic_cfg_path, scripts):
for script_name in scripts:
Expand Down Expand Up @@ -117,7 +132,8 @@ def slice_install(self):
self._clear_logs()

if 'kikimr' in self.components:
format_drivers(self.nodes)
self._check_drives_exist()
self._format_drives()

if 'bin' in self.components.get('kikimr', []):
self._update_kikimr(self.nodes, self.configurator.kikimr_bin, self.configurator.kikimr_compressed_bin)
Expand Down
3 changes: 3 additions & 0 deletions ydb/tools/ydbd_slice/kube/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ def slice_nodeclaim_format(api_client, project_path, manifests):
return
node_list = nodes.Nodes(node_list)
handlers.format_drivers(node_list)
cmd = r"sudo find /dev/disk/ -path '*/by-partlabel/kikimr_*' " \
r"-exec dd if=/dev/zero of={} bs=1M count=1 status=none \;"
nodes.execute_async(cmd)


def slice_nodeclaim_delete(api_client, project_path, manifests):
Expand Down

0 comments on commit 9aaa2c1

Please sign in to comment.