x
login Signup

How do you prevent ElectricSentry jobs from being deleted?

I need to troubleshoot some occasional ElectricSentry failures. I added a condition to the cleanup step to skip if the sentry fails or times out. This works until the next sentry job succeeds - then all previous sentry jobs are deleted. In poking through the implementation, I see a spot in the cleanup subprocess that checks to see if sentry is configured to preserve failed jobs. However, I cannot determine where that configuration is set. How do I configure ElectricSentry to preserve failed jobs?

avatar image By david 131 asked Aug 22 at 10:09 PM
more ▼
(comments are locked)
10|750 characters needed characters left

2 answers: sort voted first

Very easy. Got edit the ECSCM::ElectricSentry procedure

The last step "Cleanup", simply add "0" to the runCondition

When you reenable it, it will automatically delete all the old jobs

Remember to enable Cleanup agains otherwise ElectricSentry will fill your job table pretty quickly

avatar image By lrochette 5.9k answered Aug 24 at 01:51 PM
more ▼
(comments are locked)
10|750 characters needed characters left

Hey Laurent, Unfortunately, that's not what I was looking for. The "cleanup" subproc under the ECSCM > scm_driver > ElectricSentry::Driver property has the following (seems like stuff was left unimplemented):

 #-------------------------------------------------------------------------
 # Cleanup
 #-------------------------------------------------------------------------
 sub cleanup {
     my $self = shift;
     my ( $sentryProjectName, $sentryScheduleName, $sentryProcedureName ) =
       $self->ECSentryGetProjectAndScheduleNames();
 
     # Save all jobs or just error jobs if flag is set
     my $tCfg =
       new ElectricSentry::GlobalCfg( $self->getCmdr(), $sentryProjectName,
         $sentryScheduleName );
 
     my $saveJobs = $tCfg->getSaveJobs();
     $saveJobs = lc($saveJobs);
     if ( $saveJobs eq "1" || $saveJobs eq "true" ) {
         return;
     }
 
     # Check for the OS Type
     my $osIsWindows = $^O =~ /MSWin/;
 
     #  Find all previous runs of this job
     my @filterList;
     push(
         @filterList,
         {
             "propertyName" => "projectName",
             "operator"     => "equals",
             "operand1"     => "$sentryProjectName"
         }
     );
     push(
         @filterList,
         {
             "propertyName" => "procedureName",
             "operator"     => "equals",
             "operand1"     => "$sentryProcedureName"
         }
     );
     push(
         @filterList,
         {
             "propertyName" => "status",
             "operator"     => "equals",
             "operand1"     => "completed"
         }
     );
 
   # Delete only the jobs that this SCHEDULE started (unless deleteAll specified)
     if ( $saveJobs !~ /deleteall/ ) {
         push(
             @filterList,
             {
                 "propertyName" => "scheduleName",
                 "operator"     => "equals",
                 "operand1"     => "$sentryScheduleName"
             }
         );
     }
 
     # Save error jobs if requested
     if ( $saveJobs =~ /error/ ) {
         push(
             @filterList,
             {
                 "propertyName" => "outcome",
                 "operator"     => "notEqual",
                 "operand1"     => "error"
             }
         );
     }
 
     # Run the Query
     my ( $success, $xPath ) =
       $self->getECSCM()->InvokeCommander( { SuppressLog => 1 },
         "findObjects", "job", { numObjects => "3000", filter => \@filterList } );
 
     # Loop over all returned jobs
     my $nodeset = $xPath->find('//job');
     foreach my $node ( $nodeset->get_nodelist ) {
 
         #  Find the workspaces (there can be more than one if some steps
         #  were configured to use a different workspace
         my $jobId   = $xPath->findvalue( 'jobId',   $node );
         my $jobName = $xPath->findvalue( 'jobName', $node );
         my ( $success, $xPath ) =
           $self->getECSCM()
           ->InvokeCommander( { SuppressLog => 1 }, "getJobInfo", $jobId );
         my $wsNodeset = $xPath->find('//job/workspace');
         foreach my $wsNode ( $wsNodeset->get_nodelist ) {
 
             my $workspace;
             if ($osIsWindows) {
                 $workspace = $xPath->findvalue( './winUNC', $wsNode );
                 $workspace =~ s/\/\//\\\\/g;
             }
             else {
                 $workspace = $xPath->findvalue( './unix', $wsNode );
             }
 
             # Delete the workspace (after checking its name as a sanity test)
             # look for "job_[nnn|UUID]"
             if ( $workspace =~ /[-_][\d]+$|[-_][0-9a-f]{8}(?:-[0-9a-f]{4}){4}[0-9a-f]{8}$/ ) {
                 use File::Path;
 
                 rmtree( [$workspace] ) unless ( $ENV{SENTRY_SIMULATE_DELETE} );
                 print "Deleted workspace - $workspace\n";
             }
         }
 
         # Delete the job
 
         my ( $success, $xPath ) =
           $self->getECSCM()
           ->InvokeCommander( { SuppressLog => 1 }, "deleteJob", $jobId );
         print "Deleted job - $jobName\n";
     }
 }
avatar image By david 131 answered Aug 29 at 05:08 PM
more ▼
(comments are locked)
avatar image lrochette Aug 30 at 03:59 AM

my system still works :) It does not delete any job. the configuration should either be in the 'ECSM' plugin in property sheet 'scm_cfgs'. I have no time to test but wondering if could simply add a saveJobs property and see if it helps.

10|750 characters needed characters left
Your answer
toggle preview:

Up to 8 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.