diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-04-15 11:18:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-15 14:18:08 +0300 |
commit | 9aaa2c10c14ab4dc916b1d48e2e46df1f593cbc7 (patch) | |
tree | a6fd3e89bac2073d1a467d8d939efdd957f1ebb6 | |
parent | 00d677a6c00947f5afe40790de7076b16807dba9 (diff) | |
download | ydb-9aaa2c10c14ab4dc916b1d48e2e46df1f593cbc7.tar.gz |
Use drives from config for formatting in ydbd_slice (#3729)
-rw-r--r-- | ydb/tools/ydbd_slice/handlers.py | 34 | ||||
-rw-r--r-- | ydb/tools/ydbd_slice/kube/handlers.py | 3 |
2 files changed, 28 insertions, 9 deletions
diff --git a/ydb/tools/ydbd_slice/handlers.py b/ydb/tools/ydbd_slice/handlers.py index 32627706efa..dd8a2e0884a 100644 --- a/ydb/tools/ydbd_slice/handlers.py +++ b/ydb/tools/ydbd_slice/handlers.py @@ -20,12 +20,6 @@ class CalledProcessError(subprocess.CalledProcessError): ) -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' @@ -56,9 +50,30 @@ class Slice: "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): @@ -69,7 +84,7 @@ class Slice: 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: @@ -117,7 +132,8 @@ class Slice: 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) diff --git a/ydb/tools/ydbd_slice/kube/handlers.py b/ydb/tools/ydbd_slice/kube/handlers.py index 05080b8b93a..e627e903a26 100644 --- a/ydb/tools/ydbd_slice/kube/handlers.py +++ b/ydb/tools/ydbd_slice/kube/handlers.py @@ -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): |