-
Notifications
You must be signed in to change notification settings - Fork 5
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
Improve ncd status logging #13
Changes from 4 commits
32f6945
df625a3
d8790c2
1bbdf9d
94421f2
a3f6a8c
0fe244c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -563,7 +563,7 @@ sub launch_ncd { | |
|
||
my $result = 0; # Assume success | ||
|
||
my @cmd = ( '/usr/sbin/ncm-ncd', '--configure' ); | ||
my $p = CAF::Process->new(['/usr/sbin/ncm-ncd', '--configure'] , log => $this_app ); | ||
if ( defined( $this_app->{ICLIST} ) && scalar(@{$this_app->{ICLIST}}) ) { | ||
# At this point, ICLIST should contain only components present in the last profile received. | ||
# The only case where a component may be in the list without being part of the configuration | ||
|
@@ -574,62 +574,60 @@ sub launch_ncd { | |
# X failed with profile N+1) and thus X removal is not detected. | ||
# As a result, X remains on the list of component to run. This should be harmless as ncm-ncd will ignore it. | ||
# This is probably rare enough to avoid complex processing to handle this in ncm-dispd. | ||
push @cmd, @{ $this_app->{ICLIST} }; | ||
$p->pushargs(@{$this_app->{ICLIST}}); | ||
} else { | ||
$this_app->info("no components to be run by NCM - ncm-ncd won't be called"); | ||
return (0); | ||
} | ||
|
||
# ncd options | ||
if ( $this_app->option('state') ) { | ||
push @cmd, "--state", $this_app->option('state'); | ||
$p->pushargs("--state", $this_app->option('state')); | ||
} | ||
if ( $this_app->option('ncd-retries') ) { | ||
push @cmd, "--retries", $this_app->option('ncd-retries'); | ||
$p->pushargs("--retries", $this_app->option('ncd-retries')); | ||
} | ||
if ( $this_app->option('ncd-timeout') ) { | ||
push @cmd, "--timeout", $this_app->option('ncd-timeout'); | ||
$p->pushargs("--timeout", $this_app->option('ncd-timeout')); | ||
} | ||
if ( $this_app->option('ncd-useprofile') ) { | ||
push @cmd, "--useprofile", $this_app->option('ncd-useprofile'); | ||
$p->pushargs("--useprofile", $this_app->option('ncd-useprofile')); | ||
} | ||
|
||
my $cmd_line = join( " ", @cmd ); | ||
if ( $this_app->option('noaction') ) { | ||
$this_app->info( "would run (noaction mode): " . $cmd_line ); | ||
$this_app->info( "would run (noaction mode): $p"); | ||
} else { | ||
$this_app->info( "about to run: " . $cmd_line ); | ||
my $verb = $cmd[0]; | ||
if ( -x $verb ) { | ||
$this_app->info( "about to run: $p"); | ||
if ( $p->is_executable() ) { | ||
# Delay processing of some signals | ||
delay_signals(); | ||
|
||
# Execute ncm-ncd and report exit status | ||
my $p = CAF::Process->new( \@cmd, log => $this_app ); | ||
sub act { | ||
my ($logger, $message) = @_; | ||
$logger->debug(1, $message); | ||
$logger->verbose($message); | ||
} | ||
my $errormsg = $p->stream_output(\&act, mode => 'line', arguments => [$this_app]); | ||
|
||
my $ec = $?; | ||
$this_app->debug(3, "ncm-ncd finished with full message $errormsg"); | ||
my $msg = "ncm-ncd finished with status: exitcode ". ($ec >> 8) . " (ec $ec)"; | ||
my $msg = "ncm-ncd finished with status: ". ($ec >> 8) . " (ec $ec"; | ||
my $log_level = 'info'; | ||
if ( $ec ) { | ||
$msg .= " (some configuration modules failed to run successfully)"; | ||
$log_level = 'warn'; | ||
$msg .= ", some configuration modules failed to run successfully)"; | ||
$result = 1; | ||
} else { | ||
$msg .= " (all configuration modules ran successfully)"; | ||
$msg .= ", all configuration modules ran successfully)"; | ||
} | ||
$this_app->info($msg); | ||
$this_app->$log_level($msg); | ||
|
||
# Process delayed signal if any and reestablish | ||
# immediate processing of signals | ||
process_signal(); | ||
immediate_signals(); | ||
|
||
} else { | ||
$this_app->error("Command $verb not found"); | ||
$this_app->error("Command ". ${$p->get_command()}[0] . " not found or not executable"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, if this is going to be frequently used, i propose to add to CAF (one or more) of:
sub execute_if_exists
{
my $(self) = @_;
if ($self->is_executable()) {
return $self->execute();
} else {
$self->{log}->error("Command ".$self->get_executable()." not found or not executable");
return 1;
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 for As for the Probably better to open an issue in CAF for this discussion... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe use the constant |
||
$result = 1; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mayeb make
/usr/sbin/ncm-ncd
a conatsnat or readonly and use it here and below?