pulp / pulp/pulp_npm

Pull-through cache not working

Open
#380 0 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue Triage-Needed
Dominant language
Python
Stars
15
Forks
24
Avg merge
3d 22h
Merged PRs (30d)
7

Description

Version
pulpcore 3.105.0 and pulp_npm 0.7.0 via Docker pulp/pulp:3.105.0

Describe the bug
Pull-through caching does not seem to work through commands like npm install or yarn add due to issues with the listing pages.

To Reproduce
Setup simple NPM proxy via Docker:

$ docker run --rm -d -e PULP_DEFAULT_ADMIN_PASSWORD=admin --network host pulp/pulp:3.105.0
$ curl -u admin:admin -XPOST http://localhost:24817/pulp/api/v3/repositories/npm/npm/ -d name=npm-test
$ curl -u admin:admin -XPOST http://localhost:24817/pulp/api/v3/remotes/npm/npm/ -d name=npm-upstream -d url=https://registry.npmjs.org/
$ curl -u admin:admin -XPATCH http://localhost:24817/pulp/api/v3/repositories/npm/npm/019cfc3a-60f4-7ed3-9ee1-f9cf8cc5c7f7/ -d remote=/pulp/api/v3/remotes/npm/npm/019cfc3b-5cf0-791a-8fba-faf6059b2d09/
$ curl -u admin:admin -XPOST http://localhost:24817/pulp/api/v3/distributions/npm/npm/ -d name=npm-test -d base_path=npm-test -d repository=/pulp/api/v3/repositories/npm/npm/019cfc3a-60f4-7ed3-9ee1-f9cf8cc5c7f7/ -d remote=/pulp/api/v3/remotes/npm/npm/019cfc3b-5cf0-791a-8fba-faf6059b2d09/

Now list versions for a package

$ curl localhost:24816/pulp/content/npm-test/math
{"_id":"math","_rev":"8-1282dbd48955a2294e47cdf64613ba90","name":"math","description":"Mathematical Functions","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.0":{"author":{"name":"Kaleb Hornsby","email":"kaleb@hornsby.ws","url":"kaleb.hornsby.ws"},"name":"math","description":"Mathematical Functions","version":"0.0.0","repository":{"type":"git","url":"git://github.com/kaleb/js-math.git"},"main":"math.js","engines":{"node":"> 0.0.0"},"dependencies":{},"devDependencies":{},"_id":"math@0.0.0","_engineSupported":true,"_npmVersion":"1.0.10","_nodeVersion":"v0.4.9-pre","_defaultsLoaded":true,"dist":{"shasum":"3bd830a4809a8e68264bb5e6cebc24b8c80c9362","tarball":"https://registry.npmjs.org/math/-/math-0.0.0.tgz","integrity":"sha512-pcd4QT3/U0DuCUWdo4heWMNn7QWA0WcFe1XGgaRjg8Flx2sV5v0xKdkL2CSXlJjXq8w003YafqeysuA8gMvgEQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCr7gaNfNID1g2Ox0olN+Y5phi6yc+Acm8OgvIdyUAiuwIhAOlz7x6+P4gWuO6yQQ1URrJEPkBwQdSjWulSsw4hSLRw"}]},"scripts":{},"directories":{}},"0.0.3":{"author":{"name":"Kaleb Hornsby","email":"kaleb@hornsby.ws","url":"kaleb.hornsby.ws"},"name":"math","description":"Mathematical Functions","version":"0.0.3","repository":{"type":"git","url":"git://github.com/kaleb/js-math.git"},"main":"math.js","engines":{"node":"> 0.0.0"},"dependencies":{},"devDependencies":{},"homepage":"kaleb.hornsby.ws/js-math","contributors":[{"name":"Kaleb Hornsby","email":"kaleb@hornsby.ws","url":"kaleb.hornsby.ws"}],"_id":"math@0.0.3","_engineSupported":true,"_npmVersion":"1.0.10","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"85b020fd54ce10b26abeabfcd7e1f4bdbc46470f","tarball":"https://registry.npmjs.org/math/-/math-0.0.3.tgz","integrity":"sha512-xyNJxsEwpYBabFmCgwg7TFRljf5oGgV2h1TqP0H9RnykScaSKgoVlBaEz+Gov8NOdxFagoTzRg1aEBfayi8qQQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDE/zVrvUsVy1tqVTqDgvfFeAOBF8l4NB9x0o0qqgcKYAiB/ryD3LPYdzqQNseNS2ODvfiIOq0QUbPnVSm5rRKlySg=="}]},"scripts":{},"maintainers":[{"name":"kzh","email":"kaleb@hornsby.ws"}],"directories":{}}},"maintainers":[{"name":"kzh","email":"kaleb@hornsby.ws"}],"time":{"modified":"2022-06-19T16:37:40.987Z","created":"2011-06-20T21:05:27.955Z","0.0.0":"2011-06-20T21:05:31.586Z","0.0.3":"2011-09-19T01:38:33.810Z"},"author":{"name":"Kaleb Hornsby","email":"kaleb@hornsby.ws","url":"kaleb.hornsby.ws"},"repository":{"type":"git","url":"git://github.com/kaleb/js-math.git"},"users":{"valenwave":true}}

Now install that package

$ npm install --registry http://localhost:24816/pulp/content/npm-test/ math

package-lock.json now has:

{
  "name": "test-npm",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "dependencies": {
        "math": "^0.0.3"
      }
    },
    "node_modules/math": {
      "version": "0.0.3",
      "resolved": "https://registry.npmjs.org/math/-/math-0.0.3.tgz",
      "integrity": "sha512-xyNJxsEwpYBabFmCgwg7TFRljf5oGgV2h1TqP0H9RnykScaSKgoVlBaEz+Gov8NOdxFagoTzRg1aEBfayi8qQQ==",
      "engines": {
        "node": "> 0.0.0"
      }
    }
  }
}

Which resolves to the upstream registry and not pulp itself. Additionally the listing for that page now fails:

$ curl localhost:24816/pulp/content/npm-test/math
500 Internal Server Error

Server got itself in trouble

You can manually change the resolved URL which works

$ curl localhost:24816/pulp/content/npm-test/math/-/math-0.0.3.tgz

Expected behavior
Remote listing should rewrite URLs to the internal pulp URL so they actually get installed from pulp and not the remote. Additionally the listing page should work and resolve internally hosted versions in addition to the remote loaded version like PyPI does. These might be two separate issues, where the first seems like a bug with the existing functionality, and the second seems more like a new feature.

Additional context
I'm not sure what the difference is between a repository having a remote and a distribution having a remote.

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 by reproducing the Docker setup and comparing the repository and distribution remote behavior with the npm install and package listing requests shown here. Trace how the listing response builds tarball URLs and handles internally hosted versions; done means the listing succeeds and installs resolve to the internal Pulp URL.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.