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

improve error message when indexing into an array is used with stable api #6102

Closed
pritidesai opened this issue Feb 2, 2023 · 2 comments · Fixed by #6652
Closed

improve error message when indexing into an array is used with stable api #6102

pritidesai opened this issue Feb 2, 2023 · 2 comments · Fixed by #6652
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@pritidesai
Copy link
Member

Expected Behavior

Indexing into array is an alpha feature. Creating a pipelineRun with embedded task specifications with a param value set to an element of an array returns a clear validation failure:

validation failed: indexing into an array requires "enable-api-fields" feature gate to be "alpha" but it is "stable": 

Actual Behavior

We have an opportunity to be more specific while reporting an error. The pipelineRun status is lacking details:

               "conditions": [
                    {
                        "lastTransitionTime": "2023-02-02T18:23:44Z",
                        "message": "Tasks Completed: 1 (Failed: 1, Cancelled 0), Skipped: 0",
                        "reason": "Failed",
                        "status": "False",
                        "type": "Succeeded"
                    }
                ],

The taskRun status is ambiguous:

  "conditions": [
    {
      "lastTransitionTime": "2023-02-02T18:23:44Z",
      "message": "failed to create task run pod \"deployrun-deploy\": non-existent variable in \"#!/bin/bash\\nVALUE=$(params.environments[1])\\nEXPECTED=\\\"qa\\\"\\ndiff=$(diff <(printf \\\"%s\\\\n\\\" \\\"${VALUE[@]}\\\") <(printf \\\"%s\\\\n\\\" \\\"${EXPECTED[@]}\\\"))\\nif [[ -z \\\"$diff\\\" ]]; then\\n    echo \\\"Get expected: ${VALUE}\\\"\\n    exit 0\\nelse\\n    echo \\\"Want: ${EXPECTED} Got: ${VALUE}\\\"\\n    exit 1\\nfi\\n\": steps[1].script\nnon-existent variable in \"$(params.environments[0])\": steps[0].args[1]. Maybe invalid TaskSpec",
      "reason": "CouldntGetTask",
      "status": "False",
      "type": "Succeeded"
    }
  ],

Steps to Reproduce the Problem

  1. Deploy Tekton Pipelines with the latest commit
  2. Set the feature flag to stable.
  3. Apply pipelineRun from the example:
kubectl apply -f https://raw.githubusercontent.com/tektoncd/pipeline/main/examples/v1beta1/pipelineruns/alpha/pipelinerun-param-array-indexing.yaml
pipeline.tekton.dev/deploy created
pipelinerun.tekton.dev/deployrun created

Check the pipelineRun and taskRun:

kubectl get pr                                                                           
NAME        SUCCEEDED   REASON   STARTTIME   COMPLETIONTIME
deployrun   False       Failed   17s         17s

kubectl get tr 
NAME               SUCCEEDED   REASON           STARTTIME   COMPLETIONTIME
deployrun-deploy   False       CouldntGetTask   82s         82s

Additional Info

  • Kubernetes version:

    Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.14", GitCommit:"3321ffc07d2f046afdf613796f9032f4460de093", GitTreeState:"clean", BuildDate:"2022-11-09T13:40:19Z", GoVersion:"go1.17.13", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.0", GitCommit:"ab69524f795c42094a6630298ff53f3c3ebab7f4", GitTreeState:"clean", BuildDate:"2021-12-07T18:09:57Z", GoVersion:"go1.17.3", Compiler:"gc", Platform:"linux/amd64"}

  • Tekton Pipeline version:

    Output of tkn version or kubectl get pods -n tekton-pipelines -l app=tekton-pipelines-controller -o=jsonpath='{.items[0].metadata.labels.version}'

Client version: 0.23.1
Pipeline version: devel

The error is reported while handling a pod creation issue at https://github.com/tektoncd/pipeline/blob/main/pkg/reconciler/taskrun/taskrun.go#L649.

@pritidesai pritidesai added the kind/bug Categorizes issue or PR as related to a bug. label Feb 2, 2023
@Yongxuanzhang
Copy link
Member

/assign

Yongxuanzhang added a commit to Yongxuanzhang/pipeline that referenced this issue Mar 2, 2023
Before this commit, if alpha or beta feature gate is not enabled, the array indexing params will not be added to string replacements, thus will lead to non-existent variable error. This is confusing to users and doesn't provide correct guidance. This commit adds the check to the array indexing validation.

closes tektoncd#6102

Signed-off-by: Yongxuan Zhang [email protected]
@tekton-robot
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 7, 2023
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. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
3 participants