Trow-Registry / trow

Container Registry and Image Management for Kubernetes Clusters
https://trow.io
Apache License 2.0
909 stars 102 forks source link

Can't get this to work with GitLab Images #352

Closed sharkymcdongles closed 1 year ago

sharkymcdongles commented 1 year ago

Describe the bug I configure the repos per the guide and when it boots and I try and pull one I get this:

Starting Trow 0.6.0 on 0.0.0.0:8000
Hostname of this registry (for the MutatingWebhook): "trow.trow.dev"
Image validation webhook configured:
  Default action: Deny
  Allowed prefixes: ["127.0.0.1", "trow.trow.dev"]
  Denied prefixes: []
Proxy registries configured:
  - gitlab: https://registry.gitlab.com/gitlab-org/build/cng
  - nvcr: https://nvcr.io
  - quay: quay.io
2023-09-19T13:01:52.103957Z  INFO request{method="GET" path="/v2/"}: trow::routes: done in 68.488µs
2023-09-19T13:01:52.161645Z  INFO trow_server::server: Request for proxied repo f/gitlab/gitlab-shell:14.26.0 maps to registry.gitlab.com/gitlab-org/build/cng/gitlab-shell:14.26.0
2023-09-19T13:01:52.625069Z ERROR trow_server::server: Could not create client for proxied registry https://registry.gitlab.com/gitlab-org/build/cng: Unexpected status code 404 Not Found
2023-09-19T13:01:52.625136Z  WARN trow_server::server: Internal error with manifest: Could not fetch digest for f/gitlab/gitlab-shell:14.26.0
2023-09-19T13:01:52.625508Z  WARN request{method="HEAD" path="/v2/f/gitlab/gitlab-shell/manifests/14.26.0"}: trow::client_interface: Error getting manifest: status: Internal, message: "Internal error finding manifest", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "date": "Tue, 19 Sep 2023 13:01:52 GMT", "content-length": "0"} }
2023-09-19T13:01:52.626116Z  INFO request{method="HEAD" path="/v2/f/gitlab/gitlab-shell/manifests/14.26.0"}: trow::routes: done in 465.139736ms
2023-09-19T13:01:52.684275Z  INFO trow_server::server: Request for proxied repo f/gitlab/gitlab-shell:14.26.0 maps to registry.gitlab.com/gitlab-org/build/cng/gitlab-shell:14.26.0
2023-09-19T13:01:53.148374Z ERROR trow_server::server: Could not create client for proxied registry https://registry.gitlab.com/gitlab-org/build/cng: Unexpected status code 404 Not Found
2023-09-19T13:01:53.148419Z  WARN trow_server::server: Internal error with manifest: Could not fetch digest for f/gitlab/gitlab-shell:14.26.0
2023-09-19T13:01:53.148697Z  WARN request{method="GET" path="/v2/f/gitlab/gitlab-shell/manifests/14.26.0"}: trow::client_interface: Error getting manifest: status: Internal, message: "Internal error finding manifest", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "date": "Tue, 19 Sep 2023 13:01:52 GMT", "content-length": "0"} }
2023-09-19T13:01:53.148738Z  INFO request{method="GET" path="/v2/f/gitlab/gitlab-shell/manifests/14.26.0"}: trow::routes: done in 465.123436ms

To Reproduce Deploy latest trow with this config for the repos:

offline: false
registries:
- alias: gitlab
  host: https://registry.gitlab.com/gitlab-org/build/cng
- alias: nvcr
  host: https://nvcr.io
- alias: quay
  host: quay.io

Images are at this endpoint: registry.gitlab.com/gitlab-org/build/cng/gitlab-shell:v14.26.0

Then try to pull any image like:

docker pull trow.trow.dev/f/gitlab/gitlab-shell:14.26.0

I also tried to setting the host to these different ones:

registry.gitlab.com/gitlab-org/build/cng
https://registry.gitlab.com/
registry.gitlab.com

When I got rid of the path I passed the path like this:

docker pull trow.trow.dev/f/gitlab/gitlab-org/build/cng/gitlab-shell:14.26.0

Expected behavior A way to proxy gitlab images.

Trow Info

Kubernetes

sharkymcdongles commented 1 year ago

@awoimbee 🙏

awoimbee commented 1 year ago

I see 2 issues here:

  1. Trow expects host to point to a registry (registry.gitlab.com), not to something inside a registry (registry.gitlab.com/gitlab-org/build/cng) -> could we change that ?.
  2. f/gitlab/gitlab-org/build/cng/gitlab-shell is 6 segments, currently each route is manually written up to 5 segments. see: https://github.com/Trow-Registry/trow/blob/844cc06923666e9fa76fd0c9161d5d2791608e6b/src/routes/manifest.rs#L75 https://github.com/Trow-Registry/trow/blob/844cc06923666e9fa76fd0c9161d5d2791608e6b/src/routes/mod.rs#L107 I hope we will get some time to either define routes using macros or use another routing library in the near future, in the meantime I would accept a PR that adds a 6th level...

PS: Who designed the routes for the docker registry API ? What kinds of drugs were they on ?

amouat commented 1 year ago

f/gitlab/gitlab-org/build/cng/gitlab-shell is 6 segments, currently each route is manually written up to 5 segments.

Lol. I did feel physically ill writing this code, but there wasn't much else I could do :(

The routing library used by Docker when writing the registry supports wildcards in the middle of routes, so they never had this problem :/

sharkymcdongles commented 1 year ago

@awoimbee I don't use rust but seemed straightforwardish:

https://github.com/Trow-Registry/trow/pull/355

sharkymcdongles commented 1 year ago

Okay so I was trying to build this and was really struggling to do it using the build scripts but then figured it out in the end. I also fixed a warning for base64 I saw just for the lulz. I built a custom image with the new binary inside and now it pulls fine.

🥳

you can test if you'd like:

https://hub.docker.com/r/bhabha/trow

Proxy registries configured:
  - gitlab: registry.gitlab.com
  - nvcr: https://nvcr.io
  - quay: quay.io
  - ghcr: ghcr.io
2023-09-23T12:31:45.454572Z  INFO request{method="GET" path="/v2/"}: trow::routes: done in 55.065µs
2023-09-23T12:31:45.535723Z  INFO trow_server::server: Request for proxied repo f/gitlab/gitlab-org/build/cng/gitlab-shell:v14.26.0 maps to registry.gitlab.com/gitlab-org/build/cng/gitlab-shell:v14.26.0
2023-09-23T12:31:46.472105Z  INFO trow_server::server: Downloading blob https://registry.gitlab.com/v2/gitlab-org/build/cng/gitlab-shell/blobs/sha256:7d97e254a0461b0a30b3f443f1daa0d620a3cc6ff4e2714cc1cfd96ace5b7a7e
2023-09-23T12:31:46.472177Z  INFO trow_server::server: Downloading blob https://registry.gitlab.com/v2/gitlab-org/build/cng/gitlab-shell/blobs/sha256:ac79b35b6399ee387fb433f37c090f64aaa6e3e663cc2fe1e6662c48a74112c4
2023-09-23T12:31:46.472251Z  INFO trow_server::server: Downloading blob https://registry.gitlab.com/v2/gitlab-org/build/cng/gitlab-shell/blobs/sha256:80630be774bd5a9e2841da4f008f2a76ba8fc623c5e12bf9aff849bba4f6b081
2023-09-23T12:31:46.472324Z  INFO trow_server::server: Downloading blob https://registry.gitlab.com/v2/gitlab-org/build/cng/gitlab-shell/blobs/sha256:d29ff3c32de6de16dcbfc130c2e38e0aa21f6acbce0cfef6e6e2988772de8ea5
2023-09-23T12:31:46.472397Z  INFO trow_server::server: Downloading blob https://registry.gitlab.com/v2/gitlab-org/build/cng/gitlab-shell/blobs/sha256:4dcd4fa368e1340aa0eba42bfc4190e38cb69ec47d64f3c849c9d2161e227a90
2023-09-23T12:31:46.472474Z  INFO trow_server::server: Downloading blob https://registry.gitlab.com/v2/gitlab-org/build/cng/gitlab-shell/blobs/sha256:29f6a21ee97cb04e7bb348b9fc947468a59112ac876e3d99ea4769e63b26a97a
2023-09-23T12:31:46.472621Z  INFO trow_server::server: Downloading blob https://registry.gitlab.com/v2/gitlab-org/build/cng/gitlab-shell/blobs/sha256:2851606c2e8735d1e0050c41abb7c301eacf8666bc3f5970a983faa7f94859d9
2023-09-23T12:31:46.472714Z  INFO trow_server::server: Downloading blob https://registry.gitlab.com/v2/gitlab-org/build/cng/gitlab-shell/blobs/sha256:8768b3f1cd706ff128037955709913fd10f18046285c30d3affcccffb1d92d48
2023-09-23T12:31:46.472946Z  INFO trow_server::server: Downloading blob https://registry.gitlab.com/v2/gitlab-org/build/cng/gitlab-shell/blobs/sha256:128e6acf4ba24c9e7d5b5118c192f07b5e143e642cac7d380b0e5458dfd722c3
2023-09-23T12:31:46.473014Z  INFO trow_server::server: Downloading blob https://registry.gitlab.com/v2/gitlab-org/build/cng/gitlab-shell/blobs/sha256:70d63723e8caf81788a53acee8703810fdcb3bb70eefae3b08e938222df881ca
2023-09-23T12:31:46.473100Z  INFO trow_server::server: Downloading blob https://registry.gitlab.com/v2/gitlab-org/build/cng/gitlab-shell/blobs/sha256:753ba2357d672bcb6eb84103072a1fb9a6b5d1c3fbc5b6764291e150001a8478
2023-09-23T12:31:46.473143Z  INFO trow_server::server: Downloading blob https://registry.gitlab.com/v2/gitlab-org/build/cng/gitlab-shell/blobs/sha256:07109c6b964f91c88d9c46e71a549e8600e6fef27003952dc20752c0c87996f5
2023-09-23T12:31:47.490756Z  INFO request{method="HEAD" path="/v2/f/gitlab/gitlab-org/build/cng/gitlab-shell/manifests/v14.26.0"}: trow::routes: done in 1.955812185s