PacketFence - BTS - PacketFence
View Issue Details
0001317PacketFencecorepublic2011-10-20 12:002012-10-29 15:02
fgaudreault 
fgaudreault 
highminoralways
resolvedfixed 
3.0.1 
3.6.1devel 
ad54619a893500d7d6febeb08094357048caa7ba
0001317: Nodes are beeing unreg if expire_mode set to window and no unreg date is set
Problematic query :
$node_statements->{'node_expire_window_sql'} = get_db_handle()->prepare(
        qq [ SELECT mac FROM node WHERE status="reg" AND unix_timestamp(regdate) + ? < unix_timestamp(now()) ]
    );

If you set no unregdate (0000-00-00 00:00:00) and you add 999w, it will always be lower than NOW(). The nodes will then be unregistered even if they should not.
No tags attached.
Issue History
2011-10-20 12:00fgaudreaultNew Issue
2011-10-20 12:01obilodeauStatusnew => assigned
2011-10-20 12:01obilodeauAssigned To => obilodeau
2011-10-21 11:25obilodeauNote Added: 0002373
2011-10-21 14:41fgaudreaultNote Added: 0002374
2011-12-22 11:15obilodeauNote Added: 0002484
2011-12-22 11:15obilodeauSeveritymajor => minor
2012-10-19 14:19fgaudreaultAssigned Toobilodeau =>
2012-10-19 14:19fgaudreaultTarget Version => general
2012-10-26 16:13fgaudreaultTarget Versiongeneral => 3.6.1
2012-10-29 14:37fgaudreaultNote Added: 0003263
2012-10-29 15:02fgaudreaultgit revision => ad54619a893500d7d6febeb08094357048caa7ba
2012-10-29 15:02fgaudreaultNote Added: 0003264
2012-10-29 15:02fgaudreaultStatusassigned => resolved
2012-10-29 15:02fgaudreaultFixed in Version => devel
2012-10-29 15:02fgaudreaultResolutionopen => fixed
2012-10-29 15:02fgaudreaultAssigned To => fgaudreault

Notes
(0002373)
obilodeau   
2011-10-21 11:25   
watch out, unregdate is not in the above query. So what is important is regdate + window < unix_timestamp( now() ).

When you saw nodes being batch de-registered what did they had as a regdate? Why was it so low?
(0002374)
fgaudreault   
2011-10-21 14:41   
You are right, my regdate was 0 since I registered my devices using raw SQL without updating that field with now(). However, the bug remains, if my regdate is 3 days ago, and my window is 2d, regardless the unregdate, I will still be unregistered.
(0002484)
obilodeau   
2011-12-22 11:15   
Reducing severity since the feature works as intended.

But we will still fix it by setting now + window to unregdate instead of looking at regdate because it gives more control to the administrators if they want to manually alter the unregdate.
(0003263)
fgaudreault   
2012-10-29 14:37   
We should only rely on the unregdate. At the registration time, we set the proper unregdate if using mode deadline or mode window. We should NEVER base our decision regarding the regdate.

A network admin should be allowed to mess with the unregdate manually.

I will remove the unnecessary code in node_maintenance.
(0003264)
fgaudreault   
2012-10-29 15:02   
Fixed in devel. Cleaned up some useless code.