Details
-
Bug
-
Status: Resolved
-
Medium
-
Resolution: Done
-
None
-
None
-
None
-
None
Description
The SyslogDatastoreManager implements a mechanism for an external client to register a callback URL to be notified of syslog messages that pass a specified filter.
Registration is done via a register-filter RPC. It generates a filter ID and writes a SyslogFilter list entry to the CONFIGURATION store. It also generates a listener ID and writes a Listener list entry under the SyslogFilter entry. A RegisteredListener instance is instantiated to listen for updates to the SyslogListener list entry in the OPERATIONAL store. When a syslog message is raised, if it passes the filter, the message text is written to the SyslogListener entry where, upon change notification, the RegisteredListener sends it to the callback URL.
I don't know the original use case for this functionality and why it was added. Unfortunately the patch that added it, https://git.opendaylight.org/gerrit/#/c/41711/20, does not explain the reason.
A few things I observed:
- I don't see the purpose of the Listener list under the SyslogFilter entry, ie why would there ever be multiple listeners sending to the same callback URL. Plus the way the code is structured, there is only ever one Listener entry.
- The registration mechanism doesn't survive restarts since the RegisteredListener is instantiated via the RPC. So the external client woild need to detect that ODL restarted and re-register via the RPC. This would generate a new filter ID and a new SyslogFilter entry which could lead to a lot of stale entries over time.
- I'm not crazy about using the OPERATIONAL store as an intermediary to trigger delivery to the callback URL. It isn't intended for such a purpose and isn't efficient.
Assuming we want to keep this functionality, I propose we simplify it and make it work properly across restarts. Remove the listener lists from the yang model and simplify to:
container syslog-dispatcher {
list syslog-filter {
config true;
key "filter-id";
leaf filter-id {
type string;
description "the unique ID of registered filter.";
}
container filter {
uses meta-filter;
}
leaf callback-url {
type string;
description "callback URL of your app.";
}
}
Eliminate the register and delete filter RPCs. Users can write syslog-filter entries to register. Add a DTCL for the syslog-filter list that caches the entries for quick retrieval. When a syslog message is raised, queue a thread task fo each registered filter to offload the notification.