Skip to content

Commit

Permalink
Merge pull request #128 from stuartwdouglas/task-resource-limits
Browse files Browse the repository at this point in the history
Add task resource limits
  • Loading branch information
stuartwdouglas authored Jan 31, 2024
2 parents ad90730 + 0bc4d06 commit 67bb6e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/reconciler/taskrun/hostpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/go-logr/logr"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
v12 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/utils/strings/slices"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down Expand Up @@ -124,6 +125,8 @@ func (hp HostPool) Deallocate(r *ReconcileTaskRun, ctx context.Context, log *log
provision.Namespace = r.operatorNamespace
provision.Labels = map[string]string{TaskTypeLabel: TaskTypeClean, UserTaskName: tr.Name, UserTaskNamespace: tr.Namespace}
provision.Spec.TaskRef = &v1.TaskRef{Name: "clean-shared-host"}
compute := map[v12.ResourceName]resource.Quantity{v12.ResourceCPU: resource.MustParse("100m"), v12.ResourceMemory: resource.MustParse("128Mi")}
provision.Spec.ComputeResources = &v12.ResourceRequirements{Requests: compute, Limits: compute}
provision.Spec.Workspaces = []v1.WorkspaceBinding{{Name: "ssh", Secret: &v12.SecretVolumeSource{SecretName: selected.Secret}}}
provision.Spec.ServiceAccountName = ServiceAccountName //TODO: special service account for this
provision.Spec.Params = []v1.Param{
Expand Down
3 changes: 3 additions & 0 deletions pkg/reconciler/taskrun/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/redhat-appstudio/multi-platform-controller/pkg/aws"
"github.com/redhat-appstudio/multi-platform-controller/pkg/cloud"
"github.com/redhat-appstudio/multi-platform-controller/pkg/ibm"
"k8s.io/apimachinery/pkg/api/resource"
"regexp"

"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
Expand Down Expand Up @@ -553,6 +554,8 @@ func launchProvisioningTask(r *ReconcileTaskRun, ctx context.Context, log *logr.
provision.Labels = map[string]string{TaskTypeLabel: TaskTypeProvision, UserTaskNamespace: tr.Namespace, UserTaskName: tr.Name, AssignedHost: tr.Labels[AssignedHost]}
provision.Spec.TaskRef = &v1.TaskRef{Name: "provision-shared-host"}
provision.Spec.Workspaces = []v1.WorkspaceBinding{{Name: "ssh", Secret: &v12.SecretVolumeSource{SecretName: sshSecret}}}
compute := map[v12.ResourceName]resource.Quantity{v12.ResourceCPU: resource.MustParse("100m"), v12.ResourceMemory: resource.MustParse("128Mi")}
provision.Spec.ComputeResources = &v12.ResourceRequirements{Requests: compute, Limits: compute}
provision.Spec.ServiceAccountName = ServiceAccountName //TODO: special service account for this
provision.Spec.Params = []v1.Param{
{
Expand Down

0 comments on commit 67bb6e6

Please sign in to comment.