argoproj / argo-workflows

Workflow Engine for Kubernetes
https://argo-workflows.readthedocs.io/
Apache License 2.0
14.98k stars 3.19k forks source link

Unable to use script tag inside containerset #10197

Open MaheshChandrra opened 1 year ago

MaheshChandrra commented 1 year ago

Pre-requisites

What happened/what you expected to happen?

Hi Team

I would like to execute a python script using script tag inside a container of container set template. But when I do it, while running, the values of image, args and command are read as empty strings as all the values are defined in script tag.

Can you please let me know how to use script tag along with containers in container set template.

Below is the error:

failed took-up entrypoint/cmd for image you must either explicitly specify the command, or list the image's command in the index: https://argoproj.github.io/argo-workflows/workflow-executors/#emissary-emissary: could not Parse reference: 

Thanks Mahesh

Version

= 3.1.0

Paste a small workflow that reproduces the issue. We must be able to run the workflow; don't enter a workflows that uses private images.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: container-set-template-
spec:
  entrypoint: main
  templates:
    - name: main
      volumes:
        - name: workspace
          emptyDir: { }
      containerSet:
        volumeMounts:
          - mountPath: /workspace
            name: workspace
        containers:
          - name: a
            script:
              image: python:alpine3.6
              command: [python]
              source: |
                import random
                i = random.randint(1, 100)
                print(i)
          - name: b
            image: argoproj/argosay:v2
          - name: main
            image: argoproj/argosay:v2
            dependencies:
              - a
              - b

Logs from the workflow controller

kubectl logs -n argo deploy/workflow-controller | grep ${workflow}

Logs from in your workflow's wait container

kubectl logs -n argo -c wait -l workflows.argoproj.io/workflow=${workflow},workflow.argoproj.io/phase!=Succeeded
sarabala1979 commented 1 year ago

@MaheshChandrra Can you provide the workflow controller logs and pod logs?

amitde69 commented 1 year ago

I am experiencing the same thing, were you able to find a solution ? @MaheshChandrra is this even supported ?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is a mentoring request, please provide an update here. Thank you for your contributions.

lvijnck commented 1 year ago

Experiencing this, would be good to have this supported

MaheshChandrra commented 1 year ago

you

Hi Amit

There is a workaround, instead of script use:

command : ["python","-c"]
args : |
          import pandas
          .
          exit()

and write source code under the tag. It should work.

Thanks Mahesh

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is a mentoring request, please provide an update here. Thank you for your contributions.

jdaftari-confluent commented 5 months ago

I'm experiencing this as well.

agilgur5 commented 3 months ago

is this even supported ?

No this shouldn't be supported or possible; I'm actually surprised it attempts to execute this.

script and container are mutually exclusive as they are two different template types. All children of a containerSet are containers. The workaround above to rewrite with command and args is the correct way to handle this. script is more or less short-hand for that as well.

Version

= 3.1.0

I would hope this would fail validation in a newer version, but if it doesn't, we should fix that.