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

Before sending notification verifying no changes in alert for sometime #178

Merged
merged 3 commits into from
Jun 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions tendrl/notifier/notification/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from abc import abstractmethod
from datetime import datetime
from dateutil import parser
import importlib
import json
import os
Expand All @@ -14,6 +16,8 @@
from tendrl.notifier.utils.central_store_util import update_alert_delivery
from tendrl.notifier.utils.util import list_modules_in_package_path

CLEARING_ALERT = "INFO"


class PluginMount(type):

Expand Down Expand Up @@ -124,6 +128,13 @@ def run(self):
lock = None
alerts = get_alerts()
for alert in alerts:
if alert.severity == CLEARING_ALERT:
if (datetime.utcnow() - parser.parse(
alert.time_stamp
).replace(tzinfo=None)).seconds < 120:
# If alert is info then wait for 120 sec
# to confirm no changes in alert severity
continue
alert.tags = json.loads(alert.tags)
if str(alert.delivered).lower() == "false":
lock = etcd.Lock(
Expand All @@ -146,6 +157,7 @@ def run(self):
SyntaxError,
ValueError,
KeyError,
TypeError,
etcd.EtcdException
)as ex:
Event(
Expand Down