Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MANOPD-86838] Resolve conflict of archive names in add_node and restore procedures #402

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions kubemarine/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,17 +444,21 @@ def upload_info_new_control_planes(self):
if new_control_planes.is_empty():
return

archive_name = 'dump_log_cluster.tar.gz'
archive_dump_path = get_dump_filepath(self.cluster.context, archive_name)
archive_remote_path = f"/tmp/{archive_name}"
log = self.cluster.log

node = self.cluster.nodes['control-plane'].get_initial_nodes().get_first_member(provide_node_configs=True)
control_plane = self.cluster.make_group([node['connect_to']])
data_copy_res = control_plane.sudo(f'tar -czvf /tmp/kubemarine-backup.tar.gz {self.dir_path}')
self.cluster.log.verbose('Backup created:\n%s' % data_copy_res)
control_plane.get('/tmp/kubemarine-backup.tar.gz',
get_dump_filepath(self.cluster.context, "dump_log_cluster.tar.gz"), 'dump_log_cluster.tar.gz')
data_copy_res = control_plane.sudo(f'tar -czvf {archive_remote_path} {self.dir_path}')
log.verbose("Archive with procedures history is created:\n%s" % data_copy_res)
control_plane.get(archive_remote_path, archive_dump_path)

self.cluster.log.debug('Backup downloaded')
log.debug("Archive with procedures history is downloaded")

for new_node in new_control_planes.get_ordered_members_list(provide_node_configs=True):
group = self.cluster.make_group([new_node['connect_to']])
group.put(get_dump_filepath(self.cluster.context, "dump_log_cluster.tar.gz"),
"/tmp/dump_log_cluster.tar.gz", sudo=True)
group.sudo(f'tar -C / -xzvf /tmp/dump_log_cluster.tar.gz')
group.put(archive_dump_path, archive_remote_path, sudo=True)
group.sudo(f'tar -C / -xzvf {archive_remote_path}')
log.debug(f"Archive with procedures history is uploaded to {new_node['name']!r}")