PacketFence - BTS - PacketFence
View Issue Details
0001490PacketFencecorepublic2012-07-13 11:492012-09-06 10:57
fgaudreault 
obilodeau 
normalminoralways
closedfixed 
3.3.2 
3.5.13.5.1 
2ac65663676178ef2ba5ca0cdf3311eda1953317
0001490: pfdhcplistener watch will start instead of restart
Two things:
- The watch will not restart unless ALL the pfdhcplistener daemons are crashed/not running
- Instead of restarting the service when a daemon crashed, the watch will start new ones stacking the process (so you can end up with multiple listeners for the same interface)
To fix it :
In services.pm:
$action eq "status" && do {
                my $pid;
                # Handle the pfdhcplistener case. Check how much internal interfaces + management we have, and if the number of pids
                # are not equals this (internal+management), then return 0 to force a restart.
                if ($exe ne "pfdhcplistener") {
                    chop( $pid = `pidof -x $exe` );
                    $pid = 0 if ( !$pid );
                } else {
                    my @devs = get_internal_devs_phy();
                    my $numPids = $#devs+1;

                    $pid = `pidof -x $exe`;
                    my @pidArray = split(/ /, $pid);

                    if ($#pidArray != $numPids) {
                       $pid = 0
                    }
                }
                $logger->info("pidof -x $exe returned $pid");
                return ($pid);
            }

In bin/pfcmd:
if ( lc($command) eq 'restart' ) {
        if ( lc($service) eq 'pf' ) {
            $logger->info(
                "packetfence restart ... executing stop followed by start");
            local $cmd{command}[2] = "stop";
            service();
            local $cmd{command}[2] = "start";
            service();
            return 1;
        } else {
            if ( !pf::services::service_ctl( $service, "status" ) ) {
                $command = "restart";
            }
        }
    }
No tags attached.
Issue History
2012-07-13 11:49fgaudreaultNew Issue
2012-07-13 11:57fgaudreaultTag Attached: Code Review
2012-07-13 11:57fgaudreaultStatusnew => feedback
2012-07-19 11:28fgaudreaultNote Added: 0002849
2012-07-30 14:54fgaudreaultNote Added: 0002852
2012-07-30 14:54fgaudreaultStatusfeedback => resolved
2012-07-30 14:54fgaudreaultResolutionopen => fixed
2012-07-30 14:54fgaudreaultAssigned To => fgaudreault
2012-07-31 14:45dwuelfrathNote Added: 0002855
2012-07-31 14:45dwuelfrathFixed in Version => 3.5.0
2012-07-31 14:45dwuelfrathTag Detached: Code Review
2012-08-06 16:40obilodeauStatusresolved => closed
2012-08-17 09:08obilodeauAssigned Tofgaudreault => obilodeau
2012-08-17 09:08obilodeauNote Added: 0002944
2012-08-17 09:08obilodeauStatusclosed => feedback
2012-08-17 09:08obilodeauResolutionfixed => reopened
2012-08-17 10:44obilodeauStatusfeedback => assigned
2012-08-17 12:01obilodeauNote Added: 0002948
2012-08-17 14:04obilodeaugit revision => 2ac65663676178ef2ba5ca0cdf3311eda1953317
2012-08-17 14:04obilodeauNote Added: 0002949
2012-08-17 14:04obilodeauStatusassigned => resolved
2012-08-17 14:04obilodeauFixed in Version3.5.0 => +1
2012-08-17 14:04obilodeauResolutionreopened => fixed
2012-09-06 10:56obilodeauTarget Version => 3.5.1
2012-09-06 10:56obilodeauFixed in Version+1 => 3.5.1
2012-09-06 10:57obilodeauNote Added: 0003025
2012-09-06 10:57obilodeauStatusresolved => closed

Notes
(0002849)
fgaudreault   
2012-07-19 11:28   
Created a fix branch for that one. Merge it when able...
(0002852)
fgaudreault   
2012-07-30 14:54   
Merged in Devel.
(0002855)
dwuelfrath   
2012-07-31 14:45   
Fixed in 3.5.0
(0002944)
obilodeau   
2012-08-17 09:08   
Having issues with this patch if pfdhcplistener get stuck.

Also I'm not sure about the 'restart' idea. It kept restarting *every* service every 5 minutes just because there was a single pfdhcplistener process stuck..

Investigating a little more before deciding what to do.
(0002948)
obilodeau   
2012-08-17 12:01   
My previous comment about restarting everything is unrelated to the previous fix in that change, sorry about that. See 0001494.

The real process management problem is that 3 hung pfdhcplisteners on eth0 is the same as 3 properly running dhcplisteners on eth0, eth0.10 and eth0.20. Now that I fixed 0001478, we should do a better job and check on what process each listeners runs.
(0002949)
obilodeau   
2012-08-17 14:04   
We are now checking exactly for the interface name in the process listing. This way no hung unrelated listener can count as a "running listener" for another interface.

See: https://github.com/inverse-inc/packetfence/pull/48 [^]
(0003025)
obilodeau   
2012-09-06 10:57   
fix released in 3.5.1 yesterday