Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
pdist: Add option --set-pdist-status
Add option --set-pdist-status. This option make the client write a
status file /.pdist_status when everything completed successfully. It is
supposed to be used only during full dists from the distmaster.

The idea is that health check scripts can look at the status file  and
the embededed time tag to find out when a system was successfully updated
and generate an alarm if this is to long in the past.
  • Loading branch information
donald committed Mar 31, 2021
1 parent af5de81 commit cfe4db8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pdist/pdist
Expand Up @@ -187,7 +187,7 @@ $SIG{PIPE} = sub {clean_tmp();exit 1;};

# options

our ($debug,$quiet,$fileop_noop,$fileop_debug,$delete);
our ($debug,$quiet,$fileop_noop,$fileop_debug,$delete,$set_pdist_status);
our ($verbose,$timeout,@files,$ssh_tunnel,$post_command,$parallel,$prompt,$msg_prefix);
our ($distfilename) = (DISTFILE);

Expand Down Expand Up @@ -829,6 +829,13 @@ sub prog_update
warn "$fn: $!\n";
}
}

if ( !$fileop_noop && $set_pdist_status) {
my $t=time;
open L,'>','/.pdist_status' or die "/.pdist_status: $!\n";
print L 'OK',$t,scalar(localtime($t));
close L;
}
}

if ($function==F_REQUEST) {
Expand Down Expand Up @@ -1014,6 +1021,8 @@ sub push_single
$fileop_debug and push @remote_opts,'--fileop_debug';
$debug and push @remote_opts,'--debug';
push @remote_opts,$delete ? '--delete' : '--nodelete';
$set_pdist_status and push @remote_opts,'--set-pdist-status';

$post_command and push @remote_opts,'--post-command='.quotemeta($post_command);

$parallel && $parallel>1 and push @remote_opts,'--msg-prefix',$client;
Expand Down Expand Up @@ -1186,6 +1195,7 @@ usage: $0 cmd [options]
--fileop_debug # log all file operations
--[no]delete # do or do not clean up additional files on client.
# default is delete unless --files is used
--set-pdist-status # force creation of /.pdist_status on target
--verbose # be more verbose
--fileop_noop # DEPRECATED: now --noop
Expand Down Expand Up @@ -1222,6 +1232,7 @@ use constant OPTIONS => (

'fileop_debug' => \$fileop_debug,
'delete!' => \$delete,
'set-pdist-status' => \$set_pdist_status,

'verbose' => \$verbose,
'debug' => \$debug,
Expand Down

0 comments on commit cfe4db8

Please sign in to comment.