Re: Poll for output in Minions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/28/2009 02:00 PM, makkalot wrote:
Poll for output in Minions:

   This implementation is a result of an idea that was post on ML a few weeks
ago.
The main idea was to be able to get some output during the minion side
execution.
The idea maybe useful for tasks which are kind of long and user wants to get
some
notification about what is going on on the other side. Because we are talking
about
long running operations that stuff is reasonable only for async stuff. Here is
some example
of tracking a long operation on overlord :

    Yup, doing this only for async makes perfect sense to me (and I
have no idea how to do it otherwise ;->)


[root@acerfedora func]# func "*" call --logpoll --async echo run_str_log
"eeeeee"
Logging data is initializing ...
------HOST : acerfedora -------
2009-07-28 20:06:55,013 - 1248800814.958679-minion - INFO - Starting counting
logger ...
------HOST : acerfedora -------
2009-07-28 20:08:00,034 - 1248800814.958679-minion - INFO - Calling method
with counter is 0
------HOST : acerfedora -------
2009-07-28 20:08:05,033 - 1248800814.958679-minion - INFO - Calling method
with counter is 1
------HOST : acerfedora -------
2009-07-28 20:08:10,034 - 1248800814.958679-minion - INFO - Calling method
with counter is 2
------HOST : acerfedora -------
2009-07-28 20:08:15,034 - 1248800814.958679-minion - INFO - Calling method
with counter is 3

That example is for lots of machines (overlord spec) but polling output seems
more reasonable for doing it for an one host :

    Indeed. Output for multiple minions reporting seems like it would
be a mess. I could see where it has it's uses (mostly just eyeballing whats
going on) but it looks like it would be hard to do much with it.

[root@acerfedora func]# func "*" call --nopoll --async echo run_str_log
"eeeeee"
JOB_ID: '*-echo-run_str_log-1248802501.952774'
[root@acerfedora func]#
[root@acerfedora func]# func "*" call --logone="acerfedora" "*-echo-
run_str_log-1248802501.952774"

2009-07-28 20:35:02,318 - 1248802502.256377-minion - INFO - Starting counting
logger ...
2009-07-28 20:36:07,318 - 1248802502.256377-minion - INFO - Calling method
with counter is 0
2009-07-28 20:36:12,317 - 1248802502.256377-minion - INFO - Calling method
with counter is 1
2009-07-28 20:36:17,317 - 1248802502.256377-minion - INFO - Calling method
with counter is 2
2009-07-28 20:36:22,317 - 1248802502.256377-minion - INFO - Calling method
with counter is 3
2009-07-28 20:36:27,318 - 1248802502.256377-minion - INFO - Calling method
with counter is 4
2009-07-28 20:36:32,318 - 1248802502.256377-minion - INFO - Calling method
with counter is 5
.



Making a method to have trackable output : It is pretty easy let see it on an
example :
a method in echo module :

def run_str_log(self,command):
         import time

         self.run_str_log.logger.info("Starting counting logger ...")
         time.sleep(60)
         for i in range(100):
             time.sleep(5)
             self.run_str_log.logger.info("Calling method with counter is
%d"%i)

         return command


By default every method in minion modules is attached with a standart logger
instance.To reach the
log instance what you need is calling self.method.logger and you have all the
stuff in a standart logging.
       One thing we might be able to do on some methods is progress
report. Certainly can't do it with all methods, but some you should
be able to. Maybe argument the logging call with a param for progress
(ie, I'm at 123 of 354).

Python API :

To poll logs on minion side with API :

In [1]: from func.overlord.client import Overlord

In [2]: fc = Overlord("*",async=True)

In [3]: j=fc.echo.run_str_log("blip")

In [4]: j
Out[4]: '*-echo-run_str_log-1248802917.3343029'

In [5]: fc.tail_log(j)
Out[5]:
({'acerfedora': ['2009-07-28 20:41:57,572 - 1248802917.536685-minion - INFO -
Starting counting logger ...\n',
                  '']},
  False)

About how to make that code useful in your applications you should take a look
into overlord/cmd_modules/call.py

Also you can poll a single machine if you need , which maybe useful in webapps
or some other stuff.

In [6]: fc = Overlord("*",async=True)

In [7]: j=fc.echo.run_str_log("blip")

In [8]: fc.tail_log(j,host="acerfedora")
Out[8]:
({'acerfedora': ['2009-07-28 20:43:45,233 - 1248803025.1892841-minion - INFO -
Starting counting logger ...\n',
                  '']},
  False)

In [9]:


Looks good to me.


Adrian

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux