Skip to content
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

Persist observe: Support tracking observe information over server restarts #1019

Merged
merged 1 commit into from
Apr 22, 2023

Conversation

mrdeep1
Copy link
Collaborator

@mrdeep1 mrdeep1 commented Feb 1, 2023

Add in optional callbacks for when observe subscriptions start and stop.

Add in optional callbacks for when the observe counter is updated (can be ratelimited) for a resource as well as track when a resource is deleted.

Add is support for new functions

coap_persist_observe() for server to add in tracked observe information.

coap_resource_set_observe_num() to update observe counter from tracked information.

coap_observe_track() to define the optional callback functions.

coap-server has -t option to track observe information (most of the code updates).

UDP sessions supported, as well as OSCORE over UDP.

Documentation updated

@mrdeep1 mrdeep1 force-pushed the persistent_observe branch 2 times, most recently from 1b89eef to d702c7b Compare February 1, 2023 13:10
@mrdeep1 mrdeep1 mentioned this pull request Feb 1, 2023
@mrdeep1 mrdeep1 force-pushed the persistent_observe branch 3 times, most recently from 770ea62 to ec49b80 Compare February 10, 2023 10:51
@mrdeep1 mrdeep1 force-pushed the persistent_observe branch 2 times, most recently from e5b6f2b to 6f8bf32 Compare March 2, 2023 16:43
@mkovatsc
Copy link

Dear @mrdeep1
Thanks again for realizing this so quickly -- the more I am sorry for coming back this late! Neither of the two development teams that have the integration of this in their backlog were able to schedule the task in a sprint so far. Hence, I used some time at the IETF Hackathon to test it out myself and start with feedback.

The basic mechanism is working well! I only noticed the automatic 4.04 still being sent when the server is shut down gracefully (e.g., Ctrl+c). It still resumes the notifications after the 4.04. I think it should be either a full shutdown with 4.04 and no resume or an intentional restart/hibernate without 4.04 and resume. I still need to think some more about this.

Now that I have the basic setup working, I will try to test and review some more. Please bear with me and just leave this PR open :)

@mrdeep1
Copy link
Collaborator Author

mrdeep1 commented Mar 26, 2023

Thanks for doing the testing so far - much appreciated. I did not really think through the 4.04 "issue. As I see it

  1. Server shuts down and does not immediately restart
  2. Server does a clean shutdown and is shortly restarted
  3. Server does an unclean shutdown and is then restarted

For 1), 4.04 should be sent out (RFC7641 is a SHOULD for when the resource is deleted) RFC7641 4.2.

For 2) the 4.04 should not be sent out.

For 3) nothing is expected to be sent out unless 2) failed part way doing the shutdown.

To differentiate between 1) and 2), perhaps 1) could continue using SIGTERM, but 2) could use SIGUSR2 (SIGUSR1 is planned for something else). Then the SIGUSR2 handler could call a new function - say - coap_observe_no_clear_down() which causes the 4.04 to not get sent out. Work for you?

I separately was thinking it made sense to move the current server application's tracking code into libcoap (enabled as a configurable option) but still provide coap_observe_track() should the application was to do its own database tracking. What do you think?

@mrdeep1 mrdeep1 force-pushed the persistent_observe branch from 6f8bf32 to f9857e4 Compare March 26, 2023 17:56
@mrdeep1
Copy link
Collaborator Author

mrdeep1 commented Mar 26, 2023

Added in coap_observe_no_clear_down() and SIGUSR2 support in coap-server for not sending out 4.04 for active observations when closing coap-server down.

@mrdeep1 mrdeep1 force-pushed the persistent_observe branch from f9857e4 to 2816004 Compare April 8, 2023 15:06
@mrdeep1
Copy link
Collaborator Author

mrdeep1 commented Apr 8, 2023

@mkovatsc I have moved most of the application persist logic into the libcoap logic (configurable to enable it, by default enabled) so that only 2 functions need to be called within the application - coap_persist_startup() and coap_persist_stop() if you want to maintain the persist information if the server is cleanly shutdown.

Application persist callbacks are still available if required (support always available), but there has been some parameter updates (and some function name changes).

Any feedback welcome.

@mrdeep1 mrdeep1 force-pushed the persistent_observe branch 2 times, most recently from 974d125 to 16927de Compare April 10, 2023 14:38
@mrdeep1 mrdeep1 force-pushed the persistent_observe branch from 16927de to 32ac413 Compare April 13, 2023 09:27
Add in optional callbacks for when dynamic resources are setup and deleted.

Add in optional callbacks for when observe subscriptions start and stop.

Add in optional callbacks for when the observe counter is updated (can be
ratelimited) for a resource as well as track when a resource is deleted.

Add is support for new functions

Main functions with libcoap tracking support are
 coap_persist_startup()
 coap_persist_stop()

coap-server has -t option to track observe information.

UDP sessions supported, as well as OSCORE over UDP.

Documentation updated

libcoap tracking support (as opposed to application tracking) is configurable.
@mrdeep1 mrdeep1 force-pushed the persistent_observe branch from 32ac413 to 6e78c5b Compare April 22, 2023 10:02
@mrdeep1 mrdeep1 merged commit ca609d2 into obgm:develop Apr 22, 2023
@mrdeep1 mrdeep1 deleted the persistent_observe branch April 22, 2023 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants