Merge lp:~percona-toolkit-dev/percona-toolkit/pt-kill-does-not-report-failure-exit-code-1314500 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.11

Proposed by Frank Cizmich
Status: Work in progress
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-kill-does-not-report-failure-exit-code-1314500
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.11
Diff against target: 69 lines (+21/-2)
3 files modified
bin/pt-kill (+8/-0)
t/pt-kill/basics.t (+12/-1)
t/pt-kill/execute_command.t (+1/-1)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-kill-does-not-report-failure-exit-code-1314500
Reviewer Review Type Date Requested Status
Daniel Nichter Needs Information
Review via email: mp+233809@code.launchpad.net

Description of the change

Now waits a couple of seconds after launching daemon so it can return an error if it fails at start.
Only modified in pt-kill since it uses a heavily modified version of Daemon.pm

To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

See my comment in the bug.

review: Needs Information

Unmerged revisions

618. By Frank Cizmich

minor comment change

617. By Frank Cizmich

pt-kill now reports an exit error if daemon fails to start - 1314500

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/pt-kill'
--- bin/pt-kill 2014-08-05 20:37:42 +0000
+++ bin/pt-kill 2014-09-08 20:46:34 +0000
@@ -2263,6 +2263,7 @@
2263use constant PTDEBUG => $ENV{PTDEBUG} || 0;2263use constant PTDEBUG => $ENV{PTDEBUG} || 0;
22642264
2265use POSIX qw(setsid);2265use POSIX qw(setsid);
2266use POSIX ":sys_wait_h";
22662267
2267sub new {2268sub new {
2268 my ( $class, %args ) = @_;2269 my ( $class, %args ) = @_;
@@ -2289,6 +2290,13 @@
2289 defined (my $pid = fork()) or die "Cannot fork: $OS_ERROR";2290 defined (my $pid = fork()) or die "Cannot fork: $OS_ERROR";
2290 if ( $pid ) {2291 if ( $pid ) {
2291 PTDEBUG && _d('Parent PID', $PID, 'exiting after forking child PID',$pid);2292 PTDEBUG && _d('Parent PID', $PID, 'exiting after forking child PID',$pid);
2293 # we wait a short time to capture any early failure of child process so
2294 # we can return a proper exit code
2295 sleep 2;
2296 if (waitpid($pid, WNOHANG)>0) {
2297 exit 1;
2298 }
2299 PTDEBUG && _d('Parent PID', $PID, 'exiting after forking child PID',$pid);
2292 exit;2300 exit;
2293 }2301 }
22942302
22952303
=== modified file 't/pt-kill/basics.t'
--- t/pt-kill/basics.t 2012-12-01 18:17:18 +0000
+++ t/pt-kill/basics.t 2014-09-08 20:46:34 +0000
@@ -26,7 +26,7 @@
26 plan skip_all => 'Cannot connect to sandbox master';26 plan skip_all => 'Cannot connect to sandbox master';
27}27}
28else {28else {
29 plan tests => 6;29 plan tests => 7;
30}30}
3131
32my $output;32my $output;
@@ -80,6 +80,17 @@
80 '--verbose'80 '--verbose'
81);81);
8282
83# ############################################################################
84# returns error code if daemon fails to start
85# ############################################################################
86my $cmd2 = "$trunk/bin/pt-kill -F $cnf -h 127.1 --print --daemonize --pid /tmp/non_existing_dir/pt-kill.pid";
87my $exit_val = system($cmd2);
88is(
89 $exit_val >> 8,
90 1,
91 'exits with error 1 if daemon fails to start'
92);
93
83# #############################################################################94# #############################################################################
84# Reconnect if cxn lost.95# Reconnect if cxn lost.
85# #############################################################################96# #############################################################################
8697
=== modified file 't/pt-kill/execute_command.t'
--- t/pt-kill/execute_command.t 2012-10-20 19:26:33 +0000
+++ t/pt-kill/execute_command.t 2014-09-08 20:46:34 +0000
@@ -97,7 +97,7 @@
97 );97 );
9898
99 diag(`touch $sentinel`);99 diag(`touch $sentinel`);
100 sleep 1;100 sleep 5;
101 ok(101 ok(
102 !-f $pid_file,102 !-f $pid_file,
103 "pt-kill stopped"103 "pt-kill stopped"

Subscribers

People subscribed via source and target branches

to all changes: