Issue #2768
closed
Worker foreign key does not get associated with task in Pulp3
Status:
CLOSED - CURRENTRELEASE
- Subject changed from Worker foreign key does not get associated with task to Worker foreign key does not get associated with task in Pulp3
- Description updated (diff)
- Sprint/Milestone set to 39
- Groomed changed from No to Yes
- Description updated (diff)
- Triaged changed from No to Yes
- Groomed changed from Yes to No
- 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
- Sprint/Milestone set to 39
- Status changed from NEW to ASSIGNED
- Assignee set to dalley
- Description updated (diff)
- Description updated (diff)
- Description updated (diff)
- Sprint/Milestone changed from 39 to 40
- 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})
- Status changed from POST to MODIFIED
- Sprint/Milestone deleted (
40)
- Sprint/Milestone set to 3.0.0
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Also available in: Atom
PDF
Associate worker foreign key with task
Ensure the worker field on the Task model gets populated.
closes #2768 https://pulp.plan.io/issues/2768