Skip to content

Task diagnostic/profile artifacts are stored in the default domain, not the task's domain #8401

Done

Description

@dkliban

Problem

When a task runs in a non-default domain and task diagnostics are enabled (TASK_DIAGNOSTICS / the X-Task-Diagnostics header), the resulting profile artifacts are created without the task's domain context, so they are stored in the default domain instead of the task's pulp_domain.

Where

pulpcore/tasking/_util.py — the diagnostic decorators create the Artifact and ProfileArtifact outside any with_domain(...) context:

  • _memory_diagnostic_decorator (memory_profile)
  • _pyinstrument_diagnostic_decorator (pyinstrument_profile)
  • _memray_diagnostic_decorator (memray_profile)
  • _logging_decorator (task_logs)

Each does roughly:

artifact = Artifact.init_and_validate(...)
artifact.save()  # on IntegrityError: artifact = Artifact.objects.get(sha256=artifact.sha256)
ProfileArtifact.objects.get_or_create(artifact=artifact, name=..., task=task)

Artifact and ProfileArtifact are domain-scoped, but these run in the worker without the task's domain active, so they land in default. The IntegrityError dedup fallback (Artifact.objects.get(sha256=...)) is also not domain-scoped and can return a different domain's artifact.

Impact

On domain-enabled deployments, profile artifacts for tasks in non-default domains are misfiled in the default domain (and may be cross-domain deduplicated), which affects retrieval via the task profile_artifacts endpoint.

Suggested fix

Wrap each artifact + ProfileArtifact creation in with_domain(task.pulp_domain) (already imported in _util.py) and scope the dedup lookup with pulp_domain=task.pulp_domain.

Version

Confirmed on 3.123.1 and still present on current main (3.125.x).

Note

A downstream deployment (pulp-service) carries a local patch that fixes this for pyinstrument and memray only; a complete upstream fix should also cover memory and task_logs.

🤖 Generated with Claude Code

Activity

  1. added 2 commits that reference this issue on Dec 4, 2026
    c52cf00
    ff751ce
  2. added a commit that references this issue on Dec 4, 2026
    36561ee
  3. added a commit that references this issue on Dec 4, 2026
    57a0552
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions