Commit df13b84b authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

Moved the method to Meadow since Meadow does most of the jobs anyway

parent ec57d958
......@@ -414,4 +414,23 @@ sub run_on_host {
return system('timeout', '3m', 'ssh', @extra_args, '-o', 'BatchMode=yes', '-o', 'ServerAliveInterval=30', sprintf('%s@%s', $meadow_user, $meadow_host), @$command);
=head2 cleanup_temp_directory
Title : cleanup_temp_directory
Function: Cleanup the temp directory assigned to the worker
sub cleanup_temp_directory {
my ($self, $worker) = @_;
# The feature can be disabled for this actual meadow
return unless $self->config_get('CleanupTempDirectoryKilledWorkers');
print "GarbageCollector:\tCleaning-up ".$worker->temp_directory_name."\n";
my $rc = $self->run_on_host($worker->meadow_host, $worker->meadow_user, ['rm', '-rf', $worker->temp_directory_name]);
$worker->worker_say(sprintf("Error: could not clean %s's temp directory '%s': %s\n", $worker->meadow_host, $worker->temp_directory_name, $@)) if $rc;
......@@ -571,7 +571,7 @@ sub check_for_dead_workers { # scans the whole Valley for lost Workers (but i
if( ($worker->status ne 'SUBMITTED') # There is no worker_temp_directory before specialization
and ($worker->meadow_user eq $this_meadow_user) ) { # if I'm actually allowed to kill the worker...
$valley->cleanup_left_temp_directory( $worker );
$this_meadow->cleanup_temp_directory( $worker );
......@@ -247,20 +247,4 @@ sub status_of_all_our_workers_by_meadow_signature {
sub cleanup_left_temp_directory {
my ($self, $worker) = @_;
# cleanup_left_temp_directory is called when garbage-collecting dead-workers,
# which is only possible for reachable meadows.
# This guarantees that $meadow is defined.
my $meadow = $self->available_meadow_hash->{$worker->meadow_type};
if ($meadow->config_get('CleanupTempDirectoryKilledWorkers')) {
print "GarbageCollector:\tCleaning-up /tmp\n";
my $rc = $meadow->run_on_host($worker->meadow_host, $worker->meadow_user, ['rm', '-rf', $worker->temp_directory_name]);
$worker->worker_say(sprintf("Error: could not clean %s's temp directory '%s': %s\n", $worker->meadow_host, $worker->temp_directory_name, $@)) if $rc;
Markdown is supported
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