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

Subscripton status "failed" is a crafted (not real in DB/cache) status #3989

Closed
fgalan opened this issue Nov 4, 2021 · 8 comments
Closed
Milestone

Comments

@fgalan
Copy link
Member

fgalan commented Nov 4, 2021

Currently we have this in Subscrpition::toJson() rendering logic:

  if ((this->notification.lastFailure > 0) && (this->notification.lastFailure > this->notification.lastSuccess))
  {
    jh.addString("status", "failed");
  }
  else
  {
    jh.addString("status", this->status);
  }

Thus, failed is not a real status coming from csubs document/cache.

This is a bit weird, but I'm not sure which should be do. Some alternatives:

  1. Store failed in DB/cache as any other status (active, inactive, etc.). That would simplify the rendering logic in Subscription::toJson() but involve dealing with seting failed in the proper place (in the code dealing with notification fails). Another more difficult to solve problem of "conceptual" kind is how to deal with some status transition situation, e.g. a subscription that is in failed status can be changed to active taking into account we don't have information about if the situation that make it to fail has disappeared?
  2. Considering failed/ok condition as orthogonal to active/inactive condition, it could be an extra field, e.g. "failed": true|false. Thus, "status": "active", "failed": true will clearly identify that a subscription is active (i.e. updates will trigger notifications) and, at the same time, last notification caused a fail.
  3. Remove status failed at all. The user may infer if the subscription is failling or not based in lastNotification/lastFailure/lastSuccess information, basically doing himself the same checking we currently have in the if-clause above.

Feedback welcome! :)

@fgalan
Copy link
Member Author

fgalan commented Nov 4, 2021

Moreover, the this->notification.lastFailure > this->notification.lastSuccess condition is weak as two notifications coud be sent in the same second (first one successfu, second one failing) and the status will end in "active" instead of "failed"

@mapedraza
Copy link
Collaborator

mapedraza commented Nov 4, 2021

IMHO failed/ok condition is totally orthogonal to active/inactive condition. For example, if notification pass to inactive after several times trying to send the notification as proposed in #3962, It is needed to know about the status of the subscription (inactive) and also about the status of the notification (failed), to identify the real situation.

If the condition this->notification.lastFailure > this->notification.lastSuccess is going to be always valid for a failing notification, maybe adding millisecond support to this parameters could be sufficient to solve this situation, and for sure is easier to maintain and implement.

@fgalan
Copy link
Member Author

fgalan commented Nov 4, 2021

If the condition this->notification.lastFailure > this->notification.lastSuccess is going to be always valid for a failing notification, maybe adding millisecond support to this parameters could be sufficient to solve this situation, and for sure is easier to maintain and implement.

Using milliseconds for lastNotification/lastFailure/lastSuccess has been considered in issue #3671

@fgalan
Copy link
Member Author

fgalan commented Nov 4, 2021

IMHO failed/ok condition is totally orthogonal to active/inactive condition. For example, if notification pass to inactive after several times trying to send the notification as proposed in #3962, It is needed to know about the status of the subscription (inactive) and also about the status of the notification (failed), to identify the real situation.

So +1 to option 2 I guess :)

@fgalan
Copy link
Member Author

fgalan commented Nov 10, 2021

Note that failed is one of the status defined in the NGSIv2 specification (http://telefonicaid.github.io/fiware-orion/api/v2/stable/)

imagen

So if we go for option 2 or 3 we have to take this into consideration (eg. documenting this deviation from the spec)

@fgalan
Copy link
Member Author

fgalan commented Nov 10, 2021

The description of status in doc/manuals/admin/database_model.md could need to be fixed depending on how this issue gets solved:

  • status: either active (for active subscriptions), inactive (for inactive subscriptions) or
    oneshot (for oneshot subscriptions). Note that NGSIv2 API consider additional states (e.g. failed or expired)
    but they never hit the DB (they are managed by Orion).

@fgalan
Copy link
Member Author

fgalan commented Nov 22, 2021

At the end we are going to implement option 3:

Remove status failed at all. The user may infer if the subscription is failling or not based in lastNotification/lastFailure/lastSuccess information, basically doing himself the same checking we currently have in the if-clause above.

At the same can be achieved just checking new field failsCounter is greater than 0

@fgalan
Copy link
Member Author

fgalan commented Nov 23, 2021

PR #4006

@fgalan fgalan closed this as completed Nov 23, 2021
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

No branches or pull requests

2 participants