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

"/workspace" in the path of "output resource" #1642

Closed
vincent-pli opened this issue Nov 28, 2019 · 8 comments
Closed

"/workspace" in the path of "output resource" #1642

vincent-pli opened this issue Nov 28, 2019 · 8 comments
Labels
kind/question Issues or PRs that are questions around the project or a particular feature

Comments

@vincent-pli
Copy link
Member

I'm confuse, maybe missing something.
I have a task with output resource and targetpath, like this:

apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: build-push
spec:
  outputs:
    resources:
    - name: builtImage
      type: image
      targetPath: /pengli/builtImage
  steps:
  - name: build-and-push
    image: docker
    args: ["touch", "$(outputs.resources.builtImage.path)/README.md"]

Simple, but get error: touch: /workspace/pengli/builtImage/README.md: No such file or directory
I checked the env, actually /pengli/builtImage/ is created.

I have no idea if it's a mistake, but I think /workspace/* should be the correct one, since containers in pod shared file system only with several mount points, /workspace/* is one of them. we expect sharing in containers.

Expected Behavior

Taskrun sucess

Actual Behavior

Failed

Steps to Reproduce the Problem

Additional Info

@chmouel
Copy link
Member

chmouel commented Nov 28, 2019

/label bug

I think you only need a workingDir: /workspace in the container spec ?

@vdemeester
Copy link
Member

/kind question
I am not actually sure if it's a bug, I would have thought if you specify the targetPath it shouldn't be prepended by /workspace.

/cc @dlorenc @bobcatfish

@tekton-robot tekton-robot added the kind/question Issues or PRs that are questions around the project or a particular feature label Nov 28, 2019
@vincent-pli
Copy link
Member Author

@vdemeester
I figure out the problem.
The workingDir of Container in our Pod is /workspace, so the mkdir will create directory based that path.

So there are two scenario:

  1. Targetpath is AP, then the path will be create as what it look like, for example: /pengli/builtImage
  2. Targetpath is relative path (no "/" at beginning), then a prefix /workspace will be added.

The outputs.resources.builtImage.path believe the targetpath is always relative path, so it alway add /workspace, that's why error raised.

I think, we should document it at least.

@afrittoli
Copy link
Member

@vdemeester
I figure out the problem.
The workingDir of Container in our Pod is /workspace, so the mkdir will create directory based that path.

So there are two scenario:

  1. Targetpath is AP, then the path will be create as what it look like, for example: /pengli/builtImage
  2. Targetpath is relative path (no "/" at beginning), then a prefix /workspace will be added.

The outputs.resources.builtImage.path believe the targetpath is always relative path, so it alway add /workspace, that's why error raised.

I think, we should document it at least.

Thanks for looking into this. The inconsistent behaviour sounds like a bug to me.

@vdemeester @bobcatfish @dlorenc @skaegi do we want to support mounting resources outside of /workspace?
I would say yes, so the absolute path should be honoured by outputs.resources.builtImage.path

@vdemeester vdemeester assigned vdemeester and unassigned vdemeester Nov 29, 2019
@vincent-pli
Copy link
Member Author

@vdemeester @afrittoli
So should we fix this issue at outputs.resources.builtImage.path side?

@ghost
Copy link

ghost commented Jan 10, 2020

@vincent-pli Yes, I think the right solution is for outputs.resources.builtImage.path to correctly report the directory instead of prepending /workspace to the target path.

I see that your current PR to solve this issue prepends /workspace - do you want to close that PR and start a new one for this fix or update it to correct the variable interpolation value?

@vincent-pli
Copy link
Member Author

@sbwsg
Sure, I can do that.

@bobcatfish
Copy link
Collaborator

For whatever reason targetPath has always been relative to /workspace https://github.com/tektoncd/pipeline/blob/master/docs/resources.md#controlling-where-resources-are-mounted

Admittedly very confusing 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Issues or PRs that are questions around the project or a particular feature
Projects
None yet
Development

No branches or pull requests

6 participants