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

Unable to safely use array results as input parameters for other tasks #7392

Closed
l-qing opened this issue Nov 18, 2023 · 6 comments · Fixed by #7460
Closed

Unable to safely use array results as input parameters for other tasks #7392

l-qing opened this issue Nov 18, 2023 · 6 comments · Fixed by #7460
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@l-qing
Copy link
Contributor

l-qing commented Nov 18, 2023

Expected Behavior

I can safely apply array results as parameters to the task, just like the usual array parameters.
When I quote the results of other tasks, I cannot ensure that the arrays in their results are definitely non-empty.

This PipelineRun can be executed successfully.

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: task-with-array-result
spec:
  params:
  - name: arrayVal1
    description: "description3"
    type: array
    default: []
  steps:
  - name: step1
    image: bash:latest
    args:
      - --images
      - $(params.arrayVal1[*])
    script: |
      #!/usr/bin/env bash
      for arg in "$@"; do
        echo $arg
      done
  - name: step2
    image: bash:latest
    script: |
      #!/usr/bin/env bash
      echo -n '[]' | tee $(results.resultArray.path)
      # echo -n '["a", "b"]' | tee $(results.resultArray.path)
  results:
  - name: resultArray
    description: "description4"
    type: array

---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  name: pipelinerun-array-result
spec:
  pipelineSpec:
    tasks:
      - name: task-1
        taskRef:
          name: task-with-array-result
        params:
          - name: arrayVal1
            value: []
      - name: task-2
        taskRef:
          name: task-with-array-result
        params:
          - name: arrayVal1
            value: $(tasks.task-1.results.resultArray)

The arrayVal1 parameter in the first task is an empty array, see if task-1 can be successfully executed.
I have specified the result of task-1 as an empty array, it cannot be used as a parameter for task-2.

Although they are both empty arrays, their behaviors are completely different. I expect them to act consistently and all be able to successfully execute.

Actual Behavior

The pipelinerun encountered an error when executing the second task.
Encountered an error.

Array Result Index 0 for Task task-1 Result resultArray is out of bound of size 0

PipelineRun YAML:

apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  creationTimestamp: "2023-11-18T11:06:31Z"
  generation: 1
  labels:
    tekton.dev/pipeline: pipelinerun-array-result
  name: pipelinerun-array-result
  namespace: devops-b
  resourceVersion: "57520529"
  uid: 143f13ad-e0a7-4558-a8b4-0bdcdf32a0f6
spec:
  pipelineSpec:
    tasks:
    - name: task-1
      params:
      - name: arrayVal1
        value: []
      taskRef:
        kind: Task
        name: task-with-array-result
    - name: task-2
      params:
      - name: arrayVal1
        value: $(tasks.task-1.results.resultArray)
      taskRef:
        kind: Task
        name: task-with-array-result
  serviceAccountName: default
  timeouts:
    pipeline: 1h0m0s
status:
  childReferences:
  - apiVersion: tekton.dev/v1
    kind: TaskRun
    name: pipelinerun-array-result-task-1
    pipelineTaskName: task-1
  completionTime: "2023-11-18T11:06:55Z"
  conditions:
  - lastTransitionTime: "2023-11-18T11:06:55Z"
    message: 'PipelineRun devops-b/pipelinerun-array-result can''t be Run; couldn''t
      resolve all references: Array Result Index 0 for Task task-1 Result resultArray
      is out of bound of size 0'
    reason: PipelineValidationFailed
    status: "False"
    type: Succeeded
  pipelineSpec:
    tasks:
    - name: task-1
      params:
      - name: arrayVal1
        value: []
      taskRef:
        kind: Task
        name: task-with-array-result
    - name: task-2
      params:
      - name: arrayVal1
        value: $(tasks.task-1.results.resultArray)
      taskRef:
        kind: Task
        name: task-with-array-result
  provenance:
    featureFlags:
      AwaitSidecarReadiness: true
      Coschedule: workspaces
      DisableAffinityAssistant: false
      DisableCredsInit: false
      EnableAPIFields: alpha
      EnableCELInWhenExpression: false
      EnableKeepPodOnCancel: false
      EnableProvenanceInStatus: true
      EnableStepActions: false
      EnableTektonOCIBundles: true
      EnforceNonfalsifiability: none
      MaxResultSize: 4096
      RequireGitSSHSecretKnownHosts: false
      ResultExtractionMethod: termination-message
      RunningInEnvWithInjectedSidecars: true
      ScopeWhenExpressionsToTask: false
      SendCloudEventsForRuns: false
      SetSecurityContext: false
      VerificationNoMatchPolicy: ignore
  startTime: "2023-11-18T11:06:31Z"

Steps to Reproduce the Problem

  1. Create the above yaml in the cluster.

Additional Info

  • Kubernetes version:

    Output of kubectl version:

$ kubectl version
Client Version: v1.28.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.27.5
  • Tekton Pipeline version:
$ tkn version
Client version: 0.33.0
Pipeline version: v0.53.2

# This issue also exists in Pipeline version: 0.41.x.

I’ve also read the documentation, is this possibly what you anticipated?

@l-qing l-qing added the kind/bug Categorizes issue or PR as related to a bug. label Nov 18, 2023
@Yongxuanzhang
Copy link
Member

/assign

@l-qing
Copy link
Contributor Author

l-qing commented Nov 25, 2023

@Yongxuanzhang It seems that toggling this feature(#6816) does not solve my problem?

I am using Tekton Pipeline v0.53.2 and have modified the feature flag enable-api-fields: alpha, but the problem persists.

@Yongxuanzhang
Copy link
Member

@Yongxuanzhang It seems that toggling this feature(#6816) does not solve my problem?

I am using Tekton Pipeline v0.53.2 and have modified the feature flag enable-api-fields: alpha, but the problem persists.

Sorry I was on vocation last week. Will take a look now!

@Yongxuanzhang
Copy link
Member

Hi, I think the bug is fixed, please let me know if there are any other issues

@l-qing
Copy link
Contributor Author

l-qing commented Dec 12, 2023

Hi, I think the bug is fixed, please let me know if there are any other issues

Very well, I’ll come back to report if I encounter others. 😆

@Yongxuanzhang
Copy link
Member

Hi, I think the bug is fixed, please let me know if there are any other issues

Very well, I’ll come back to report if I encounter others. 😆

Thanks!!

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants