astefanutti commented on a change in pull request #844: fix build-pod strategy 
on kubernetes
URL: https://github.com/apache/camel-k/pull/844#discussion_r305432207
 
 

 ##########
 File path: pkg/controller/build/schedule_pod.go
 ##########
 @@ -77,70 +75,45 @@ func (action *schedulePodAction) Handle(ctx 
context.Context, build *v1alpha1.Bui
 
        // Emulate a serialized working queue to only allow one build to run at 
a given time.
        // This is currently necessary for the incremental build to work as 
expected.
-       hasScheduledBuild := false
        for _, b := range builds.Items {
                if b.Status.Phase == v1alpha1.BuildPhasePending || 
b.Status.Phase == v1alpha1.BuildPhaseRunning {
-                       hasScheduledBuild = true
-                       break
+                       // Let's requeue the build in case one is already 
running
+                       return nil, nil
                }
        }
 
-       if hasScheduledBuild {
-               // Let's requeue the build in case one is already running
-               return nil, nil
-       }
-
-       // Try to get operator image name before starting the build
-       operatorImage, err := platform.GetCurrentOperatorImage(ctx, 
action.client)
+       pod, err := getBuilderPod(ctx, action.client, build)
        if err != nil {
                return nil, err
        }
 
-       // Otherwise, let's create the build pod
-       // We may want to explicitly manage build priority as opposed to 
relying on
-       // the reconcile loop to handle the queuing
-       pod := newBuildPod(build, operatorImage)
-
-       // Set the Build instance as the owner and controller
-       if err := controllerutil.SetControllerReference(build, pod, 
action.client.GetScheme()); err != nil {
-               return nil, err
-       }
+       if pod == nil {
+               // Try to get operator image name before starting the build
+               operatorImage, err := platform.GetCurrentOperatorImage(ctx, 
action.client)
+               if err != nil {
+                       return nil, err
+               }
 
-       // Ensure service account is present
-       if err := action.ensureServiceAccount(ctx, pod); err != nil {
-               return nil, errors.Wrap(err, "cannot ensure service account is 
present")
-       }
+               // Otherwise, let's create the build pod
 
 Review comment:
   I'd suggest to remove that line has it has moved out of context.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to