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

Support for "volume" field in Condition #1795

Closed
adux6991 opened this issue Dec 30, 2019 · 1 comment
Closed

Support for "volume" field in Condition #1795

adux6991 opened this issue Dec 30, 2019 · 1 comment

Comments

@adux6991
Copy link

adux6991 commented Dec 30, 2019

Expected Behavior

I am trying to implement a simple flip-coin example using pipelines and conditions. Since I cannot find a way to output parameters in a task, I use volumes to store the output and mount the volume in each task. But when it comes to conditions, the field "volume" is not supported. How should I accomplish this?

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-volume-claim
spec:
  resources:
    requests:
      storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: flip-coin
spec:
  volumes:
  - name: my-cache
    persistentVolumeClaim:
      claimName: my-volume-claim
  steps:
    - name: flip-coin-step
      image: ubuntu
      script: |
        #!/bin/sh
        python -c "import random; result = 'heads' if random.randint(0,1) == 0 else 'tails'; print(result)" | tee /my-cache/output
      volumeMounts:
        - name: my-cache
          mountPath: /my-cache
---
apiVersion: tekton.dev/v1alpha1
kind: Condition
metadata:
  name: condition-1
spec:
  volumes:     # This is the field not supported
  - name: my-cache
    persistentVolumeClaim:
      claimName: my-volume-claim
  check:
    image: ubuntu
    command: ["/bin/sh"]
    args: ['-c', 'test "head" = $(cat /my-cache/output)']
    volumeMounts:
      - name: my-cache
        mountPath: /my-cache
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: mytask2
spec:
  volumes:
  - name: my-cache
    persistentVolumeClaim:
      claimName: my-volume-claim
  steps:
    - name: catsomething
      image: ubuntu
      command: ["bash", "-c"]
      args: ["cat /my-cache/output"]
      volumeMounts:
        - name: my-cache
          mountPath: /my-cache
---
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
  name: mypipeline
spec:
  tasks:
    - name: task1
      taskRef:
        name: mytask
    - name: task2
      runAfter: [task1]
      taskRef:
        name: mytask2
      conditions:
        - conditionRef: "condition-1"
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
  name: mypipelinerun
spec:
  pipelineRef:
    name: mypipeline

Actual Behavior

Internal error occurred: admission webhook "webhook.tekton.dev" denied the request: mutation failed: cannot decode incoming new object: json: unknown field "volumes"

Steps to Reproduce the Problem

  1. kubectl apply -f condition.yaml

Additional Info

I searched among existed issues and found that it would be perfect if one of the following proposals were implemented, especially for users who have no access to GCS, the only supported storage resource.

  1. Add volume resource. Add "volume" input/output resource #1062 Support for a "volume resource"-like Task.spec field #1438
  2. Support 'param' field in task outputs. Feature Request: Task Output Type of Param #1273
@adux6991
Copy link
Author

Found a way to bypass the restriction. Declare volumes in pipelineRun.podTemplate and mount it in Condition.spec.check.volumeMounts. So I'm gonna close it.

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

No branches or pull requests

1 participant