You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/08/05 10:50:25 UTC
[camel-k] branch release-1.5.x updated: fix(builder): Fix
race-condition when Build transitions to running phase
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch release-1.5.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/release-1.5.x by this push:
new 9646085 fix(builder): Fix race-condition when Build transitions to running phase
9646085 is described below
commit 9646085eebb7bcbc5626aebfe6be1c9e7bfd1ad9
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Wed Aug 4 15:16:23 2021 +0200
fix(builder): Fix race-condition when Build transitions to running phase
---
pkg/controller/build/monitor_routine.go | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/pkg/controller/build/monitor_routine.go b/pkg/controller/build/monitor_routine.go
index 64a3bbd..8ba1b67 100644
--- a/pkg/controller/build/monitor_routine.go
+++ b/pkg/controller/build/monitor_routine.go
@@ -68,7 +68,11 @@ func (action *monitorRoutineAction) Handle(ctx context.Context, build *v1.Build)
build.Status.Error = "Build routine exists"
return build, nil
}
- // Start the build asynchronously to avoid blocking the reconcile loop
+ status := v1.BuildStatus{Phase: v1.BuildPhaseRunning}
+ if err := action.updateBuildStatus(ctx, build, status); err != nil {
+ return nil, err
+ }
+ // Start the build asynchronously to avoid blocking the reconciliation loop
routines.Store(build.Name, true)
go action.runBuild(build)
@@ -92,11 +96,7 @@ func (action *monitorRoutineAction) runBuild(build *v1.Build) {
ctxWithTimeout, cancel := context.WithDeadline(ctx, build.Status.StartedAt.Add(build.Spec.Timeout.Duration))
defer cancel()
- status := v1.BuildStatus{Phase: v1.BuildPhaseRunning}
- if err := action.updateBuildStatus(ctx, build, status); err != nil {
- return
- }
-
+ status := v1.BuildStatus{}
buildDir := ""
Builder := builder.New(action.client)