-
Notifications
You must be signed in to change notification settings - Fork 0
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
IsUserAwakeBeforeShutdown
called shifter and fallback, right away.
#250
Comments
from the logs (removed private information:
|
This is the part of code, responsible for calling the fallback: if self._get_oldest_call_age() >= self.time_before_fallback:
log.debug('Getting phone number of fallback shifter')
numbers_to_call.append(self.phone_number_of_fallback_shifter()) This I found a bug in the function removing old and acknowledged calls: def _remove_acknowledged_and_old_calls(self):
""" from the list of not acknowledged calls
remove all calls, which have been acknowledged on the web page
Also remove calls older than 2 hours, to get out of
a "call the backup shifter" dead lock
"""
alerts = {a['uuid']: a for a in get_alerts()}
if not alerts:
return
for msg in copy(self.not_acknowledged_messages):
age = datetime.datetime.utcnow() - msg.timestamp
if age > (self.max_time_for_fallback + self.time_before_fallback):
self.not_acknowledged_messages.remove(msg)
else:
try:
alert = alerts[str(msg.uuid)]
except KeyError:
continue
if alert['acknowledged'] is True:
self.not_acknowledged_messages.remove(msg) It says: When you cannot get any alerts from the website ... return. So it does not even try to remove too-old alerts, when it cannot find out what was acknoledged. This function is doing to independent things... and if the one thing is impossible, it does not even try the other idenpendent thing. That is of course a bug. I think, I might have recently introduced this bug .. let me see. |
Ah the reason, why it showed up today was: Normally there is at least one alert in the list of alerts ... the dummy-alert from the start-up checklist. But today this dummy alert was not in the list. Either the shifter did not try it. Or it did not work. Either way ... the shifter should at least have it reported in the log-book. If not having called one of the SH expert in the evening, because if the dummy alert is not working, this is serious. ... Well ... this error (not doing the dummy-alert) ... made us realize this bug. ... so it was a good thing in the end. |
The fix is easy: instead of alerts = {a['uuid']: a for a in get_alerts()}
if not alerts:
return we just need: alerts = {a['uuid']: a for a in get_alerts()} alerts will be an empty dict now and the code below is fine with an empty set of alerts... |
We are running the shifthelper_heartbeat branch at the moment and indeed I edited this part ... but the same behaviour (returning, instead of carrying on with an empty set of alerts) was already there before my edit .. so it wasnt me :-D But I should have seen that (embarrassed) |
I just removed this `if not alerts: return` part. but I though this function doing two things ... was part of the problem so I took it apart.
This morning, SH called 20min before shutdown, because nobody was awake. so far so good.
But it called the fallback immediately and not after 15 minutes.
I do not know why.
The text was updated successfully, but these errors were encountered: