fact-project / shifthelper

So we can sleep at night.
4 stars 0 forks source link

What happens, when e.g. the `calendar.Data` Table is not there? #242

Closed dneise closed 7 years ago

dneise commented 7 years ago

This is a question that came up in a discussion here and since I wasn't able to answer it right from the top of my head... I thought I should write it down.

So what's the problem?

The db_cloner wants to clone a Table, like here for example https://github.com/fact-project/shifthelper/blob/master/shifthelper/db_cloner/__main__.py#L16

say the table is ... I don't know ... it was deleted .. and will never come back. So it will log the exception ... but that's all...

What will happen to the SH?

dneise commented 7 years ago

I try to answer it myself.

Tow cases:

A

Say the SH was just freshly started on a new host. Then the db_cloner logs the exception and the calendar_data table will not exist in the cloned DB. So this query https://github.com/fact-project/shifthelper/blob/master/shifthelper/tools/shift.py#L73 will raise an exception which will bubble up to the SH expert.

B

The SH is already running since some time and suddenly the DB goes away. The DB cloner will log the exception (which nobody reads) ... and the query above will work. But the result will be empty. Since the cloning stopped working some time ago, one day the question "who is on shift tonight" will come up blank, since in the cloned DB there was nobody entered for that day.

And then this line: https://github.com/fact-project/shifthelper/blob/master/shifthelper/tools/shift.py#L30

Will throw an exception, since the iloc[0] does not work for an empty result.

So also in this case we will be notified.


Summing it up:

When the cloning does not work, because the remote DB went away ... we do not immediately get a notification. But once the cloned DB content turns up empty, we will be notified.

Due to the ShifterOnShift Check, we will get notified immediately when the query comes up blank.