You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "claudio4j (via GitHub)" <gi...@apache.org> on 2023/05/17 16:45:54 UTC

[GitHub] [camel-k] claudio4j commented on a diff in pull request #4384: feat: enable generic Pipeline

claudio4j commented on code in PR #4384:
URL: https://github.com/apache/camel-k/pull/4384#discussion_r1196801685


##########
pkg/trait/builder.go:
##########
@@ -148,52 +149,59 @@ func (t *builderTrait) Apply(e *Environment) error {
 			ExecutorImage: executorImage,
 		}})
 	}
-
-	if t.Strategy != "" {
-		t.L.Infof("User defined build strategy %s", t.Strategy)
-		switch t.Strategy {
-		case string(v1.BuildStrategyPod):
-			e.BuildConfiguration.Strategy = v1.BuildStrategyPod
-		case string(v1.BuildStrategyRoutine):
-			e.BuildConfiguration.Strategy = v1.BuildStrategyRoutine
-		default:
-			return fmt.Errorf("must specify either pod or routine build strategy, unknown %s", t.Strategy)
-		}
-	}
-
-	if t.RequestCPU != "" {
-		e.BuildConfiguration.RequestCPU = t.RequestCPU
-	}
-	if t.RequestMemory != "" {
-		e.BuildConfiguration.RequestMemory = t.RequestMemory
-	}
-	if t.LimitCPU != "" {
-		e.BuildConfiguration.LimitCPU = t.LimitCPU
-	}
-	if t.LimitMemory != "" {
-		e.BuildConfiguration.LimitMemory = t.LimitMemory
-	}
-
 	return nil
 }
 
 func (t *builderTrait) builderTask(e *Environment) (*v1.BuilderTask, error) {
 	maven := v1.MavenBuildSpec{
-		MavenSpec: e.Platform.Status.Build.Maven,
+		MavenSpec: e.Platform.Status.Pipeline.Maven,
 	}
 	// Add Maven repositories defined in the IntegrationKit
 	for _, repo := range e.IntegrationKit.Spec.Repositories {
 		maven.Repositories = append(maven.Repositories, mvn.NewRepository(repo))
 	}
 
+	if trait := e.Catalog.GetTrait(quarkusTraitID); trait != nil {
+		// The builder trait must define certain resources requirements when we have a native build
+		if quarkus, ok := trait.(*quarkusTrait); ok && pointer.BoolDeref(quarkus.Enabled, true) && quarkus.isNativeIntegration(e) {
+			// Force the build to run in a separate Pod
+			t.L.Info("This is a Quarkus native build: setting build configuration with build Pod strategy, 1 CPU core and 4 GiB memory. Make sure your cluster can handle it.")
+			t.Strategy = string(v1.BuildStrategyPod)
+			t.RequestCPU = "1000m"
+			t.RequestMemory = "4Gi"

Review Comment:
   Having a `native` settings for CPU/memory would be interesting for users who want to also customize these settings for native. Thinking on another level, it could be the native requirements are 2x or 3x the regular minimum, alternatively the operator could enhance this behavior, by verifying if the build failed for OOME and automatically increase the memory.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org