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

Introduce Worker.last_seen, worker's last communication with hub #156

Merged
merged 1 commit into from
Jul 8, 2021

Conversation

rohanpm
Copy link
Member

@rohanpm rohanpm commented Jul 7, 2021

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.

@coveralls
Copy link

coveralls commented Jul 7, 2021

Pull Request Test Coverage Report for Build 311

  • 24 of 25 (96.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 50.478%

Changes Missing Coverage Covered Lines Changed/Added Lines %
kobo/hub/models.py 19 20 95.0%
Totals Coverage Status
Change from base Build 310: 0.2%
Covered Lines: 3118
Relevant Lines: 6177

💛 - Coveralls

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.
@rohanpm rohanpm marked this pull request as ready for review July 7, 2021 22:21
@rohanpm rohanpm requested review from querti, rbikar and a team July 7, 2021 22:22
@rohanpm rohanpm merged commit d6b2a00 into release-engineering:master Jul 8, 2021
@rohanpm rohanpm deleted the worker-last-seen branch July 8, 2021 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants