Task #2430
closedKeep Worker model records around instead of deleting them
100%
Description
Currently Pulp worker DB records are deleted when workers go missing or are shut down, and created when they are first observed or updated. It would be beneficial to keep these records. This allows someone to read these records post-mortem. It has a tertiary benefit that Tasks won't be cascade deleted due to the Worker objects being removed.
To resolve this, introduce a boolean named 'online' on the Worker model. The code in pulp_celerybeat that manages these Worker records would be updated to set the 'online' value when workers start and stop. The field's default should correspond with its usage.
Currently on 3.0-dev the pulp_celerybeat code all lives inside of here[0].
[0]: https://github.com/pulp/pulp/blob/3.0-dev/platform/pulp/tasking/services/worker_watcher.py
Updated by mhrivnak about 8 years ago
This may require us to re-think the uniqueness constraint. I suspect the tasking system will want to continue having an easy way to guarantee that there's only one active worker at a time with a given name.
Perhaps we could add a field that's a timestamp for when the worker was "archived", let that field be null, and make that field plus the "name" be unique together? That would allow just one non-archived worker, and any number of archived ones.
Updated by bmbouter about 8 years ago
I was imagining we would keep the existing uniqueness constraint[0], and when pulp_celerybeat brings a worker online and there is an existing record in the db, it would update(online=True, last_heartbeat=<now>)
I do think we want to "reuse" worker records because we want to aggregate all Task foreign keys onto the same Worker instance by name. Otherwise when we use worker.tasks
we will only be getting the tasks for the most recent instance which is generally not what we want when we write that code. To then get the full list you would have to aggregate all Tasks that have a foreign key to a worker whose name=<someworkername>. Given ^ just reusing the same worker instance would allow us to sidestep this aggregation issue completely.
Updated by mhrivnak over 7 years ago
- Description updated (diff)
- Groomed changed from No to Yes
Updated by fdobrovo over 7 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to fdobrovo
Updated by fdobrovo over 7 years ago
- Status changed from ASSIGNED to POST
Added by fdobrovo over 7 years ago
Added by fdobrovo over 7 years ago
Revision e6e6e06f | View on GitHub
Keep workers records when they gone offline
Updated by fdobrovo over 7 years ago
- Status changed from POST to MODIFIED
- % Done changed from 0 to 100
Applied in changeset pulp|e6e6e06fa4f9ee2003640c3fe26e0c41658868a9.
Updated by bmbouter about 5 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Keep workers records when they gone offline
closes #2430 https://pulp.plan.io/issues/2430