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

Task with variable resource params #1548

Closed
faust64 opened this issue Nov 10, 2019 · 7 comments
Closed

Task with variable resource params #1548

faust64 opened this issue Nov 10, 2019 · 7 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/duplicate Indicates an issue is a duplicate of other open issue.

Comments

@faust64
Copy link

faust64 commented Nov 10, 2019

Trying to setup a generic task with params involving per-container resource limits/requests.

Expected Behavior

Should be able to create task.

Actual Behavior

Can't create task.

$ oc apply -f task.yaml
Error from server (InternalError): error when applying patch:
{"metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"tekton.dev/v1alpha1\",\"kind\":\"Task\",\"metadata\":{\"annotations\":{},\"name\":\"docker-build\",\"namespace\":\"cicd\"},\"spec\":{\"inputs\":{\"params\":[{\"default\":\"quay.io/buildah/stable\",\"description\":\"The location of the buildah builder image.\",\"name\":\"builderimage\",\"type\":\"string\"},{\"default\":\"100m\",\"description\":\"CPU Limit\",\"name\":\"cpulimit\",\"type\":\"string\"},{\"default\":\"100m\",\"description\":\"CPU Request\",\"name\":\"cpurequest\",\"type\":\"string\"},{\"default\":\"./Dockerfile\",\"description\":\"Path to the Dockerfile to build.\",\"name\":\"dockerfile\",\"type\":\"string\"},{\"default\":\"256Mi\",\"description\":\"Memory Limit\",\"name\":\"memorylimit\",\"type\":\"string\"},{\"default\":\"256Mi\",\"description\":\"Memory Request\",\"name\":\"memoryrequest\",\"type\":\"string\"},{\"default\":\"\",\"description\":\"Forces FROM in Dockerfile.\",\"name\":\"fromimage\",\"type\":\"string\"},{\"default\":\"true\",\"description\":\"Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)\",\"name\":\"tlsverify\",\"type\":\"string\"}],\"resources\":[{\"name\":\"source\",\"type\":\"git\"}]},\"outputs\":{\"resources\":[{\"name\":\"image\",\"type\":\"image\"}]},\"steps\":[{\"command\":[\"/bin/bash\",\"-c\",\"if test \\\"$(inputs.params.fromimage)\\\"; then sed -i \\\"s|^[ ]*FROM[ ]*[^ ]*$|FROM $(inputs.params.fromimage)|\\\" \\\"$(inputs.params.dockerfile)\\\"; fi\"],\"image\":\"$(inputs.params.builderimage)\",\"name\":\"patch-from\",\"workingDir\":\"/workspace/source\"},{\"command\":[\"buildah\",\"bud\",\"--tls-verify=$(inputs.params.tlsverify)\",\"--layers\",\"-f\",\"$(inputs.params.dockerfile)\",\"-t\",\"$(outputs.resources.image.url)\",\".\"],\"image\":\"$(inputs.params.builderimage)\",\"name\":\"build\",\"resources\":{\"limits\":{\"cpu\":\"$(inputs.params.cpulimit)\",\"memory\":\"$(inputs.params.memorylimit)\"},\"requests\":{\"cpu\":\"$(inputs.params.cpurequest)\",\"memory\":\"$(inputs.params.memoryrequest)\"}},\"securityContext\":{\"privileged\":true},\"volumeMounts\":[{\"mountPath\":\"/var/lib/containers\",\"name\":\"varlibcontainers\"}],\"workingDir\":\"/workspace/source\"},{\"command\":[\"buildah\",\"push\",\"--tls-verify=$(inputs.params.tlsverify)\",\"$(outputs.resources.image.url)\",\"docker://$(outputs.resources.image.url)\"],\"image\":\"$(inputs.params.builderimage)\",\"name\":\"push\",\"securityContext\":{\"privileged\":true},\"volumeMounts\":[{\"mountPath\":\"/var/lib/containers\",\"name\":\"varlibcontainers\"}],\"workingDir\":\"/workspace/source\"}],\"volumes\":[{\"emptyDir\":{},\"name\":\"varlibcontainers\"}]}}\n"}},"spec":{"inputs":{"params":[{"default":"quay.io/buildah/stable","description":"The location of the buildah builder image.","name":"builderimage","type":"string"},{"default":"100m","description":"CPU Limit","name":"cpulimit","type":"string"},{"default":"100m","description":"CPU Request","name":"cpurequest","type":"string"},{"default":"./Dockerfile","description":"Path to the Dockerfile to build.","name":"dockerfile","type":"string"},{"default":"256Mi","description":"Memory Limit","name":"memorylimit","type":"string"},{"default":"256Mi","description":"Memory Request","name":"memoryrequest","type":"string"},{"default":"","description":"Forces FROM in Dockerfile.","name":"fromimage","type":"string"},{"default":"true","description":"Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)","name":"tlsverify","type":"string"}]},"outputs":{"resources":[{"name":"image","type":"image"}]},"steps":[{"command":["/bin/bash","-c","if test \"$(inputs.params.fromimage)\"; then sed -i \"s|^[ ]*FROM[ ]*[^ ]*$|FROM $(inputs.params.fromimage)|\" \"$(inputs.params.dockerfile)\"; fi"],"image":"$(inputs.params.builderimage)","name":"patch-from","workingDir":"/workspace/source"},{"command":["buildah","bud","--tls-verify=$(inputs.params.tlsverify)","--layers","-f","$(inputs.params.dockerfile)","-t","$(outputs.resources.image.url)","."],"image":"$(inputs.params.builderimage)","name":"build","resources":{"limits":{"cpu":"$(inputs.params.cpulimit)","memory":"$(inputs.params.memorylimit)"},"requests":{"cpu":"$(inputs.params.cpurequest)","memory":"$(inputs.params.memoryrequest)"}},"securityContext":{"privileged":true},"volumeMounts":[{"mountPath":"/var/lib/containers","name":"varlibcontainers"}],"workingDir":"/workspace/source"},{"command":["buildah","push","--tls-verify=$(inputs.params.tlsverify)","$(outputs.resources.image.url)","docker://$(outputs.resources.image.url)"],"image":"$(inputs.params.builderimage)","name":"push","securityContext":{"privileged":true},"volumeMounts":[{"mountPath":"/var/lib/containers","name":"varlibcontainers"}],"workingDir":"/workspace/source"}]}}
to:
Resource: "tekton.dev/v1alpha1, Resource=tasks", GroupVersionKind: "tekton.dev/v1alpha1, Kind=Task"
Name: "docker-build", Namespace: "cicd"
Object: &{map["apiVersion":"tekton.dev/v1alpha1" "kind":"Task" "metadata":map["creationTimestamp":"2019-11-10T15:20:05Z" "generation":'\x02' "name":"docker-build" "namespace":"cicd" "ownerReferences":[map["apiVersion":"wopla.io/v1alpha1" "kind":"Ci" "name":"sweet" "uid":"00201c75-f8bb-11e9-8b94-52540069748c"]] "resourceVersion":"16292423" "selfLink":"/apis/tekton.dev/v1alpha1/namespaces/cicd/tasks/docker-build" "uid":"9291ff1d-03cd-11ea-b813-52540079f30f"] "spec":map["inputs":map["params":[map["default":"quay.io/buildah/stable" "description":"The location of the buildah builder image." "name":"builderimage" "type":"string"] map["default":"" "description":"Forces FROM in Dockerfile." "name":"fromimage" "type":"string"] map["default":"./Dockerfile" "description":"Path to the Dockerfile to build." "name":"dockerfile" "type":"string"] map["default":"true" "description":"Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)" "name":"tlsverify" "type":"string"]] "resources":[map["name":"source" "type":"git"]]] "outputs":map["resources":[map["name":"image" "outputImageDir":"/builder/home/image-outputs/image" "type":"image"]]] "steps":[map["command":["/bin/bash" "-c" "if test \"$(inputs.params.fromimage)\"; then sed -i \"s|^[ ]*FROM[ ]*[^ ]*$|FROM $(inputs.params.fromimage)|\" \"$(inputs.params.dockerfile)\"; fi"] "image":"$(inputs.params.builderimage)" "name":"patch-from" "resources":map[] "workingDir":"/workspace/source"] map["command":["buildah" "bud" "--tls-verify=$(inputs.params.tlsverify)" "--layers" "-f" "$(inputs.params.dockerfile)" "-t" "$(outputs.resources.image.url)" "."] "image":"$(inputs.params.builderimage)" "name":"build" "resources":map[] "securityContext":map["privileged":%!q(bool=true)] "volumeMounts":[map["mountPath":"/var/lib/containers" "name":"varlibcontainers"]] "workingDir":"/workspace/source"] map["command":["buildah" "push" "--tls-verify=$(inputs.params.tlsverify)" "$(outputs.resources.image.url)" "docker://$(outputs.resources.image.url)"] "image":"$(inputs.params.builderimage)" "name":"push" "resources":map[] "securityContext":map["privileged":%!q(bool=true)] "volumeMounts":[map["mountPath":"/var/lib/containers" "name":"varlibcontainers"]] "workingDir":"/workspace/source"]] "volumes":[map["emptyDir":map[] "name":"varlibcontainers"]]]]}
for: "task.yaml": Internal error occurred: admission webhook "webhook.tekton.dev" denied the request: mutation failed: cannot decode incoming new object: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'

Steps to Reproduce the Problem

  1. Try creating task from sample below

Additional Info

task.yaml:

apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: docker-build
  namespace: cicd
spec:
  inputs:
    params:
    - name: builderimage
      description: The location of the buildah builder image.
      default: quay.io/buildah/stable
      type: string
    - default: 100m
      description: CPU Limit
      name: cpulimit
      type: string
    - default: 100m
      description: CPU Request
      name: cpurequest
      type: string
    - name: dockerfile
      description: Path to the Dockerfile to build.
      default: ./Dockerfile
      type: string
    - default: 256Mi
      description: Memory Limit
      name: memorylimit
      type: string
    - default: 256Mi
      description: Memory Request
      name: memoryrequest
      type: string
    - name: fromimage
      description: Forces FROM in Dockerfile.
      default: ""
      type: string
    - name: tlsverify
      description: Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)
      default: "true"
      type: string
    resources:
    - name: source
      type: git
  outputs:
    resources:
    - name: image
      type: image
  steps:
  - name: patch-from
    image: $(inputs.params.builderimage)
    workingDir: /workspace/source
    command:
    - /bin/bash
    - -c
    - if test "$(inputs.params.fromimage)"; then sed -i "s|^[ ]*FROM[ ]*[^ ]*$|FROM $(inputs.params.fromimage)|" "$(inputs.params.dockerfile)"; fi
  - name: build
    image: $(inputs.params.builderimage)
    workingDir: /workspace/source
    command:
    - buildah
    - bud
    - --tls-verify=$(inputs.params.tlsverify)
    - --layers
    - -f
    - $(inputs.params.dockerfile)
    - -t
    - $(outputs.resources.image.url)
    - .
    resources:
      limits:
        cpu: "$(inputs.params.cpulimit)"
        memory: "$(inputs.params.memorylimit)"
      requests:
        cpu: "$(inputs.params.cpurequest)"
        memory: "$(inputs.params.memoryrequest)"
    volumeMounts:
    - name: varlibcontainers
      mountPath: /var/lib/containers
    securityContext:
      privileged: true
  - name: push
    image: $(inputs.params.builderimage)
    workingDir: /workspace/source
    command:
    - buildah
    - push
    - --tls-verify=$(inputs.params.tlsverify)
    - $(outputs.resources.image.url)
    - docker://$(outputs.resources.image.url)
    volumeMounts:
    - name: varlibcontainers
      mountPath: /var/lib/containers
    securityContext:
      privileged: true
  volumes:
  - name: varlibcontainers
    emptyDir: {}
@faust64
Copy link
Author

faust64 commented Nov 10, 2019

somewhat similar to #1514

@dibyom dibyom added the kind/bug Categorizes issue or PR as related to a bug. label Dec 3, 2019
@dibyom
Copy link
Member

dibyom commented Mar 12, 2020

This also looks related to #1530
I'm going to mark this as a duplicate and close this out and track the work for a better more general variable substitution over there.

@dibyom
Copy link
Member

dibyom commented Mar 12, 2020

triage/duplicate
/close

@tekton-robot
Copy link
Collaborator

@dibyom: Closing this issue.

In response to this:

triage/duplicate
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dibyom dibyom added the triage/duplicate Indicates an issue is a duplicate of other open issue. label Mar 12, 2020
@faust64
Copy link
Author

faust64 commented May 23, 2021

After over one year waiting for it, both linked cases are now closed.
Does this mean this won't be implemented after all?

@gaodan-fang
Copy link

Hi @faust64 , I met the same issue, did you happen to figure out any workaround for this problem?

@faust64
Copy link
Author

faust64 commented Aug 23, 2021

No.

Case has been close in favor of #1530 . Which was closed, for no reason. There's no follow-up. It used to be planned for 1.0, then 1.1. Now I have no idea.

It's been over a year I'm waiting for a fix, wasting resources over-allocating requests on all my jobs.
This is ridiculous. Coming from OpenShift, BuildConfig are still more interesting in that regards, when available.

I'm tempted to re-open a new case, as I can't re-open this on, while #1530 has been forgotten as well.
Free free to create a new one, @gaodan-fang

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. triage/duplicate Indicates an issue is a duplicate of other open issue.
Projects
None yet
Development

No branches or pull requests

4 participants