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

Mount volumes defined in a WorkflowTemplate when it's called by another workflow #7444

Open
cscetbon opened this issue Dec 19, 2021 · 6 comments

Comments

@cscetbon
Copy link

cscetbon commented Dec 19, 2021

Summary

What change needs making?

Volumes set on a WorkflowTemplate should be used when called by another workflow

Use Cases

When would you use this?

Here is what doesn't work today

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: template1
spec:
  entrypoint: template1
  volumeClaimTemplates:
  - metadata:
      name: my-pvc
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 5M
  arguments: &parameters
    parameters: 
    - name: run
  templates:
    - name: template1
      inputs: *parameters
      steps:
        - - name: template10
            template: template10
            arguments:
              parameters:
                - name: run
                  value: "{{inputs.parameters.run}}"
        - - name: template11
            templateRef:
              name: template2
              template: template2

    - name: template10
      inputs: *parameters
      script:
        image: debian:9.4
        command: [bash]
        source: |
          echo "{{inputs.parameters.run}}" > /mnt/pvc/output
        volumeMounts:
          - name: my-pvc
            mountPath: /mnt/pvc

---
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: template2
spec:
  entrypoint: template2
  templates:
    - name: template2
      script:
        image: debian:9.4
        command: [bash]
        source: |
          cat /mnt/pvc/output
        volumeMounts:
          - name: my-pvc
            mountPath: /mnt/pvc
---
apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
  name: cronwf-ex1
spec:
  schedule: 0 11 * * *
  concurrencyPolicy: Forbid
  workflowSpec:
    entrypoint: jobs
    # volumeClaimTemplates:
    # - metadata:
    #     name: my-pvc
    #   spec:
    #     accessModes: [ "ReadWriteOnce" ]
    #     resources:
    #       requests:
    #         storage: 5M
    templates:
    - name: jobs
      steps:
      - - name: template1
          templateRef:
            name: template1
            template: template1
          arguments:
            parameters:
            - name: run
              value: "{{item}}"
          withItems:
            - run1
            # -... 
            - run23

works well
argo submit --from wftmpl/template1 --watch

works only if the commented out lines on the cron workflow are uncommented
argo submit --from cronwf/cronwf-ex1 --watch

The issue with adding the volume on the cronworkflow is that it's shared by all the runX however I want to keep it in the template1 to make sure each runX uses a different PVC (gp2 can't use ReadWriteMany for instance).

volumes available on the workflow template should be automatically mounted when called by another template. It could be not mounted only if the calling workflow already has a corresponding volume for instance.


Message from the maintainers:

Love this enhancement proposal? Give it a 👍. We prioritise the proposals with the most 👍.

@cscetbon cscetbon added the type/feature Feature request label Dec 19, 2021
@alexec alexec added type/bug area/controller Controller issues, panics area/workflow-templates and removed type/feature Feature request area/controller Controller issues, panics labels Feb 7, 2022
@stale

This comment was marked as resolved.

@stale stale bot added the problem/stale This has not had a response in some time label Mar 2, 2022
@stale stale bot closed this as completed Apr 16, 2022
@cscetbon
Copy link
Author

I don't think it should be closed.

@sarabala1979
Copy link
Member

It is not a bug. It is by design. if you are referring templateRef on workflow, it can't access the Spec level elements. PVC definition should be in workflow.

@wobrycki
Copy link

Hi @sarabala1979, is there any way to configure argo-workflows, so that volumeClaimTemplates: is always defined, per default, regardless of which workflow I start (like cron without volumeClaimTemplates: defined)?

Our use-case is similar. We have a template which needs a volume and has volumeMounts:.
It's used in may places (cron, other workflows). Now, we need to remember to always put volumeClaimTemplates into every "parent" workflow. Isn't it contradiction to the point of having reusable sub-templates?

@sarabala1979
Copy link
Member

@wobrycki you can try workflowDefaults on workflow-controller configmap. WorkflowDefaults will be applied to all workflows that are executed on that controller.

The following would be specified in the Config Map:

@sarabala1979 sarabala1979 reopened this Jun 20, 2023
@stale stale bot removed the problem/stale This has not had a response in some time label Jun 20, 2023
@stale

This comment was marked as resolved.

@stale stale bot added the problem/stale This has not had a response in some time label Sep 17, 2023
@terrytangyuan terrytangyuan removed the problem/stale This has not had a response in some time label Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants