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

[TEP-0115] Support Artifact Hub in Hub Resolver #5666

Merged

Conversation

QuanZhang-William
Copy link
Member

@QuanZhang-William QuanZhang-William commented Oct 19, 2022

Changes

Part of issues/667.
This commit adds support to resolve catalog from the Artifact Hub and keep current functionality of fetching catalog from the Tekton Hub.

  • Change 1:

The commit adds a new field type to the hub resolver indicating the type of the Hub to pull the resource from. The value can be set to tekton or artifact. By default, the resolver fetches resources from https://artifacthub.io/ when setting type to artifact.

  • Change 2:

Prior to this change, the hub resolver only supports pulling resources from the Tekton Hub. This commit updates the default hub type to artifact since the Artifact Hub will be the main entrypoint for Tekton Catalogs in the future.

  • Change 3:

Prior to this change, the default Tekton Hub URL is: https://api.hub.tekton.dev. This commit removes the default value of the Tekton Hub URL and enforces users to configure their own instance of Tekton Hub since the public instance https://api.hub.tekton.dev will be deprecated after the migration to Artifact Hub is done.

/kind feature

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

The Hub Resolver will have a new `type` field to indicate the type of Hub from where to pull the resource. The default hub type is updated from the Tekton Hub to the Artifact Hub. Please see more details in TEP-0115

@tekton-robot
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@tekton-robot tekton-robot added kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Oct 19, 2022
@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 19, 2022
@QuanZhang-William
Copy link
Member Author

/kind feature

@QuanZhang-William
Copy link
Member Author

/test all

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/hub/resolver.go 72.4% 74.8% 2.4

@QuanZhang-William
Copy link
Member Author

/test all

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/hub/resolver.go 72.4% 75.6% 3.2

@QuanZhang-William
Copy link
Member Author

/test all

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/hub/resolver.go 72.4% 74.8% 2.4

@abayer
Copy link
Contributor

abayer commented Oct 19, 2022

Nice!

@QuanZhang-William
Copy link
Member Author

/retest

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/hub/resolver.go 72.4% 74.8% 2.4

@QuanZhang-William QuanZhang-William marked this pull request as ready for review October 20, 2022 13:12
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 20, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/hub/resolver.go 72.4% 74.8% 2.4

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/hub/resolver.go 72.4% 74.8% 2.4

@QuanZhang-William
Copy link
Member Author

/retest

@jerop jerop added this to the Pipelines v0.41 milestone Oct 20, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/hub/resolver.go 72.4% 74.5% 2.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/hub/resolver.go 72.4% 74.5% 2.1

@jerop
Copy link
Member

jerop commented Oct 24, 2022

/retest

@jerop
Copy link
Member

jerop commented Oct 24, 2022

known flake: #4643

/retest

Copy link
Member

@chuangw6 chuangw6 left a comment

Choose a reason for hiding this comment

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

Thank you @QuanZhang-William !! 👍

pkg/resolution/resolver/hub/resolver.go Outdated Show resolved Hide resolved
pkg/resolution/resolver/hub/resolver.go Outdated Show resolved Hide resolved
pkg/resolution/resolver/hub/resolver_test.go Outdated Show resolved Hide resolved
docs/hub-resolver.md Outdated Show resolved Hide resolved
pkg/resolution/resolver/hub/resolver.go Outdated Show resolved Hide resolved
Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

Looks good!

pkg/resolution/resolver/hub/resolver.go Outdated Show resolved Hide resolved
resVer := version

if hubType == ArtifactHubType && len(semVer) == 2 {
resVer = version + ".0"
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit concerned about doing this - i.e. if someone takes this version and tries to fetch the config, will this guarantee to always work? i.e. if artifacthub publishes 0.1, will I always be able to fetch 0.1.0 and will this always map to 0.1? Or could a different 0.1.0 be added after?

There's an argument that maybe the resolver shouldn't try to interpret semver and just always handle versions as-is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @wlynch, thanks for your input and this is a good question 😀 . The short answer is yes. If artifacthub publishes 0.1, and I will always be able to fetch 0.1.0

The artifact hub will always convert the resource yaml version to semVer (i.e. 0.6 -> 0.6.0) and the Hub uses the semVer to index the corresponding resource.

So technically you can publish a resource with yaml version 0.6 first (which is converted to 0.6.0 in the Hub), and then publish another yaml version of 0.6.0, it just overrides the previous 0.6.0 version in the Hub. But the API will always return the latest 0.6.0

The main reason I put such conversion is for backward compatibility, so that current users can keep version 0.6 in the resolver, and the type is default to artifact

Copy link
Member

Choose a reason for hiding this comment

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

I'd lean towards dropping this for the new artifacthub impl:

  1. semver with a missing minor/patch version generally uses the latest version matching the prefix (i.e. the golang 1.19 docker image refers to the latest patch version 1.19.2) - I'm not sure we want to have the resolver implement this kind of lookup behavior.
  2. I'm worried about version skew for ArtifactHub URLs - e.g. https://artifacthub.io/packages/tekton-task/tekton-catalog-tasks/git-clone/0.8.0 (even though this points to the 0.8 git tag), but https://artifacthub.io/packages/tekton-task/tekton-catalog-tasks/git-clone/0.8 404s.

It'll probably be simpler long term for the resolver to interpret the user provided version tag as-is, so it always matches the upstream state (up to you if you want to preserve the old behavior for compatibility).

Copy link
Member Author

@QuanZhang-William QuanZhang-William Oct 27, 2022

Choose a reason for hiding this comment

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

The Artifact Hub always converts the resource yaml version and git tag to semVer here (by appending 0 as minor and patch version if missing) and requires the exact match between the 2 after conversion.

For 2, I don't think there is version skew for the Artifact Hub URL since all the valid URLs will use semVer no matter how do you tag the repo, and URLs with simple semver will always return 404s.

Because the resource is indexed by the resource yaml version, we cannot use the latest version matching the prefix logic here (so we can only append 0s).

So it seems to me that the lookup here brings the extra backward compatibility benefit and does not cause any problems (i.e. version 0.6 and version 0.6.0 in the hub resolver always points to the same resource)?

Copy link
Member Author

Choose a reason for hiding this comment

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

pkg/resolution/resolver/hub/resolver.go Outdated Show resolved Hide resolved
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/hub/resolver.go 72.4% 77.6% 5.2

Part of [issues/667].
This commit adds support to resolve catalog resource from the [Artifact Hub] while keeping current functionality of fetching resources from Tekton Hub.

- Change 1:

The commit adds a new field `type` to the hub resolver indicating the type of the Hub to pull the resource from. The value can be set to `tekton` or `artifact`. By default, the resolver fetches resources from `https://artifacthub.io/` when setting `type` to `" artifact"`, and fetches resources from user's private instance of Tekton Hub when setting `type` to `"tekton"`.

- Change 2:

Prior to this change, the hub resolver only supports pulling resources from the Tekton Hub. This commit updates the default hub type to `artifact` since the [Artifact Hub][Artifact Hub] will be the main entrypoint for Tekton Catalogs in the future.

- Change 3:

Prior to this change, the default Tekton Hub URL is: `https://api.hub.tekton.dev`. This commit removes the default value of the Tekton Hub URL and enforces users to configure their own instance of Tekton Hub since the public instance `https://api.hub.tekton.dev` will be deprecated after the migration to Artifact Hub is done.

/kind feature

[Artifact Hub]: https://artifacthub.io/
[issues/667]: tektoncd/hub#667
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/hub/resolver.go 72.4% 77.6% 5.2

@QuanZhang-William
Copy link
Member Author

@jerop @abayer @wlynch @chuangw6 . Could you please review the code again. Thanks 😁

@jerop
Copy link
Member

jerop commented Oct 25, 2022

/approve

cc @abayer

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 25, 2022
@wlynch
Copy link
Member

wlynch commented Oct 25, 2022

Would it be worth adding docs around configuring the different hub impls and the differences between them?

@QuanZhang-William
Copy link
Member Author

Would it be worth adding docs around configuring the different hub impls and the differences between them?

Hi @wlynch, I have some documentation here talking about the configuration and migration to the Artifact Hub. Is there thing else you suggest to add?

Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

My mistake!

/lgtm

cmd/resolvers/main.go Show resolved Hide resolved
@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 28, 2022
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jerop, wlynch

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants