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

failed to fetch resources due to wrong path #1841

Open
yy502 opened this issue Jul 17, 2024 · 0 comments
Open

failed to fetch resources due to wrong path #1841

yy502 opened this issue Jul 17, 2024 · 0 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@yy502
Copy link

yy502 commented Jul 17, 2024

Expected Behavior

The API server should be able to fetch and return the README/YAML of the resource from the cloned catalog.

Actual Behavior

Fail to read from cloned files because the path is built incorrectly.

Steps to Reproduce the Problem

  1. add a catalog that does not live in the root of a repo
  2. the initial scrape of resources are fine
  3. click open any task from the home dashboard, README or YAML will not load
  4. upon checking the HTTP requests, we see "resource not found" errors
  5. upon checking the DB, all seems fine (resource name, version, catalog name, etc.)

Additional Info

sample catalog:
- name: core3
org: My Company
type: internal
provider: gitlab
url: https://some.internal.url
sshurl: ssh://[email protected]_server.com/core3.git
contextdir: corp/tekton/catalog
revision: master

  • UI Screenshots(if applicable)
    Screenshot 2024-07-16 at 09 16 06
    Screenshot 2024-07-16 at 09 14 05

The Bug

ContextDir was not included when building the paths to README/YAML resources.
e.g. https://github.com/tektoncd/hub/blob/main/api/v1/service/resource/resource.go#L186 and https://github.com/tektoncd/hub/blob/main/api/v1/service/resource/resource.go#L207

readmePath := fmt.Sprintf("%s/%s/%s/%s/%s/README.md", s.CatalogClonePath(), strings.ToLower(p.Catalog), strings.ToLower(p.Kind), p.Name, p.Version)
So for example, the resulting path for README is /tmp/catalog/core3/task/hello-world/0.1/README.md
but it should have been /tmp/catalog/core3/corp/tekton/catalog/task/hello-world/0.1/README.md

This bug is not affecting https://hub.tekton.dev/ because the community Tekton Hub does not need a ContextDir as all resources are in the root dir of https://github.com/tektoncd/catalog

Validation

I created a sym-link from /tmp/catalog/core3/task to /tmp/catalog/core3/corp/tekton/catalog/task and all resources are loading fine now.
Screenshot 2024-07-17 at 11 49 42

@yy502 yy502 added the kind/bug Categorizes issue or PR as related to a bug. label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

1 participant