From fdc1973b0bb0efb19ea575f4f3e70d69276f9a89 Mon Sep 17 00:00:00 2001 From: Pasquale Congiusti Date: Fri, 19 May 2023 16:08:04 +0200 Subject: [PATCH] chore(ctrl): enable max running pipelines --- pkg/apis/camel/v1/build_types.go | 4 ++-- pkg/controller/build/build_controller.go | 10 ++++++---- pkg/trait/builder.go | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/apis/camel/v1/build_types.go b/pkg/apis/camel/v1/build_types.go index 6a7107df90..4c309e997d 100644 --- a/pkg/apis/camel/v1/build_types.go +++ b/pkg/apis/camel/v1/build_types.go @@ -25,9 +25,9 @@ import ( // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. // Important: Run "make generate-deepcopy" to regenerate code after modifying this file -// PipelineSpec defines the Build operation to be executed +// PipelineSpec defines the Pipeline to be execute type PipelineSpec struct { - // The sequence of Build tasks to be performed as part of the Build execution. + // The sequence of Pipeline tasks to be performed. Tasks []Task `json:"tasks,omitempty"` // Timeout defines the Pipeline maximum execution duration. // The Pipeline deadline is set to the Pipeline start time plus the Timeout duration. diff --git a/pkg/controller/build/build_controller.go b/pkg/controller/build/build_controller.go index 354f84043d..065337a37f 100644 --- a/pkg/controller/build/build_controller.go +++ b/pkg/controller/build/build_controller.go @@ -141,11 +141,13 @@ func (r *reconcileBuild) Reconcile(ctx context.Context, request reconcile.Reques targetLog := rlog.ForBuild(target) var actions []Action - + ip, err := platform.GetOrFindForResource(ctx, r.client, &instance, true) + if err != nil { + rlog.Error(err, "Could not find a platform bound to this Build") + return reconcile.Result{}, err + } buildMonitor := Monitor{ - // TODO enable this where we have the MaxRunningPipelines (the platform likely) - // maxRunningBuilds: instance.Spec.MaxRunningBuilds, - maxRunningBuilds: 10, + maxRunningBuilds: ip.Status.Pipeline.MaxRunningPipelines, } switch instance.BuilderConfiguration().Strategy { diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go index a96ddee153..317ecd4d66 100644 --- a/pkg/trait/builder.go +++ b/pkg/trait/builder.go @@ -245,7 +245,7 @@ func getImageName(e *Environment) string { } func (t *builderTrait) customTasks() []v1.Task { - customTasks := make([]v1.Task, 0, len(t.Tasks)) + customTasks := make([]v1.Task, len(t.Tasks), len(t.Tasks)) for i, t := range t.Tasks { // TODO, better strategy than a simple split! splitted := strings.Split(t, ";")