Commit 89215f46 authored by Felix Seibert's avatar Felix Seibert
Browse files

introducing a break after a certain number of iterations. simplifying debug output.

parent d79c0fb7
......@@ -174,10 +174,14 @@ class OSDManager(object):
'''
def fix_physical_layout(self, repeat_delete_interval_secs=15):
# list 1
change_policy_command_list = []
# list 2
create_replica_command_list = []
# list 3
delete_replica_command_list = []
# create commands
managed_folders = self.get_assigned_folders()
for managed_folder in managed_folders:
for directory in os.walk(managed_folder):
......@@ -190,11 +194,6 @@ class OSDManager(object):
osd_for_file = self.distribution.get_containing_osd(containing_folder_id).uuid
if osd_of_file != osd_for_file:
# create replication commands
# collect replication commands
# run replication commands - handle errors if new replica is not complete yet
# if no replication is used (otherwise than for moving the files from osd to osd),
# we should reset the replication policy to none
policy_command = div_util.create_replication_policy_command(absolute_file_path)
create_command = div_util.create_create_replica_command(absolute_file_path, osd_for_file)
delete_command = div_util.create_delete_replica_command(absolute_file_path, osd_of_file)
......@@ -203,24 +202,37 @@ class OSDManager(object):
create_replica_command_list.append(div_util.command_list_to_single_string(create_command))
delete_replica_command_list.append(div_util.command_list_to_single_string(delete_command))
# run commands
processes = div_util.run_commands(change_policy_command_list)
if self.debug:
print("executing " + str(len(processes)) + " change policy commands done. Results:")
div_util.print_process_list(processes)
# div_util.print_process_list(processes)
processes = div_util.run_commands(create_replica_command_list)
if self.debug:
print("executing " + str(len(processes)) + " create replica commands done. Results:")
div_util.print_process_list(processes)
# div_util.print_process_list(processes)
processes = div_util.run_commands(delete_replica_command_list)
# run and repeat delete commands, until they return no error
# (if an error is returned for another reason than that one would delete the last complete replica,
# this will probably not work.
iterations = 0
max_iterations = 5000 # e.g. approximately 24h with the default repeat interval of 15 secs
while True:
if self.debug:
print("executing " + str(len(processes)) + " delete replica commands done. Results:")
if iterations >= max_iterations:
print("results of last iteration: ")
div_util.print_process_list(processes)
print("Original replicas could not be deleted after " + str(max_iterations) + ". Aborting...")
break
if self.debug:
print("executing " + str(len(processes))
+ " delete replica commands done. This is iteration "
+ str(iterations))
# div_util.print_process_list(processes)
# successful_deletions = []
errored_deletions = []
for process in processes:
......@@ -233,7 +245,11 @@ class OSDManager(object):
time.sleep(repeat_delete_interval_secs)
if self.debug:
print("rerunning " + str(len(errored_deletions)) + " commands because replica could not be deleted...")
processes = div_util.run_commands(errored_deletions)
iterations += 1
'''
create empty folders and assign OSDs.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment