Introduce Worker.last_seen, worker's last communication with hub #156
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit introduces a new attribute, last_seen, onto the Worker
model used by hub. This field contains the timestamp for the worker's
last XML-RPC call to hub and is kept up-to-date automatically.
It is accessible from 'export', which means it appears in the responses
to get_worker_info method.
The motivation is to improve our ability to monitor workers.
Prior to this, no attributes on the model can be used to reliably
determine whether a worker is alive, or even whether it truly exists.
For example, a worker can have enabled=True, ready=True even if it
uses a nonexistent hostname.
The time at which a worker last called the hub is a useful signal to
determine whether workers are alive, so let's start tracking it.
Note that the way this is implemented is quite different from how it
would be in other circumstances. In particular, if this were implemented
when the model was originally defined, it'd just be another column
in the DB. The problem with doing this now is that the last DB schema
change was ~5 years ago and I doubt that most kobo-using services have a
process in place for running migrations around upgrades. I know this is
true at least for Pub.
For that reason, the info is maintained using 0-byte state files. This
is expected to be compatible with all environments without requiring
migrations.