-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging implementation for tendrl #178
Conversation
tendrl/node_agent/message/logger.py
Outdated
self.message.payload["job_id"], | ||
self.message.__dict__, | ||
append=True) | ||
log_message = ("%s:%s") % ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shtripat @brainfunked @r0h4n @nnDarshan @anmolbabu @nthomas-redhat
operation updates are required some sequence key, so we cant use etcdobj save method, and message is an object but is in common so direct write to etcd is used.
@shtripat @brainfunked @r0h4n @nnDarshan @anmolbabu @nthomas-redhat please review |
formatters: | ||
simple: | ||
format: "%(asctime)s - %(filename)s:%(lineno)s - %(funcName)20s() - %(levelname)s - %(message)s" | ||
datefmt: "%Y-%m-%dT%H:%M:%S%z" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have removed format because we cant tell function name and line no and file name from logger , it is passed with message and appended with log message automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is it passed with the message? any examples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@r0h4n
log_message = Message.to_json(log_message)
message = ("%s - %s - %s:%s - %s - %s - %s") % (
self.message.timestamp,
self.message.publisher,
self.message.caller["filename"],
self.message.caller["line_no"],
self.message.caller["function"],
self.message.priority.upper(),
log_message
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@r0h4n need you to review.
doc/source/installation.rst
Outdated
@@ -40,7 +40,8 @@ For installing node agent following dependencies have to be manually installed: | |||
|
|||
$ yum install libffi-devel gcc python-devel openssl-devel | |||
$ yum install -y http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm | |||
$ yum install hwinfo | |||
$ yum install hwinfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is hwinfo required for logging implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brainfunked i am not added hwinfo it comes because of some space change i think
log_level: DEBUG | ||
tendrl_message_socket_addr: 127.0.0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be a UNIX socket, as commented here: https://github.com/Tendrl/node-agent/pull/67/files#r97720923
stream: ext://sys.stdout | ||
|
||
info_file_handler: | ||
class: logging.handlers.SysLogHandler | ||
facility: local0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log to local5 or some such. Lots of programmes use local0, local1 etc.
tendrl-node-agent.spec
Outdated
@@ -24,6 +24,7 @@ Requires: collectd | |||
Requires: python-jinja2 | |||
Requires: tendrl-commons | |||
Requires: hwinfo | |||
Requires: rsyslog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not required.
tendrl/node_agent/message/handler.py
Outdated
RECEIVE_DATA_SIZE = 4096 | ||
|
||
|
||
class MessageHandler(gevent.greenlet.Greenlet): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be updated based on Tendrl/commons#134 (comment)
@brainfunked @shtripat @nthomas-redhat @anmolbabu @r0h4n @anmolsachan please review this, i have done all the changes |
tendrl/node_agent/message/logger.py
Outdated
class Logger(object): | ||
def __init__(self, message): | ||
self.message = message | ||
self.etcd_orm = tendrl_ns.etcd_orm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you want a copy use the global variable directly tendrl_ns.etcd_orm.....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anmolbabu i will correct it, no need to take copy
tendrl/node_agent/message/logger.py
Outdated
def critical(self, message): | ||
LOG.critical(message) | ||
|
||
def notice(self, message): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see from line 72, that this func name should match priority I think case wise and also exact name should be the func here. In which case is it NOTIF or notice? Applies to all other funcs above as well. Also if this all that needs to be done is there a better way of doing it? Probably have a map from log levels of tendrl to log levels of logger and use it in getattr directly on LOG object instead of on self? Just a thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will modify those line to call the function easily
tendrl/node_agent/message/handler.py
Outdated
def bind_unix_listener(self): | ||
try: | ||
if os.path.exists(PATH): | ||
os.remove(PATH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you really need to do this?
I feel just if the socket file is not used currently by some other process it suffices... Please check...
I am not sure though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anmolbabu i will check it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anmolbabu If we are not removed this file then i will throw exception like "Address already in use". They have to remove manually to run then node agent again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
formatters: | ||
simple: | ||
format: "%(asctime)s - %(filename)s:%(lineno)s - %(funcName)20s() - %(levelname)s - %(message)s" | ||
datefmt: "%Y-%m-%dT%H:%M:%S%z" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is it passed with the message? any examples?
tendrl/node_agent/message/handler.py
Outdated
|
||
|
||
RECEIVE_DATA_SIZE = 4096 | ||
PATH = "/etc/tendrl/.node_agent_socket" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to come from configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@r0h4n i will change it
tendrl/node_agent/message/handler.py
Outdated
@@ -0,0 +1,53 @@ | |||
import _socket |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use http://www.gevent.org/gevent.socket.html instead of _socket
tendrl/node_agent/message/handler.py
Outdated
try: | ||
if os.path.exists(PATH): | ||
os.remove(PATH) | ||
self.sock = _socket.socket(_socket.AF_UNIX, _socket.SOCK_STREAM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@r0h4n message contains one field called caller, it contains all the information about where the message is from and which function and line no. these details are captured using getframeinfo. so there information are appended with message and then logged. so no need log format here. because log format will take the details where the message is logged. Here we are logging the all message in node_agent , so it give wrong function name and line no and file name. |
@r0h4n example log_message = Message.to_json(log_message) |
@r0h4n all changes are done |
@@ -5,3 +5,4 @@ tendrl_ansible_exec_file: $HOME/.tendrl/node-agent/ansible_exec | |||
log_cfg_path: /etc/tendrl/node-agent/node-agent_logging.yaml | |||
log_level: DEBUG | |||
package_source_type: rpm | |||
logging_socket_path: "/etc/tendrl/.node_agent_socket" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this default path is not supposed to be in /etc, application sockets can be store in /tmp/node-agent/.node_agent.sock
help: "Called details" | ||
type: Dict | ||
enabled: true | ||
list: cluster/$TendrlContext.integration_id/messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clusters not cluster
enabled: true | ||
list: cluster/$TendrlContext.integration_id/messages | ||
help: "Cluster Messages" | ||
value: cluster/$TendrlContext.integration_id/messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: clusters
help: "Called details" | ||
type: Dict | ||
enabled: true | ||
list: node/$Node_context.node_id/messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camel case "Messages"
help: "Called details" | ||
type: Dict | ||
enabled: true | ||
list: cluster/$TendrlContext.integration_id/messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camelcase "Messages"
help: "Called details" | ||
type: Dict | ||
enabled: true | ||
list: /messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Messages"
@r0h4n all changes done |
tendrl-spec: logging_implementation Signed-off-by: GowthamShanmugam <gshanmug@redhat.com>
@r0h4n changes are done |
tendrl-bug-id: Tendrl/specifications#28
tendrl-spec: logging_implementation
Signed-off-by: GowthamShanmugam gshanmug@redhat.com