pipeline: Parameter substitution not working in ClusterTask.spec.steps.imagePullPolicy
Expected Behavior
This should work:
apiVersion: tekton.dev/v1beta1
kind: ClusterTask
metadata:
name: tssc-setup
spec:
params:
- name: ciWorkersImageRegesitryURI
type: string
default: quay.io
- name: ciWorkersImageRepositoryName
type: string
default: tssc
- name: ciWorkersImageTag
type: string
default: latest
- name: ciWorkersImagePullPolicy
type: string
default: IfNotPresent
steps:
- name: create-python-venv
image: $(params.ciWorkersImageRegesitryURI)/$(params.ciWorkersImageRepositoryName)/tssc-base:$(params.ciWorkersImageTag)
imagePullPolicy: $(params.ciWorkersImageRegesitryURI)
script: |
#!/usr/bin/env bash
echo hello world
Actual Behavior
Get the following error:
status:
completionTime: '2020-10-21T15:58:44Z'
conditions:
- lastTransitionTime: '2020-10-21T15:58:44Z'
message: TaskRun tssc-tekton-pipeline-maven-8xnhn-tssc-setup-225w4 has failed
reason: Failed
status: 'False'
type: Succeeded
startTime: '2020-10-21T15:58:44Z'
taskRuns:
tssc-tekton-pipeline-maven-8xnhn-tssc-setup-225w4:
pipelineTaskName: tssc-setup
status:
conditions:
- lastTransitionTime: '2020-10-21T15:58:44Z'
message: >-
Missing or invalid Task ian-tekton-test2/tssc-setup: Pod
"tssc-tekton-pipeline-maven-8xnhn-tssc-setup-225w4-pod-sn8w2" is
invalid: spec.containers[0].imagePullPolicy: Unsupported value:
"$(params.ciWorkersImagePullPolicy)": supported values: "Always",
"IfNotPresent", "Never"
reason: CouldntGetTask
status: 'False'
type: Succeeded
podName: ''
startTime: '2020-10-21T15:58:44Z'
It would apear from the error that for some reason variable substitution is not happenin gin the ClusterTask.spec.steps.imagePullPolicy value. I would have assumed that could do variable substitution in anything under ClusterTask.spec.steps.
Steps to Reproduce the Problem
- Create a cluster task with a step defining imagePullPolicy with a avlue from a parameter
- try to run the step
Additional Info
-
Kubernetes version:
Output of
kubectl version:
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.8", GitCommit:"9f2892aab98fe339f3bd70e3c470144299398ace", GitTreeState:"clean", BuildDate:"2020-08-13T16:12:48Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.3+012b3ec", GitCommit:"012b3ec", GitTreeState:"clean", BuildDate:"2020-07-24T07:23:10Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}
-
Tekton Pipeline version:
Output of
tkn versionorkubectl get pods -n tekton-pipelines -l app=tekton-pipelines-controller -o=jsonpath='{.items[0].metadata.labels.version}'
Installed via OpenShift Pipelines Operator, can’t find a tekton-pipelines-controller
OpenShift Pipelines Operator: 1.1.1 OpenShift-Pipelines: v0.14.3 OpenShift-Pipelines-Triggers: v0.6.1 OpenShift-Pipelines-ClusterTasks: v0.14
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (4 by maintainers)
Commits related to this issue
- Add variable expansion for ImagePullPolicy in Tasks Closes #3423 Add variable expansion in Tasks for fields: - `spec.steps[].imagePullPolicy` - `spec.sidecar[].imagePullPolicy` — committed to rinckm/pipeline by rinckm 4 years ago
- Add variable expansion for ImagePullPolicy in Tasks Closes #3423 Add variable expansion in Tasks for fields: - `spec.steps[].imagePullPolicy` - `spec.sidecar[].imagePullPolicy` — committed to rinckm/pipeline by rinckm 4 years ago
- Add variable expansion for ImagePullPolicy in Tasks Closes #3423 Add variable expansion in Tasks for fields: - `spec.steps[].imagePullPolicy` - `spec.sidecar[].imagePullPolicy` — committed to tektoncd/pipeline by rinckm 4 years ago
I want to allow that a user of the Task can specify the image and the corresponding imagePullPolicy. If the user specifies a released image he may want to use the imagePullPolicy ‘IfNotPresent’ to speed up things. If the user specifies a image with tag ‘latest’ he may want to use the imagePullPolicy ‘Always’ to really get the latest version.
Thanks for explaining your use cases @itewk and @rinckm , that makes perfect sense to me! I also looked at your examples more closely and I had this backwards 🤦♀️ - I thought we were adding a variable that allows you to grab the ImagePullPolicy that was already set (e.g. something like “echo $(steps.imagePullPolicy)”) but now i understand you want to SET the ImagePullPolicy at runtime which makes way more sense XD. (I can also see why you were confused by me saying this is “k8s specific” @vdemeester 🙏 😆 )
@bobcatfish my use case is being able to control at runtime when calling a pipeline whether to used the cached images or pull the latest. This comes in most handy when doing intigration testing of the workflow itself and testing with updated task container images.
This is likley a crazy ask, that i am guessing has already been discussed somewhere, but why isn’t there variable substitution in every field within
spec.steps? that would mean you arn’t doing any codeing specific tok8sapi and would mean when other fields are added arn’t having to maitain and remember a complicated list of which fields do and do not accept variable substitutionI would say, yes and no (on
imagePullPolicybeing “k8s specific stuff”). The field itself is k8s specific but the “feature” is more than k8s specific. It is tied to any container runtime (aka what should the runtime do in case of the image is present in its cache or not, …) and could probably be part of the conformance / api spec.The variable interpolation is selective and I am pretty sure we don’t go through the
imagePullPolicyfield. It’s more or less a one-liner to fix this though (see #3488)Hey @rinckm and all,
I want to explore this a bit before we add it since it seems to me like ImagePullPolicy is a very k8s specific thing and while we do add k8s specific stuff into our API I want to make sure we really need to before we do (https://github.com/tektoncd/community/blob/master/design-principles.md#conformance)
@vdemeester it sounds like you think we SHOULD replace this - do we replace other container spec fields?