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

Tasks are failing when "init" is the first argument followed by two or more other arguments. #5080

Closed
vdemeester opened this issue Jul 5, 2022 · 1 comment · Fixed by #5084
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now.

Comments

@vdemeester
Copy link
Member

Expected Behavior

Given the following task

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: tkn-arg-test
  labels:
    app.kubernetes.io/version: "0.4"
  annotations:
    tekton.dev/pipelines.minVersion: "0.22.0"
    tekton.dev/tags: cli
spec:
  description: >-
    Test consuming args
  params:
  - name: ARGS
    description: The terraform cli commands to tun
    type: array
    default:
      - "--help"
  - name: USER_HOME
    description: Override home directory to /tekton/home
    type: string
    default: "/tekton/home"
  steps:
    - name: echo-cli
      image: registry.access.redhat.com/ubi9/ubi-minimal:9.0.0-1580
      workingDir: /tekton/home
      args:
        - "$(params.ARGS)"
      command: ["echo"]
      resources:
       limits:
         cpu: 250m
         memory: 1Gi
       requests:
         cpu: 250m
         memory: 500Mi
      env:
        - name: "HOME"
          value: $(params.USER_HOME)

The following command should work:

$ tkn task start tkn-arg-test "-p=ARGS=init,two" --use-param-defaults --showlog
# Works…
[echo-cli] init two 
$ tkn task start tkn-arg-test "-p=ARGS=init,two,three" --use-param-defaults --showlog
# Doesn't work
[echo-cli] 2022/07/05 17:05:42 init error: open two: no such file or directory

Actual Behavior

It fails as written above

Steps to Reproduce the Problem

  • Create the task
  • Issue the tkn commands

Additional Info

This affect any Pipeline release that contains the follow change :
#4826. This means it affects 0.32 to 0.37 and the fix should be backport in all.

The main reason why it fails is the way the entrypoint binary is written and the way flag acts. To simplify a tiny bit, the command created on a task looks like /ko-app/entrypoint --entrypoint echo -- command and args here (with a bunch of flags before -- ommited here). With the above example, it becomes /ko-app/entrypoint --entrypoint echo -- init foo bar. The flag package, in that particular case ignores the -- and tells the rest of the code that the arguments are init foo bar, which is similar to /ko-app/entrypoint --entrypoint echo init foo bar. And this, in terms, goes into the init subcommand.

/assign
/priority critical-urgent

@vdemeester vdemeester added the kind/bug Categorizes issue or PR as related to a bug. label Jul 5, 2022
@tekton-robot tekton-robot added the priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. label Jul 5, 2022
@vdemeester
Copy link
Member Author

Upstream go issue, just in case : golang/go#53691

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants