Skip to content

Commit f2a7498

Browse files
committed
kueue: skip old platform param if new param exists
We came across a pipelinerun that was using the new parameter format to parameterize the old template format via a matrix definition. While it's likely that the pipelinerun is doing extra configuration here that it doesn't need to (it had `PLATFORM` defined in both matrix params and task params), tekton doesn't reject it. Therefore, we need to consider the possibility that these pipelineruns may exist - tekton-kueue will need to handle such pipelines without issues. The problem in the pipelinerun that caused issues was that the old platform parameter was populated with substitution data that cannot fit inside a label. The CEL expressions don't run against the data that has been substituted in (that would require us to monitor TaskRuns instead), so they would try to create labels with invalid characters, which would be rejected by kubernetes. Since the old platforms parameter will only contain garbage like this, and this can happen only if the new platform parameter is populated, only extract the old parameter if the new parameter isn't exist. See KONFLUX-9917 for further details. Fixes: KONFLUX-9917 Signed-off-by: Andy Sadler <[email protected]>
1 parent 8bd5cc2 commit f2a7498

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

components/kueue/development/tekton-kueue/config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ cel:
3838
3939
# Set resource requests for multi platform pipelines which doesn't use the build-platforms parameter (old style)
4040
- |
41+
!(
42+
has(pipelineRun.spec.params) &&
43+
pipelineRun.spec.params.exists(p, p.name == 'build-platforms')
44+
) &&
4145
has(pipelineRun.spec.pipelineSpec) &&
4246
has(pipelineRun.spec.pipelineSpec.tasks) &&
4347
pipelineRun.spec.pipelineSpec.tasks.size() > 0 ?
@@ -53,6 +57,10 @@ cel:
5357
5458
# Request AWS IP for AWS-based platforms which doesn't use the build-platforms parameter (old style)
5559
- |
60+
!(
61+
has(pipelineRun.spec.params) &&
62+
pipelineRun.spec.params.exists(p, p.name == 'build-platforms')
63+
) &&
5664
has(pipelineRun.spec.pipelineSpec) &&
5765
has(pipelineRun.spec.pipelineSpec.tasks) &&
5866
pipelineRun.spec.pipelineSpec.tasks.size() > 0 ?

components/kueue/staging/base/tekton-kueue/config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ cel:
3838
3939
# Set resource requests for multi platform pipelines which doesn't use the build-platforms parameter (old style)
4040
- |
41+
!(
42+
has(pipelineRun.spec.params) &&
43+
pipelineRun.spec.params.exists(p, p.name == 'build-platforms')
44+
) &&
4145
has(pipelineRun.spec.pipelineSpec) &&
4246
has(pipelineRun.spec.pipelineSpec.tasks) &&
4347
pipelineRun.spec.pipelineSpec.tasks.size() > 0 ?
@@ -53,6 +57,10 @@ cel:
5357
5458
# Request AWS IP for AWS-based platforms which doesn't use the build-platforms parameter (old style)
5559
- |
60+
!(
61+
has(pipelineRun.spec.params) &&
62+
pipelineRun.spec.params.exists(p, p.name == 'build-platforms')
63+
) &&
5664
has(pipelineRun.spec.pipelineSpec) &&
5765
has(pipelineRun.spec.pipelineSpec.tasks) &&
5866
pipelineRun.spec.pipelineSpec.tasks.size() > 0 ?

hack/test-tekton-kueue-config.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,65 @@ def check_prerequisites(should_print: bool = True) -> Dict[str, TestConfig]:
590590
}
591591
},
592592

593+
"prefer-new-parameters": {
594+
"name": "Only use new platform parameters when both old and new parameters exist",
595+
"pipelinerun": {
596+
"apiVersion": "tekton.dev/v1",
597+
"kind": "PipelineRun",
598+
"metadata": {
599+
"name": "prefer-new-platform-parameters",
600+
"namespace": "default",
601+
"labels": {
602+
"pipelinesascode.tekton.dev/event-type": "push",
603+
}
604+
},
605+
"spec": {
606+
"pipelineRef": {"name": "build-pipeline"},
607+
"params": [
608+
{
609+
"name": "build-platforms",
610+
"value": ["linux/amd64", "linux/arm64", "linux/s390x"]
611+
},
612+
{
613+
"name": "other-param",
614+
"value": "test"
615+
}
616+
],
617+
"pipelineSpec": {
618+
"tasks": [
619+
{
620+
"name": "build-task-amd64",
621+
"params": [{"name": "PLATFORM", "value": "linux/amd64"}],
622+
"taskRef": {"name": "build-task"}
623+
},
624+
{
625+
"name": "build-task-arm64",
626+
"params": [{"name": "PLATFORM", "value": "linux/arm64"}],
627+
"taskRef": {"name": "build-task"}
628+
},
629+
{
630+
"name": "other-task",
631+
"taskRef": {"name": "other-task"}
632+
}
633+
]
634+
},
635+
"workspaces": [{"name": "shared-workspace", "emptyDir": {}}]
636+
}
637+
},
638+
"expected": {
639+
"annotations": {
640+
"kueue.konflux-ci.dev/requests-linux-amd64": "1",
641+
"kueue.konflux-ci.dev/requests-linux-s390x": "1",
642+
"kueue.konflux-ci.dev/requests-linux-arm64": "1",
643+
"kueue.konflux-ci.dev/requests-aws-ip": "2",
644+
},
645+
"labels": {
646+
"kueue.x-k8s.io/queue-name": "pipelines-queue",
647+
"kueue.x-k8s.io/priority-class": "konflux-post-merge-build",
648+
}
649+
}
650+
},
651+
593652
}
594653

595654
# Configuration combinations that can be applied to any PipelineRun
@@ -660,6 +719,10 @@ def check_prerequisites(should_print: bool = True) -> Dict[str, TestConfig]:
660719
"pipelinerun_key": "mixed_platforms_excluded_included",
661720
"config_key": "development"
662721
},
722+
"prefer_new_parameters_dev": {
723+
"pipelinerun_key": "prefer-new-parameters",
724+
"config_key": "development"
725+
},
663726

664727
# multiplatform_old edge cases
665728
"multiplatform_old_no_pipelineSpecTasks": {
@@ -688,6 +751,10 @@ def check_prerequisites(should_print: bool = True) -> Dict[str, TestConfig]:
688751
"pipelinerun_key": "mintmaker",
689752
"config_key": "staging"
690753
},
754+
"prefer_new_parameters_staging": {
755+
"pipelinerun_key": "prefer-new-parameters",
756+
"config_key": "staging"
757+
},
691758

692759
# Test key PipelineRuns with production config
693760
"multiplatform_new_production": {

0 commit comments

Comments
 (0)