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

Disable Matrix Validation for non Matrix Pipelines #8088

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pkg/apis/pipeline/v1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,16 @@ func validateGraph(tasks []PipelineTask) (errs *apis.FieldError) {
}

func validateMatrix(ctx context.Context, tasks []PipelineTask) (errs *apis.FieldError) {
hasMatrix := false
for idx, task := range tasks {
errs = errs.Also(task.validateMatrix(ctx).ViaIndex(idx))
if task.IsMatrixed() {
errs = errs.Also(task.validateMatrix(ctx).ViaIndex(idx))
hasMatrix = true
}
}
if hasMatrix {
errs = errs.Also(validateTaskResultsFromMatrixedPipelineTasksConsumed(tasks))
}
errs = errs.Also(validateTaskResultsFromMatrixedPipelineTasksConsumed(tasks))
return errs
}

Expand Down
16 changes: 16 additions & 0 deletions test/e2e-tests-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,30 @@ header "Create resources at previous release version"
kubectl create namespace upgrade
trap "kubectl delete namespace upgrade" EXIT
kubectl create -f ./test/upgrade/simpleResources.yaml || fail_test
kubectl create -f ./test/upgrade/resultRefResources.yaml || fail_test

# Upgrade to the current release.
header "Upgrade to the current release of Tekton pipeline"
install_pipeline_crd

initRestartCount=$(kubectl get pods -o=jsonpath='{.items[?(@.metadata.labels.app=="tekton-pipelines-controller")].status.containerStatuses[0].restartCount}' -n ${SYSTEM_NAMESPACE})

# Create runs from the Task and Pipeline resources created at the previous release version
header "Creating TaskRuns and PipelineRuns referencing existing Tasks and Pipelines"
kubectl create -f ./test/upgrade/simpleRuns.yaml || fail_test
kubectl create -f ./test/upgrade/resultRefRuns.yaml || fail_test

for i in $(kc get pr -o=custom-columns=NAMENAME:.metadata.name --no-headers);
do kubectl wait --for=jsonpath='{.status.conditions[0].reason}'=Succeeded pipelinerun $i;
done

curRestartCount=$(kubectl get pods -o=jsonpath='{.items[?(@.metadata.labels.app=="tekton-pipelines-controller")].status.containerStatuses[0].restartCount}' -n ${SYSTEM_NAMESPACE})

if [ ${initRestartCount} -ne ${curRestartCount} ];
echo "controller restarted"
then fail_test;
fi


# Run the post-integration tests. We do not need to install the resources again, since
# they are installed before the upgrade. We verify if they still work, after going through
Expand Down
64 changes: 64 additions & 0 deletions test/upgrade/resultRefResources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: add-task
spec:
params:
- name: first
description: the first operand
- name: second
description: the second operand
results:
- name: sum
description: the sum of the first and second operand
steps:
- name: add
image: alpine
env:
- name: OP1
value: $(params.first)
- name: OP2
value: $(params.second)
command: ["/bin/sh", "-c"]
args:
- echo -n $((${OP1}+${OP2})) | tee $(results.sum.path);
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: sum-three-pipeline
spec:
params:
- name: first
description: the first operand
- name: second
description: the second operand
- name: third
description: the third operand
tasks:
- name: first-add
taskRef:
name: add-task
params:
- name: first
value: $(params.first)
- name: second
value: $(params.second)
- name: second-add
taskRef:
name: add-task
params:
- name: first
value: $(tasks.first-add.results.sum)
- name: second
value: $(tasks.first-add.results.sum) - $(sum)
results:
- name: sum
description: the sum of all three operands
value: $(tasks.second-add.results.sum)
- name: partial-sum
description: the sum of first two operands
value: $(tasks.first-add.results.sum)
- name: all-sum
description: the sum of everything
value: $(tasks.second-add.results.sum)-$(tasks.first-add.results.sum)
14 changes: 14 additions & 0 deletions test/upgrade/resultRefRuns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
name: resultRefRun
spec:
pipelineRef:
name: sum-three-pipeline
params:
- name: first
value: "2"
- name: second
value: "10"
- name: third
value: "10"
Loading