Project

Profile

Help

Issue #2768

closed

Worker foreign key does not get associated with task in Pulp3

Added by bizhang over 7 years ago. Updated almost 5 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Sprint 21
Quarter:

Description

When a task is kicked off I would expect it to populate the worker foreign key [0] when the task is ran

I would expect this to be updated in the apply_async function when the Task status object is created [1].
Tasks kicked off with apply_async should have the worker field populated upon creation.
Tasks kicked off with apply_async_with_reservations would have the worker field updated when it gets routed to the worker.

For reference pulp2 updates the field here [2]

[0] https://github.com/pulp/pulp/blob/b3ff9a93bba4af1405f57e907944270b3052668a/platform/pulp/app/models/task.py#L158
[1] https://github.com/pulp/pulp/blob/b3ff9a93bba4af1405f57e907944270b3052668a/platform/pulp/tasking/tasks.py#L243
[2] https://github.com/pulp/pulp/blob/master/server/pulp/server/async/tasks.py#L484

Actions #1

Updated by bizhang over 7 years ago

  • Subject changed from Worker foreign key does not get associated with task to Worker foreign key does not get associated with task in Pulp3
Actions #2

Updated by bizhang over 7 years ago

  • Description updated (diff)
Actions #3

Updated by ttereshc over 7 years ago

  • Sprint/Milestone set to 39
  • Groomed changed from No to Yes
Actions #4

Updated by bizhang over 7 years ago

  • Description updated (diff)
Actions #5

Updated by ttereshc over 7 years ago

  • Triaged changed from No to Yes
  • Groomed changed from Yes to No
Actions #6

Updated by bmbouter over 7 years ago

  • Sprint/Milestone deleted (39)

I thought about this more, and I think this is the patch we need. We should only set the worker in the _queue_reserve_resource task because that is the earliest moment the worker is known and that is the only time in all of Pulp that a task is dispatched to a dedicated worker.

diff --git a/platform/pulp/tasking/tasks.py b/platform/pulp/tasking/tasks.py
index cd0e21b..41c6890 100644
--- a/platform/pulp/tasking/tasks.py
+++ b/platform/pulp/tasking/tasks.py
@@ -87,6 +87,9 @@ def _queue_reserved_task(name, inner_task_id, resource_id, inner_args, inner_kwa
         time.sleep(0.25)

     task_status = TaskStatus.objects.get(pk=inner_task_id)
+    task_status.worker = worker
+    task_status.save()
+
     ReservedResource.objects.create(task=task_status, worker=worker, resource=resource_id)

     inner_kwargs['routing_key'] = worker.name
Actions #7

Updated by bmbouter over 7 years ago

  • Sprint/Milestone set to 39
Actions #8

Updated by bizhang over 7 years ago

https://pulp.plan.io/issues/2768#note-6 would only associate the worker when the task is called with apply_async_with_reservation. This is an issues that also exists in pulp2

As discussed with bmbouter the change should be made in https://github.com/pulp/pulp/blob/b3ff9a93bba4af1405f57e907944270b3052668a/platform/pulp/tasking/tasks.py#L255
Since __call__() is called on the worker itself, worker name should be one of the *args or **kwargs

Actions #9

Updated by dalley over 7 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to dalley
Actions #10

Updated by bizhang over 7 years ago

  • Description updated (diff)
Actions #11

Updated by bizhang over 7 years ago

  • Description updated (diff)
Actions #12

Updated by bizhang over 7 years ago

  • Description updated (diff)
Actions #13

Updated by mhrivnak over 7 years ago

  • Sprint/Milestone changed from 39 to 40
Actions #14

Updated by dalley over 7 years ago

  • Status changed from ASSIGNED to POST

PR is up
https://github.com/pulp/pulp/pull/3054

Commands to test:

from pulpcore.app.tasks import repository
from pulpcore.app.models import Repository
import uuid
repo_uuid=str(uuid.uuid4())
repo=Repository(name=repo_uuid)
repo.save()

repository.delete.apply_async(kwargs={'repo_name':repo_uuid})
repository.delete.apply_async_with_reservation("foo","bar",kwargs={'repo_name':repo_uuid})

Added by dalley over 7 years ago

Revision b00649ec | View on GitHub

Associate worker foreign key with task

Ensure the worker field on the Task model gets populated.

closes #2768 https://pulp.plan.io/issues/2768

Added by dalley over 7 years ago

Revision b00649ec | View on GitHub

Associate worker foreign key with task

Ensure the worker field on the Task model gets populated.

closes #2768 https://pulp.plan.io/issues/2768

Actions #15

Updated by dalley over 7 years ago

  • Status changed from POST to MODIFIED
Actions #16

Updated by bmbouter over 6 years ago

  • Sprint set to Sprint 21
Actions #17

Updated by bmbouter over 6 years ago

  • Sprint/Milestone deleted (40)
Actions #18

Updated by daviddavis over 5 years ago

  • Sprint/Milestone set to 3.0.0
Actions #19

Updated by bmbouter over 5 years ago

  • Tags deleted (Pulp 3)
Actions #20

Updated by bmbouter almost 5 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Also available in: Atom PDF