Question about schedules

29 views
Skip to first unread message

Denis Kostromitskiy

unread,
Aug 11, 2014, 4:18:43 AM8/11/14
to vfe...@googlegroups.com
Hi!
I have a question about schedules.. I'm a bit confused there.
I have 4 customers. I want to add a schedule to customer= 'Customer'. I'm adding it, and as expected, this schedule is only available for this particular customer. I'm switching across other customers and their schedules list is empty. Ok.
BUT..
After server restart
$ sudo /opt/TopPatch/tp/src/daemon/vFensed restart
Schedules I've created for just one customer= 'Customer' spread all over all others customers... That's confusing. It shouldn't be this way I guess.
What could be reason of such behavior?


After server restart

 Jobstore default:
    New (trigger: cron[day_of_week='4', hour='16', minute='22'], next run at: 2014-08-15 16:22:00)
    wee (trigger: cron[day_of_week='4', hour='16', minute='23'], next run at: 2014-08-15 16:23:00)
    2nd (trigger: cron[day='8', hour='16', minute='23'], next run at: 2014-09-08 16:23:00)
    sad (trigger: cron[day_of_week='4', hour='16', minute='24'], next run at: 2014-08-15 16:24:00)
Jobstore Customer:
    New (trigger: cron[day_of_week='4', hour='16', minute='22'], next run at: 2014-08-15 16:22:00)
    wee (trigger: cron[day_of_week='4', hour='16', minute='23'], next run at: 2014-08-15 16:23:00)
    2nd (trigger: cron[day='8', hour='16', minute='23'], next run at: 2014-09-08 16:23:00)
    sad (trigger: cron[day_of_week='4', hour='16', minute='24'], next run at: 2014-08-15 16:24:00)
Jobstore SomeNewClient:
    New (trigger: cron[day_of_week='4', hour='16', minute='22'], next run at: 2014-08-15 16:22:00)
    wee (trigger: cron[day_of_week='4', hour='16', minute='23'], next run at: 2014-08-15 16:23:00)
    2nd (trigger: cron[day='8', hour='16', minute='23'], next run at: 2014-09-08 16:23:00)
    sad (trigger: cron[day_of_week='4', hour='16', minute='24'], next run at: 2014-08-15 16:24:00)
Jobstore SUPER:
    New (trigger: cron[day_of_week='4', hour='16', minute='22'], next run at: 2014-08-15 16:22:00)
    wee (trigger: cron[day_of_week='4', hour='16', minute='23'], next run at: 2014-08-15 16:23:00)
    2nd (trigger: cron[day='8', hour='16', minute='23'], next run at: 2014-09-08 16:23:00)
    sad (trigger: cron[day_of_week='4', hour='16', minute='24'], next run at: 2014-08-15 16:24:00)



This script always shows jobs spread across all customers.

###
from apscheduler.scheduler import Scheduler
from apscheduler.jobstores.redis_store import RedisJobStore
import logging

logging.basicConfig()

def main():
    sched = Scheduler(daemonic=False)
    sched.add_jobstore(RedisJobStore(db=10), 'default')
    sched.add_jobstore(RedisJobStore(db=10), 'SUPER')
    sched.add_jobstore(RedisJobStore(db=10), 'Customer')
    sched.add_jobstore(RedisJobStore(db=10), 'SomeNewClient')

    sched.start()

    print sched.print_jobs()

    sched.shutdown()


if __name__ == "__main__":
    main()

###

Allen Sanabria

unread,
Aug 11, 2014, 8:38:09 AM8/11/14
to vfe...@googlegroups.com
Hey Denis, so I was able to replicate this issue. This has to due with the apscheduler RedisJobStore. We are using apschedulers internal list of jobs feature to get the jobs we need. This issue has also been fixed in the next release of vFense. We transitioned from using RedisJobStore to the RethinkDBJobstore. We now query RethinkdDB directly for all the jobs. In the mean time, even though we are quite a bit a way from the next release, I will see if I can write a patch to get this rectified for you.

Denis Kostromitskiy

unread,
Aug 19, 2014, 5:00:29 AM8/19/14
to vfe...@googlegroups.com
Seems like issue is resolved by simply by adding specific key for every customer:

--- src/scheduler/jobManager.py (revision 186)
+++ src/scheduler/jobManager.py (revision 187)
@@ -52,7 +52,7 @@
         if customers:
             for customer in customers:
                 sched.add_jobstore(
-                    RedisJobStore(db=10), customer[CustomerKey.CustomerName]
+                    RedisJobStore(db=10, key_prefix=customer[CustomerKey.CustomerName]+'.'), customer[CustomerKey.CustomerName]
                 )
                 list_of_customers.append(
                     {

And note also, that you probably want to add a jobstore for customer while customer creation. Otherwise you need to restart server to add jobstore for newly created customer.

Allen Sanabria

unread,
Aug 19, 2014, 8:57:48 AM8/19/14
to vfe...@googlegroups.com
Denis, can you do a pull request? Once you do the pull request, I will review and merge into development.  Just so you know all the work I have been doing lately is in the pre-0.8.1 branch..

Do not use it as it isn't ready yet, but at least you can see the work I've been up too.
Reply all
Reply to author
Forward
0 new messages