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

"From" does not work #755

Closed
vincent-pli opened this issue Apr 12, 2019 · 4 comments · Fixed by #762
Closed

"From" does not work #755

vincent-pli opened this issue Apr 12, 2019 · 4 comments · Fixed by #762

Comments

@vincent-pli
Copy link
Member

Expected Behavior

This my pipeline:

apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
  name: tutorial-pipeline
spec:
  resources:
    - name: source-repo
      type: git
    - name: docker-image
      type: image
  tasks:
    - name: build-model-image
      taskRef:
        name: build-docker-image-from-git-source
      params:
        - name: pathToDockerFile
          value: /workspace/docker-source/mnist/Dockerfile.model
        - name: pathToContext
          value: /workspace/docker-source/mnist/ #configure: may change according to your source
      resources:
        inputs:
          - name: docker-source
            resource: source-repo
        outputs:
          - name: docker-image
            resource: docker-image
    - name: train
      taskRef:
        name: train-model
      resources:
        inputs:
          - name: train-image
            from:
              - build-model-image

I guess it's right, just follow the guide, I expect the task will run as build-model-image -> train

Actual Behavior

I get error:
pipelineTask tried to use input resource not present in declared resources

Additional Info

I try to figure out what happened, then find the code in pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go

func getPipelineRunTaskResources(pt v1alpha1.PipelineTask, providedResources map[string]v1alpha1.PipelineResourceRef) ([]v1alpha1.TaskResourceBinding, []v1alpha1.TaskResourceBinding, error) {
	inputs, outputs := []v1alpha1.TaskResourceBinding{}, []v1alpha1.TaskResourceBinding{}
	if pt.Resources != nil {
		for _, taskInput := range pt.Resources.Inputs {
			// if len(taskInput.From) > 0 {
			// 	continue
			// }
			resource, ok := providedResources[taskInput.Resource]
			if !ok {
				return inputs, outputs, fmt.Errorf("pipelineTask tried to use input resource %s not present in declared resources", taskInput.Resource)
			}
			inputs = append(inputs, v1alpha1.TaskResourceBinding{
				Name:        taskInput.Name,
				ResourceRef: resource,
			})
		}
		for _, taskOutput := range pt.Resources.Outputs {
			resource, ok := providedResources[taskOutput.Resource]
			if !ok {
				return outputs, outputs, fmt.Errorf("pipelineTask tried to use output resource %s not present in declared resources", taskOutput.Resource)
			}
			outputs = append(outputs, v1alpha1.TaskResourceBinding{
				Name:        taskOutput.Name,
				ResourceRef: resource,
			})
		}
	}
	return inputs, outputs, nil
}

I don't know, the logic is not right, then I try to add additional code(the comment ones) and I get a memory error in
pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.ValidateFrom

at the end, I pass the issue by add additional item in inputs section of the second task:
from:

      resources:
        inputs:
          - name: train-image
            from:
              - build-model-image

to:

      resources:
        inputs:
          - name: train-image
            resource: docker-image
            from:
              - build-model-image

So is this issue just a document error?

@vincent-pli
Copy link
Member Author

@vdemeester
Could you take a look this?

@piyush-garg
Copy link
Contributor

@vincent-pli Seems like a document issue. AFAIK, we need to provide resource filed which will be the resource name from the previous task, so your changed input resources for the second task looks fine to me. Can you please point me where the yaml's are.

More @vdemeester can give us info about this. Thanks

@vincent-pli
Copy link
Member Author

vincent-pli commented Apr 15, 2019

Thanks @piyush-garg , I just follow document about pipelines:
https://github.com/tektoncd/pipeline/blob/master/docs/pipelines.md

@piyush-garg
Copy link
Contributor

Ok, Thanks @vincent-pli will fix that.

For your reference, here is an example with the details I provided https://github.com/tektoncd/pipeline/blob/master/docs/tutorial.md#pipeline

@vdemeester Any thoughts.

piyush-garg added a commit to piyush-garg/pipeline that referenced this issue Apr 15, 2019
Yaml provided as a sample have missing property
and are confusing the users

Fix them to avoid confusions and also used the
consistent naming

Fixes tektoncd#755
tekton-robot pushed a commit that referenced this issue Apr 15, 2019
Yaml provided as a sample have missing property
and are confusing the users

Fix them to avoid confusions and also used the
consistent naming

Fixes #755
nikhil-thomas pushed a commit to nikhil-thomas/pipeline that referenced this issue Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants