Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create utility to render and store transactional snapshot of simple detail page for a project #8586

Merged
merged 19 commits into from
Feb 2, 2022

Conversation

ewdurbin
Copy link
Member

@ewdurbin ewdurbin commented Sep 18, 2020

Needed for #8487.

Exposes packaging.utils.render_simple_detail for use in TUF integration.

def render_simple_detail(project, request, store=False):

Returns (content_hash, simple_detail_path)

The store flag can be used to control wether the resulting rendered/hashed simple detail page is pushed to our storage service.

@ewdurbin ewdurbin force-pushed the render_and_hash_simple_detail branch from b4f35ca to b967eba Compare September 18, 2020 21:03
@ewdurbin ewdurbin force-pushed the render_and_hash_simple_detail branch from b967eba to 581e20e Compare January 12, 2021 16:14
Base automatically changed from master to main January 21, 2021 18:39
@ewdurbin ewdurbin force-pushed the render_and_hash_simple_detail branch from 581e20e to c76e4e7 Compare February 9, 2021 17:48
@ewdurbin ewdurbin force-pushed the render_and_hash_simple_detail branch from c76e4e7 to 3745775 Compare February 23, 2021 16:14
@ewdurbin ewdurbin force-pushed the render_and_hash_simple_detail branch from b142122 to 27e862a Compare March 8, 2021 17:09
@ewdurbin ewdurbin force-pushed the render_and_hash_simple_detail branch from 27e862a to 1c16dbe Compare March 23, 2021 14:10
@ewdurbin
Copy link
Member Author

@di can I get a review and sanity check here before I go about implementing tests?

@ewdurbin
Copy link
Member Author

cc @woodruffw

@ewdurbin ewdurbin force-pushed the render_and_hash_simple_detail branch from 1c16dbe to 33a7b76 Compare March 23, 2021 14:57
@ewdurbin ewdurbin requested a review from di March 23, 2021 15:09
Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

LGTM! One tiny question about when simple detail files are being stored 🙂

@ewdurbin ewdurbin force-pushed the render_and_hash_simple_detail branch from 33a7b76 to 2de0757 Compare April 29, 2021 14:06
@ewdurbin ewdurbin marked this pull request as ready for review August 25, 2021 16:24
@ewdurbin
Copy link
Member Author

Ready for review @di and @woodruffw.

Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

LGTM!

warehouse/packaging/utils.py Outdated Show resolved Hide resolved
warehouse/packaging/utils.py Outdated Show resolved Hide resolved
warehouse/packaging/utils.py Show resolved Hide resolved
},
)

return (content_hash, simple_detail_path)
Copy link
Member

Choose a reason for hiding this comment

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

Should we return content here instead, so the endpoint can directly render the simple page rather than having to fetch it from storage?

Copy link
Member Author

Choose a reason for hiding this comment

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

Initially, this is implemented so that we render simple detail pages in the same way that we currently do and this utility is available for TUF.

We'll need some transition plan before we start serving simple pages directly from object storage... which I consider material for a follow on PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also as is, we don't ever fetch back simple pages from storage from warehouse.

Copy link
Member

Choose a reason for hiding this comment

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

Also as is, we don't ever fetch back simple pages from storage from warehouse.

Should we ever? Serving the request (and storing the rendered & hashed detail page) should happen every time cache is purged and a request hits the backend. The worse case is that we occasionally overwrite an existing file with itself.

For the hashed pages, we would need to serve those from storage of course.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍🏼

@ewdurbin
Copy link
Member Author

I'm not sure what the best next step is for this PR.

It seems we have two concerns at play in review:

  • Exposing the necessary utility for TUF
  • Establishing the full simple index in object storage

Initially this work is intended to provide only the first outcome, to unblock TUF integration into warehouse.

For the TUF concern, there appears to only be a decision regarding path names for files stored in the object store.

For the second one, I think we need the following:

  1. Matching renderer for the simple_index view, and perhaps an hourly job to render and purge its cache?
  2. A tool to backfill/regenerate simple indexes for all projects.
  3. Some plan to transition

@ewdurbin ewdurbin force-pushed the render_and_hash_simple_detail branch from 52635fd to 7a94d77 Compare November 9, 2021 14:32
Copy link
Contributor

@kairoaraujo kairoaraujo left a comment

Choose a reason for hiding this comment

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

I am working on the following implementation PR on top of this PR (related to PEP 458, TUF).
I noticed that the simple HTML files generated by render_simple_details are empty (see my comment on warehouse/packaging/utils).

warehouse/packaging/services.py Outdated Show resolved Hide resolved
warehouse/packaging/utils.py Show resolved Hide resolved
@di di force-pushed the render_and_hash_simple_detail branch from 7a94d77 to a5c60e0 Compare February 1, 2022 16:07
@di di mentioned this pull request Feb 1, 2022
52 tasks
Copy link
Member Author

@ewdurbin ewdurbin left a comment

Choose a reason for hiding this comment

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

I think this is good to go, it puts in place the mechanism for TUF to invoke render_simple_detail and get the hash/path for signing/service.

For now we'll remove serving all simple pages from storage from scope, and get this merged so TUF work can proceed when contributors are ready.

I'll merge this after configuring the new SIMPLE_BACKEND for test.pypi.org/pypi.org.

@ewdurbin ewdurbin merged commit f116534 into main Feb 2, 2022
@ewdurbin ewdurbin deleted the render_and_hash_simple_detail branch February 2, 2022 18:13
@di di mentioned this pull request Feb 2, 2022
kairoaraujo pushed a commit to kairoaraujo/warehouse that referenced this pull request Feb 4, 2022
This commit enables the simple hash project index during the project
upload file. This change will store the simple storage with the
project hash index for new project uploads.

This PR is a follow-up on PR pypi#8586, where it uses in the legacy file
upload the render simple details as part of PEP 458.

Signed-off-by: Kairo de Araujo <[email protected]>
domdfcoding pushed a commit to domdfcoding/warehouse that referenced this pull request Jun 7, 2022
…etail page for a project (pypi#8586)

* helper function to render and hash simple detail for a specific project

* use the existing Jinja2 environment

* file storage

* format with black

* store hashed project indexes at `/simple/<HASH>.<PROJECT_NAME>` as discussed

also store unhashed index as normal

* add 'simple.backend' config for tests

* add a jinja renderer to pyramid_request fixture

* restore tests for existing functionality

* test new SimpleStorage services

* license

* test render_simple_index utility

* Update warehouse/packaging/utils.py

* Update warehouse/packaging/utils.py

* fix tests, store last serial information on metadata of simple files

* reformat/lint

* Remove print statement

* Add flush

* Fix tests

* Simpflify duplication in storage services

Co-authored-by: Dustin Ingram <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants