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 2019/12/18 12:34:55 UTC
[camel-k] 10/13: chore(build): Use positive patching to update
build status in routine strategy too
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit b5a8e17d41a88673b47333bf4d9e95adae15736c
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Tue Dec 17 12:48:11 2019 +0100
chore(build): Use positive patching to update build status in routine strategy too
---
pkg/controller/build/schedule_routine.go | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/pkg/controller/build/schedule_routine.go b/pkg/controller/build/schedule_routine.go
index f4abe59..61a9173 100644
--- a/pkg/controller/build/schedule_routine.go
+++ b/pkg/controller/build/schedule_routine.go
@@ -23,11 +23,13 @@ import (
"sync"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"github.com/apache/camel-k/pkg/builder"
+ "github.com/apache/camel-k/pkg/util/patch"
)
// NewScheduleRoutineAction creates a new schedule routine action
@@ -143,8 +145,13 @@ func (action *scheduleRoutineAction) updateBuildStatus(ctx context.Context, buil
target.Status = status
// Copy the failure field from the build to persist recovery state
target.Status.Failure = build.Status.Failure
- // Patch the build status with the current progress
- err := action.client.Status().Patch(ctx, target, client.MergeFrom(build))
+ // Patch the build status with the result
+ p, err := patch.PositiveMergePatch(build, target)
+ if err != nil {
+ action.L.Errorf(err, "Cannot patch build status: %s", build.Name)
+ return err
+ }
+ err = action.client.Status().Patch(ctx, target, client.ConstantPatch(types.MergePatchType, p))
if err != nil {
action.L.Errorf(err, "Cannot update build status: %s", build.Name)
return err