-
Notifications
You must be signed in to change notification settings - Fork 191
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
Configured subscription integration #1440
base: udp_notif
Are you sure you want to change the base?
Configured subscription integration #1440
Conversation
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.
Thanks, I have commented only on minor/general issues I have noticed, most of them apply for many cases, not just where I have put the comment. After those are fixed, I will test the actual functionality and provide feedback for it.
ffdc083
to
9af4e86
Compare
Hello,
|
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.
After brief look it seems fine and neater than before. Sadly, I am not able to try it out and provide feedback for the actual functionality because I am going on a vacation for 2 weeks, I will respond after that.
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.
So I am back and wanting to test this, why not create some new tests? The code seems finished, so tests would definitely be required, at least some basic ones. Thanks.
9af4e86
to
a9f5508
Compare
Hi,
|
Firstly, I have rebased this branch to the current
So, thanks for the tests and everything, I have made some minor changes to be able to compile it and the tests produce some meaningful output so please commit it with some of your commits (the author is not important). I think you can create a separate test file for these tests because there should be several of them. I thought you are actually going to test sending and receiving the notifications but I assume you did that only with your proprietary notification receiver because there is none in netopeer2. Which brings me to my (hopefully) last larger request, add support for notification receiver somewhere to our projects so that it can be properly tested, both manually and in the test suite (so that there is not just setting and reading the configuration). Ideally into libnetconf2 and then it can be used with ease in both cases (netopeer2 test suite and netopeer2-cli). Other than that I have briefly went over the code and it seemed fine, no major changes will be required, I think. But I will not know unless I can actually see the notification being send and received. Thanks again for all your effort. |
This reverts commit 846f516.
68340fc
to
6c4e50e
Compare
Hi,
As you suggested, I reverted the commit with the test. One implementation of the notification receiver is https://github.com/pmacct/pmacct/tree/master. |
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 am about to run all the tests and try to go through all the code as it is executed but in the meantime you can address the comment I made and, in case you really do not know how to solve a problem, can add a test that is failing. I can then fix it much more easily than based on a description only (regarding the problem 2.).
Sorry, but the test is failing for me
and I found no simple way of fixing it, seems no notifications are being received for some reason. Other than that, they could use some improvements. Mainly using So, please make sure the tests pass. If they do for you, I should be able to find out what is wrong with some assistance. |
6c4e50e
to
57f2ad4
Compare
Hi Mishal, However you may see it once the other tests pass. The tests pass on my machine except with valgrind, as I explained earlier. |
FYI On my side I get: |
Thanks for the changes.
That is interesting, any reason why it would not work on IPv6? Because it seems that no notifications are being received.
No problem, me neither, actually. |
57f2ad4
to
e043020
Compare
Ok so the udp collector has also 127.0.0.1 local address in the test. |
I have tested the latest changes and this is the test output
but to get there several fixes were required. I have changed the subscription to configuration changes to support failing with an error because that is what had been happening to me but the error was ignored. I have fixed the error, though, but I think it will be better this way. Question is whether not to remove Next, I did some refactoring and additional error checking. The latter could definitely use some improvements so that all the callbacks return proper error to the client and ideally print it as well. Naturally, no errors should be ignored either, so please fix all that. I tried to look at the current problem but the tests need some work before they can be nicely debugged. But I did notice that there was still a timer thread running in the server so there is likely a problem with stopping the subscriptions. Also, the tests must be independent of each other, each must pass separately, and not rely on any particular setup (the error I had before in the 8th test was caused by some missing data in sysrepo). Finally, some more refactoring would be nice, to use |
Thank you for the feedback. However, regarding the timer_helper_thread, Isn't it normal to have this timer thread running. Maybe it is due to the implementation of timer_* functions? |
Okay, you have looked at it more than I have, seems fine then. |
e043020
to
5a1eada
Compare
Hi, I added the missing return codes and logs, so no error is ignored anymore. CMakeLists.txt is also updated. Thus we can use a custom udp-notif-c-collector library. |
What exactly means "not working"? The only difference it could make is that when the callback is called, some module locks are still held and can potentially block API calls you make from the callback. The other being the ability to return a proper error. So, I wanted to test this but it is not even possible to compile, you left out some final changes of a test
I have tried to fix it the way I thought was intended but it did not work, so please finish it. |
5a1eada
to
1832680
Compare
Sorry, it seems I made some mistakes. |
3d4aea3
to
b9907d9
Compare
When I try to run all the tests, they get stuck at the |
When running all the tests, this is the output: 15/37 Testing: test_configured_subscriptions
|
Well, yes, my output is the same and like I said, this is not okay despite the print that all the tests passed. The following module removal must not time out and instead succeed. So there are still some lock problems, please fix them, with some basic information I provided in my previous reply. As for the listener leaks, please remove it then, in the teardown or wherever, the tests need to pass with |
b9907d9
to
e33cd6b
Compare
Ok, I replaced the collector code by simpler udp socket code.
|
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.
Okay, thanks, it seems to be functional now so there are just some less serious problems in this PR to fix before it can be merged.
CMakeLists.txt
Outdated
if (NOT UDP_NOTIF_BIN) | ||
set(BUILD_UDP_NOTIF yes) |
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 do not really understand the logic of these variables, are they even required? Is this feature supposed to be optional? If so, the variable is supposed to be with the options at the beginning. In any case, please simplify this and do not use redundant variables. If you are trying to implement caching of this external project (not sure if needed, I think cmake
can handle that on its own), using UDP_NOTIF_STATIC_LIB
and UDP_NOTIF_INCLUDES
should be enough.
goto cleanup; | ||
} | ||
|
||
message->buffer = string_notification; | ||
message->buffer_len = strlen(string_notification); | ||
message->buffer_len = strlen(message->buffer); |
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.
Minor improvement, the message length is returned by asprintf()
so it saves you this strlen()
call.
free(string_notification); | ||
|
||
ATOMIC_INC_RELAXED(sub->sent_count); | ||
free(message->buffer); |
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 would prefer for this to be in the cleanup, with condition if (message) ...
. Occurs at several places.
|
||
receiver->udp.sender = unyte_start_sender(&receiver->udp.options); | ||
if (!receiver->udp.sender) { | ||
ERR("Cannot create udp sender\n"); |
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.
Redundant \n
, always appended. Every message should, in general, start with a capital, end with a period and ideally provide error cause if possible (such as strerror(errno)
for standard functions, not sure if that is possible here).
@@ -601,22 +839,25 @@ csn_config_sub_receivers_prepare(const struct lyd_node *node_receiver, | |||
|
|||
receiver.name = strdup(lyd_get_value(node_receiver_name)); | |||
if (!receiver.name) { | |||
rc = SR_ERR_NO_MEMORY; | |||
EMEM; | |||
csn_receiver_destroy(&receiver, 0); |
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.
Seems you can put this into the cleanup with condition if (rc) ...
and save this call in all following error conditions.
if (strstr(request_xpath, "subscriptions/subscription[") && | ||
strstr(request_xpath, "/receivers/receiver[")) { |
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 really part of this PR but this is wrong, the request_path
can be, for example, /*
and then you should provide all the data including the receivers. You should, instead, subscribe np2srv_oper_sub_ntf_receivers_cb()
separately for its own nested subtree. Sysrepo will handle this correctly and call np2srv_oper_sub_ntf_subscriptions_cb()
before np2srv_oper_sub_ntf_receivers_cb()
as needed.
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 am not sure how to solve this one.
During the tests I see that np2srv_oper_sub_ntf_subscriptions_cb()
can give the operational data of everything in /subscriptions.
However when doing the reset action on a receiver, sysrepo calls the operational callback and does not accept the complete operational data. But only the receiver operational data.
That's why I used this call to np2srv_oper_sub_ntf_receivers_cb() in this case.
What should np2srv_oper_sub_ntf_receivers_cb() do when it is called with request_xpath "/subscriptions" "or "/*" ?
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.
Okay, so I have finally looked more into the changes you made and actually understood at least the config/oper data. Frankly, the current relevant code is a mess and will need major improvements, so a long description of the changes is following.
The data tree /ietf-subscribed-notifications:subscriptions/subscription
is supposed to hold information about both dynamic and configured subscriptions. Since there were only dynamic subscriptions before, I have implemented it only as operational data since they were based on RPC calls and not configuration data. However, that has changed with the configured subscriptions. Here is how I would put all this together:
- create a new config subscription (
sr_module_change_subscribe()
) for the whole subtree (you have implemented this in the callbacknp2srv_config_subscriptions_cb()
) - create a new config subscription for the receivers (your callback
np2srv_config_subscriptions_receivers_cb()
) - create a new oper subscription to populate the state data in
/ietf-subscribed-notifications:subscriptions/subscription
for configured subscriptions- there are several ways of doing this, either subscribe for providing
/ietf-subscribed-notifications:subscriptions
(the callback will be called once) and create all the state data or subscribe to/ietf-subscribed-notifications:subscriptions/subscription
(will be called for each configured subscription) and in the callback create data only for the specific subscription - use
SR_SUBSCR_OPER_MERGE
to only merge these data to the configuration data
- there are several ways of doing this, either subscribe for providing
- create a new config subscription for
/ietf-subscribed-notifications:subscriptions/ietf-subscribed-notif-receivers:receiver-instances
and store the data in internal structures (your callbacknp2srv_config_receivers_cb()
) - keep the oper subscription for
/ietf-subscribed-notifications:subscriptions
that creates the data for dynamic subscriptions exactly as it was but they should be merged (flagSR_SUBSCR_OPER_MERGE
) to the data of the configured subscriptions - regarding the internal structures holding all the information, it may make sense to completely separate dynamic and configured subscriptions because they are quite different, obviously
If you have any additional questions, we may schedule a call and talk about the design in detail.
e33cd6b
to
3cd54aa
Compare
Thanks for your last answer. I fixed the code according to the previous comments. |
An important update. After some discussion with @jktjkt it has been decided that no notification subscriptions will be supported directly by netopeer2 and instead implemented by a new daemon
The relevant consequence of this for you is that once the daemon is finished, this is my idea of how UDP notifications will work. There will be a separate project implementing a "UDP server" (can even be hosted by 6wind directly and netopeer2 will mention a link) that will install all its YANG modules for configured subscriptions/UDP transport on its own into sysrepo. Then, it will handle any configuration changes in the modules and send a specific RPC that will create a new subscription to So, it is up to you to decide what you want to do in the meantime. The last changes we talked about are no longer relevant since it will all be in a separate project but most of the functionality you implemented will still be used. I should start the implementation of |
3cd54aa
to
c1fd0fd
Compare
Ok, I used SR_SUBSCR_OPER_MERGE and I kept only one oper callback for the moment. |
c1fd0fd
to
714c9ec
Compare
refactor configured subscriptions functions: csn_send_notif_one to send to one specific receiver. new csn_build_notification function to create a unyte messages. Send subscription-started and subscription-terminated. Increment sent_count on each message.
Add missing return code. Add missing function description. Rename some functions.
ad96ecc
to
b83e4a0
Compare
Hi, |
I have made a fair progress with But I can mention some relevant information that is unlikely to change now. To use |
Thanks for the update.
Any particular reason for a YANG-level RPC here, and for a pipe that's visible in the filesystem? I would actually prefer a C library call that would just return a FD for reading. That way, there's:
|
The reason being that that is how we designed it before. Also, it would allow for more code being moved to the new daemon (such as operational data reporting) but your worries seem valid and the proposed change should work so I will try to implement it. |
Hello,
Several commits to handle configured subscriptions.
To test this, it was necessary to make manual tests:
Please could you give your feedback?
Many thanks