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

Add subPath to PipelineTask so instances of tasks can write to different paths of ws #2490

Closed
jlpettersson opened this issue Apr 24, 2020 · 0 comments · Fixed by #2491
Closed
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@jlpettersson
Copy link
Member

jlpettersson commented Apr 24, 2020

Expected Behavior

That I can use multiple instances of a task that writes to the workspace volume, but to different paths.

E.g. one git-clone task that clone the app-code-repository and another git-clone task that clone the app-config-repository and that I in a later task can use files from both git-clone tasks.

Another use case is to git-clone code into a directory of workspace volume, and in addition fetch cached dependencies from a GCS bucket into another directory of the workspace volume.

Actual Behavior

This can currently be done using two workspaces of type PersistentVolumeClaim in combination with different values of subPath, e.g.

workspaces:
- name: workspace-1
  persistentVolumeClaim:
    claimName: mypvc
  subPath: subdir-1
- name: workspace-2
  persistentVolumeClaim:
    claimName: mypvc
  subPath: subdir-2

but when using a workspace of type volumeClaimTemplate there is currently no way of doing this, since providing two templates gives you two different volumes

workspaces:
- name: workspace-1
  volumeClaimTemplate:
    spec:
      accessModes: 
      - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi
- name: workspace-2
  volumeClaimTemplate:
    spec:
      accessModes: 
      - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi

Proposed Solution

If we add the field subPath to the WorkspacePipelineTaskBinding - different instances of a task can be bound to different subdirectories of the workspace volume. Then this is done when the pipeline binds the workspace to the instance of the task in the Pipeline.

Example Pipeline

apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: pipeline
spec:
  tasks:
  - name: writer-1
    taskRef:
      name: writer
    workspaces:
    - name: task-ws
      workspace: ws
      subPath: dir-1
  - name: writer-2
    taskRef:
      name: writer
    workspaces:
    - name: task-ws
      workspace: ws
      subPath: dir-2
  - name: read-all
    runAfter:
    - writer-1
    - writer-2
    taskSpec:
      steps:
      - name: read-1
        image: ubuntu
        script: cat $(workspaces.local-ws.path)/dir-1/foo | grep bar
      - name: read-2
        image: ubuntu
        script: cat $(workspaces.local-ws.path)/dir-2/foo | grep bar
      workspaces:
      - name: local-ws
    workspaces:
    - name: local-ws
      workspace: ws
  workspaces:
  - name: ws
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  generateName: pr-
spec:
  pipelineRef:
    name: pipeline
  workspaces:
  - name: ws
    volumeClaimTemplate:
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 1Gi

/kind feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants