pulp / pulp/pulpcore

Pulp4 - Improve absolute and relative URL building

Open
#6,239 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature
Dominant language
Python
Stars
598
Forks
168
Avg merge
1d 4h
Merged PRs (30d)
86

Description

This is a discussion issue, not a RFE explicitly. What I've learned is that CONTENT_ORIGIN and the associated machinery to build absolute or relative URIs is in some ways re-solving what Django already solved.

As background, note that Pulp has two situations where code executes 1) in the request + response cycle of django 2) the request + response cycle of aiohttp.server and 3) in tasking. In Pulp3 we've tried to solve the building of absolute URLs for all cases in one go, with one setting, CONTENT_ORIGIN and some custom URL builder functions.

While we can't use Django machinery for aiohttp.server request+response, or in task processing, but consider this core django utility function: https://github.com/django/django/blob/8a6b4175d790424312965ec77e4e9b072fba188b/django/http/request.py#L148-L164 This seems well thought out that it:

  • allows you to enable/disable HTTP_X_FORWARDED_HOST with a setting, e.g. USE_X_FORWARDED_HOST which is disabled by default
  • attempts to use HOST as the next thing it tries
  • attempts to use PEP 333 algorithm which uses SERVER_NAME and port

It would be good if Pulp worked this way for the django and aiohttp request + response handling, and in fact if we could just use the django build_url machinery (which all uses this underneath) we could get out of that business too. Figuring out how to get aiohttp.server to also do this will take some investigation, but at least it's a straightforward goal.

The only remaining issue then is what to do about places that aren't part of the request+response cycle, e.g. tasking, django-admin commands, etc. For those I think there needs to be either feature-by-feature defaults, environment variables, or maybe a site-wide default (like CONTENT_ORIGIN only used just for this subset of features). Anyways, producing URLs is tricky business so we need to think carefully about this aspect.

FYI @pulp/core

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Django request.py utility linked in the issue, then locate Pulp’s CONTENT_ORIGIN and custom URL-builder machinery. Investigate how aiohttp.server supplies request context and how tasking and django-admin commands build URLs; the issue is complete only after a decided, consistent approach covers these contexts.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.