Skip to content

Add support for adding pull-through content to associated repositories#6224

Merged
gerrod3 merged 2 commits intopulp:mainfrom
gerrod3:pull-through-repo-add
Mar 18, 2025
Merged

Add support for adding pull-through content to associated repositories#6224
gerrod3 merged 2 commits intopulp:mainfrom
gerrod3:pull-through-repo-add

Conversation

@gerrod3
Copy link
Copy Markdown
Contributor

@gerrod3 gerrod3 commented Jan 23, 2025

No description provided.

Comment thread pulpcore/content/handler.py Outdated
log.info(f"RemoteArtifact for {url} already exists.")
if ca.relative_path == content_artifact.relative_path:
# Side effect used by pull-through-caching in _stream_remote_artifact
remote_artifact.content_artifact = ca
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the question, why we should rename the variable in the first place, does remote_artifact exist here?
Also should we save "content_artifact" on the model when we set it? Maybe the comment is missing some nasty details to understand the codeflow here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remote_artifact exists in the method definition.

I don't understand your second question, but I am wondering if I even need to use a side-effect to get the newly saved content_artifact for the pull-through method. This is a private method and searching through the code-base no one uses this method besides the content app, so maybe I can just change the return type to a dictionary of all the newly created objects.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So content_artifact isn't even a field on the remote_artifact?
But yes the returning the proper stuff sounds better.
So sad that with python it's usually hard to guess what is a private and what a public interface...

@gerrod3 gerrod3 force-pushed the pull-through-repo-add branch from 57606c3 to 3118fc1 Compare February 26, 2025 04:54
Comment on lines +22 to +29
@middleware
async def guid(request, handler):
"""Sets the django_guid for each request."""
set_guid(generate_guid())
return await handler(request)


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like a good change in general. Maybe that's a different story, but should we look for the cid header in the request to allow following correlations even through content access?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe yeah, we would also need to expose the value to be used in logging for the content app, currently this change is solely to allow for dispatching tasks from the content app.

@gerrod3 gerrod3 force-pushed the pull-through-repo-add branch from 3118fc1 to 1c41bb0 Compare February 26, 2025 16:01
@gerrod3 gerrod3 force-pushed the pull-through-repo-add branch 3 times, most recently from d0a7252 to 7f995ef Compare March 6, 2025 20:30
mdellweg
mdellweg previously approved these changes Mar 7, 2025
Comment on lines +497 to +501
finally:
await content.adelete()
await repo.adelete()
await remote.adelete()
await distro.adelete()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need that... Django unittests usually run in a transaction that never gets committed.

@gerrod3 gerrod3 merged commit 4e7b339 into pulp:main Mar 18, 2025
@gerrod3 gerrod3 deleted the pull-through-repo-add branch March 18, 2025 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow plugins to automatically add pull-through content to repositories

2 participants