Skip to content

Conversation

@reasonerjt
Copy link
Contributor

This commit update the flow to generate URL of token service, which will first try to use the Host in request. This will help the situation when Harbor is configured to serve via a hostname but some client needs to pull artifacts from Harbor via IP due to limitations in the environment.

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

@reasonerjt reasonerjt added the release-note/update Update or Fix label Apr 18, 2025
@reasonerjt reasonerjt requested a review from a team as a code owner April 18, 2025 09:11
@reasonerjt reasonerjt marked this pull request as draft April 18, 2025 09:11
@codecov
Copy link

codecov bot commented Apr 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.44%. Comparing base (c8c11b4) to head (d335e89).
Report is 468 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #21898      +/-   ##
==========================================
+ Coverage   45.36%   46.44%   +1.07%     
==========================================
  Files         244      253       +9     
  Lines       13333    14236     +903     
  Branches     2719     2925     +206     
==========================================
+ Hits         6049     6612     +563     
- Misses       6983     7273     +290     
- Partials      301      351      +50     
Flag Coverage Δ
unittests 46.44% <ø> (+1.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 178 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the token service URL generation to prioritize the Host header from the HTTP request, enabling Harbor clients to interact with the service using either hostnames or IP addresses.

  • Renamed the function from tokenSvcEndpoint to tokenSvcURL to better reflect its purpose
  • Introduced a helper function (getURL) to format the token service URL
  • Modified the URL generation logic to utilize req.Host when available

@reasonerjt reasonerjt force-pushed the token-svc-url branch 2 times, most recently from 18b88c7 to 0dae104 Compare April 27, 2025 08:20
This commit update the flow to generate URL of token service, which will
first try to use the Host in request.  This will help the situation when
Harbor is configured to serve via a hostname but some client needs to
pull artifacts from Harbor via IP due to limitations in the environment.

Signed-off-by: Daniel Jiang <[email protected]>
@reasonerjt reasonerjt marked this pull request as ready for review April 27, 2025 08:21
Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

lgtm

@reasonerjt reasonerjt merged commit 70306dc into goharbor:main Apr 28, 2025
13 checks passed
wy65701436 pushed a commit to wy65701436/harbor that referenced this pull request May 16, 2025
This commit update the flow to generate URL of token service, which will
first try to use the Host in request.  This will help the situation when
Harbor is configured to serve via a hostname but some client needs to
pull artifacts from Harbor via IP due to limitations in the environment.

Signed-off-by: Daniel Jiang <[email protected]>
@arcezd
Copy link

arcezd commented Oct 16, 2025

While upgrading from v2.13.1 to v2.14.0, we ran into an issue that might be useful to others

Our harbor is hosted on k8s exposed with Istio, and for some reason, we had this on our virtual service:

rewrite:
  authority: harbor-registry.harbor-registry.svc.cluster.local

Which caused Harbor to reply with the internal cluster svc for the service/token request, instead of the external host registry.example.com: Get "https://harbor-registry.harbor-registry.svc.cluster.local/service/token?

Error response from daemon: Get "https://registry.example.com/v2/project/appimage/manifests/sha256:c0aeeb22fc71e9bd0ac2a4ccbd5b147ff10ea123c49dd9aa6c0d15d62c87716d": Get "https://harbor-registry.harbor-registry.svc.cluster.local/service/token?scope=repository%3Aproject%2Fappimage%3Apull&service=harbor-registry": dial tcp: lookup harbor-registry.harbor-registry.svc.cluster.local on 10.10.10.100:53: no such host

I will blame this on a misconfiguration on our end, but just in case someone else faces the same, I hope this helps figure it out quicker.

OrlinVasilev pushed a commit to OrlinVasilev/harbor that referenced this pull request Oct 29, 2025
This commit update the flow to generate URL of token service, which will
first try to use the Host in request.  This will help the situation when
Harbor is configured to serve via a hostname but some client needs to
pull artifacts from Harbor via IP due to limitations in the environment.

Signed-off-by: Daniel Jiang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/update Update or Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants