Dont update if same (#64)

* Return status as integer

During the first start the if statement on line 237 does not get evaluated correctly and will not "return"
Therefore by any restart the first evaluation triggers a update even if the original status is same.

* Prevent unecessery push

By a case where allowed_fails > 0 and one failure is received the url monitor pushes a unnecessary update as the component state was not changed, resulting in a notification of "component is operational", but in fact the component was still operation before the update.

This creates another api call (get) towards the cachet, but it is a better trade-off to prevent unnecessary notifications for end-users.
This commit is contained in:
mazhead
2019-04-04 17:44:34 +02:00
committed by mtakaki
parent 9569818bb0
commit a296cfc1aa

View File

@@ -241,6 +241,11 @@ class Configuration(object):
if not self.trigger_update:
return
self.api_component_status = get_current_status(self.api_url, self.component_id, self.headers)
if self.status == self.api_component_status:
return
params = {'id': self.component_id, 'status': self.status}
component_request = requests.put('%s/components/%d' % (self.api_url, self.component_id), params=params,
headers=self.headers)