Bug 1970493

Summary: stepTemplate limits and requests are not applied in init-container for Tekton clusterTask
Product: Red Hat OpenShift Pipelines Reporter: Gabriel Meghnagi <gmeghnag>
Component: pipelinesAssignee: Vincent Demeester <vdemeest>
Status: ASSIGNED --- QA Contact: Ruchir Garg <rgarg>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 1.4CC: anowak, cpassare, marrober, ppitonak, vdemeest
Target Milestone: ---   
Target Release: 1.6   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gabriel Meghnagi 2021-06-10 14:59:48 UTC
Description of problem:

Resource limits and requests specified in {.spec.stepTemplate} for ClusterTask are not applied to the init-containers but only to the step containers;


Version-Release number of selected component (if applicable):
1.4

How reproducible:

100%

Steps to Reproduce:

1. Create ClusterTask with stepTemplate resource limits.

2. Start the clusterTask

3. using oc describe <taskrun generated pod>, verify that the limits and requests are only applied to the step containers and not to the init-containers.

Actual results:

The limits and requests are only applied to the step containers and not to the init-containers.


Expected results:

The limits and requests should be also applied to init-containers.

Additional info:

In case the project has LimitRange with {.spec.limits.default} field setted, the init-container takes the limits/requests from the LimitRange and not from the stepTemplate defined in the clusterTask resource.

Comment 4 Vincent Demeester 2021-08-30 12:22:33 UTC
For what is worth, this should be handled by the following work-in-progress PR upstream : https://github.com/tektoncd/pipeline/pull/4176

Comment 5 Mark Roberts 2022-02-08 09:26:51 UTC
I am seeing the same result when I move the resource limits from the specTemplate to the step as per the example below :

kind: Task
apiVersion: tekton.dev/v1beta1
metadata:
  name: test02
spec:  
  steps:
  - name: test
    image: alpine
    script: |
      echo EXECUTED
    resources:
      limits:
        cpu: "2"
        memory: 1Gi
      requests:
        cpu: "1"
        memory: 500Mi


My quota defintion applied to the project is :

apiVersion: v1
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: cust-quota
  spec:
    hard:
      limits.cpu: "4"
      limits.memory: 8Gi
      pods: "20"
      requests.cpu: "4"
      requests.memory: 8Gi
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

The only difference in this example is that the pod never appears for investigation and the taskrun result shows a message of :

failed to create task run pod "test02": pods "test02-pod-nvrd4" is forbidden: failed quota: cust-quota: must specify limits.cpu,limits.memory,requests.cpu,requests.memory. Maybe missing or invalid Task liberty-rest-gogs/test02

The task is present and perfectly valid as it works fine when the quota is removed.

Comment 10 Vincent Demeester 2022-07-19 09:11:46 UTC
Ah you are right. What got fixed in 1.6 is the fact that LimitRange where not applied to init container. But StepTemplate is, indeed not applied to to init containers. I think this is by designed, as init containers are not steps.

There have been evolution around this in the most recent version of Tekton Pipelines, mainly https://github.com/tektoncd/pipeline/pull/5059. This probably be something fixed in 1.9 (hopefully), but it's probably going to be very hard to backport it to 1.6 (as a lot of things changed since then).