From faa9fcb8d23132f108bb499eb46121729c6c6020 Mon Sep 17 00:00:00 2001 From: Jan Hutar Date: Tue, 17 Dec 2024 21:06:45 +0100 Subject: [PATCH] feat(KONFLUX-5670): Define computeResources for prefetch-dependencies tasks --- task-generator/trusted-artifacts/go.mod | 2 +- .../trusted-artifacts/golden/git-clone/ta.yaml | 7 +++++++ .../golden/prefetch-dependencies/ta.yaml | 7 +++++++ task-generator/trusted-artifacts/ta.go | 11 +++++++++++ task/git-clone-oci-ta/0.1/git-clone-oci-ta.yaml | 7 +++++++ .../0.1/prefetch-dependencies-oci-ta.yaml | 14 ++++++++++++++ .../0.1/prefetch-dependencies.yaml | 7 +++++++ 7 files changed, 54 insertions(+), 1 deletion(-) diff --git a/task-generator/trusted-artifacts/go.mod b/task-generator/trusted-artifacts/go.mod index 9ca88c966d..deddfc7536 100644 --- a/task-generator/trusted-artifacts/go.mod +++ b/task-generator/trusted-artifacts/go.mod @@ -8,6 +8,7 @@ require ( github.com/tektoncd/pipeline v0.66.0 github.com/zregvart/tkn-fmt v0.0.0-20240614122620-a2995427266c k8s.io/api v0.30.1 + k8s.io/apimachinery v0.30.1 mvdan.cc/sh/v3 v3.10.0 sigs.k8s.io/kustomize/api v0.18.0 sigs.k8s.io/kustomize/kyaml v0.18.1 @@ -87,7 +88,6 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apimachinery v0.30.1 // indirect k8s.io/client-go v0.30.1 // indirect k8s.io/klog/v2 v2.120.1 // indirect k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a // indirect diff --git a/task-generator/trusted-artifacts/golden/git-clone/ta.yaml b/task-generator/trusted-artifacts/golden/git-clone/ta.yaml index 40c71aa88e..c29fb3d0e4 100644 --- a/task-generator/trusted-artifacts/golden/git-clone/ta.yaml +++ b/task-generator/trusted-artifacts/golden/git-clone/ta.yaml @@ -255,6 +255,13 @@ spec: env: - name: IMAGE_EXPIRES_AFTER value: $(params.ociArtifactExpiresAfter) + computeResources: + limits: + cpu: "1" + memory: 3Gi + requests: + cpu: "1" + memory: 3Gi volumeMounts: - name: workdir mountPath: /var/workdir diff --git a/task-generator/trusted-artifacts/golden/prefetch-dependencies/ta.yaml b/task-generator/trusted-artifacts/golden/prefetch-dependencies/ta.yaml index 620a81b790..6ab24b0f78 100644 --- a/task-generator/trusted-artifacts/golden/prefetch-dependencies/ta.yaml +++ b/task-generator/trusted-artifacts/golden/prefetch-dependencies/ta.yaml @@ -152,6 +152,13 @@ spec: env: - name: IMAGE_EXPIRES_AFTER value: $(params.ociArtifactExpiresAfter) + computeResources: + limits: + cpu: "1" + memory: 3Gi + requests: + cpu: "1" + memory: 3Gi args: - create - --store diff --git a/task-generator/trusted-artifacts/ta.go b/task-generator/trusted-artifacts/ta.go index 19e1c5760a..f826865402 100644 --- a/task-generator/trusted-artifacts/ta.go +++ b/task-generator/trusted-artifacts/ta.go @@ -12,6 +12,7 @@ import ( "github.com/google/go-containerregistry/pkg/v1/remote" pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" core "k8s.io/api/core/v1" + resource "k8s.io/apimachinery/pkg/api/resource" ) var ( @@ -334,6 +335,16 @@ func perform(task *pipeline.Task, recipe *Recipe) error { }, }, Args: args, + ComputeResources: core.ResourceRequirements{ + Requests: core.ResourceList{ + core.ResourceCPU: resource.MustParse("1"), + core.ResourceMemory: resource.MustParse("3Gi"), + }, + Limits: core.ResourceList{ + core.ResourceCPU: resource.MustParse("1"), + core.ResourceMemory: resource.MustParse("3Gi"), + }, + }, } if task.Spec.StepTemplate == nil && !recipe.PreferStepTemplate { diff --git a/task/git-clone-oci-ta/0.1/git-clone-oci-ta.yaml b/task/git-clone-oci-ta/0.1/git-clone-oci-ta.yaml index 3629da9fd7..7cdc186fb6 100644 --- a/task/git-clone-oci-ta/0.1/git-clone-oci-ta.yaml +++ b/task/git-clone-oci-ta/0.1/git-clone-oci-ta.yaml @@ -310,3 +310,10 @@ spec: env: - name: IMAGE_EXPIRES_AFTER value: $(params.ociArtifactExpiresAfter) + computeResources: + limits: + cpu: "1" + memory: 3Gi + requests: + cpu: "1" + memory: 3Gi diff --git a/task/prefetch-dependencies-oci-ta/0.1/prefetch-dependencies-oci-ta.yaml b/task/prefetch-dependencies-oci-ta/0.1/prefetch-dependencies-oci-ta.yaml index 87deeb25b5..0a46254d53 100644 --- a/task/prefetch-dependencies-oci-ta/0.1/prefetch-dependencies-oci-ta.yaml +++ b/task/prefetch-dependencies-oci-ta/0.1/prefetch-dependencies-oci-ta.yaml @@ -394,6 +394,13 @@ spec: cachi2 --log-level="$LOG_LEVEL" inject-files /var/workdir/cachi2/output \ --for-output-dir=/cachi2/output + computeResources: + limits: + cpu: "1" + memory: 3Gi + requests: + cpu: "1" + memory: 3Gi - name: unregister-rhsm image: quay.io/redhat-appstudio/cachi2:0.15.0@sha256:b141cb5cf4d98e6c5f668f1fe172e1d68f2a44ac1027403fbcff94ce1e68185d script: | @@ -417,3 +424,10 @@ spec: env: - name: IMAGE_EXPIRES_AFTER value: $(params.ociArtifactExpiresAfter) + computeResources: + limits: + cpu: "1" + memory: 3Gi + requests: + cpu: "1" + memory: 3Gi diff --git a/task/prefetch-dependencies/0.1/prefetch-dependencies.yaml b/task/prefetch-dependencies/0.1/prefetch-dependencies.yaml index 9a859d42de..dd85f25c74 100644 --- a/task/prefetch-dependencies/0.1/prefetch-dependencies.yaml +++ b/task/prefetch-dependencies/0.1/prefetch-dependencies.yaml @@ -255,6 +255,13 @@ spec: readOnly: true - mountPath: /activation-key name: activation-key + computeResources: + limits: + cpu: '1' + memory: 3Gi + requests: + cpu: '1' + memory: 3Gi script: | #!/bin/bash