You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/02/24 17:07:49 UTC

[camel-k] branch master updated: chore(controller): reduce logging when action fails because of conflicts, log the error message without the stack and re-queue the reconcilation

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/master by this push:
     new f76eff3  chore(controller): reduce logging when action fails because of conflicts, log the error message without the stack and re-queue the reconcilation
     new 57225b5  Merge pull request #488 from lburgazzoli/conflict
f76eff3 is described below

commit f76eff34868c9410d00def05b7c0e2c511fedf06
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Fri Feb 22 18:52:50 2019 +0100

    chore(controller): reduce logging when action fails because of conflicts, log the error message without the stack and re-queue the reconcilation
---
 pkg/controller/integration/integration_controller.go         | 12 ++++++++++--
 .../integrationcontext/integrationcontext_controller.go      | 11 ++++++++++-
 .../integrationplatform/integrationplatform_controller.go    | 11 ++++++++++-
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/pkg/controller/integration/integration_controller.go b/pkg/controller/integration/integration_controller.go
index 7a2b5ad..bff5513 100644
--- a/pkg/controller/integration/integration_controller.go
+++ b/pkg/controller/integration/integration_controller.go
@@ -8,9 +8,10 @@ import (
 	"github.com/apache/camel-k/pkg/client"
 
 	"k8s.io/apimachinery/pkg/api/errors"
-	k8serrors "k8s.io/apimachinery/pkg/api/errors"
 	"k8s.io/apimachinery/pkg/runtime"
 
+	k8serrors "k8s.io/apimachinery/pkg/api/errors"
+
 	"sigs.k8s.io/controller-runtime/pkg/controller"
 	"sigs.k8s.io/controller-runtime/pkg/event"
 	"sigs.k8s.io/controller-runtime/pkg/handler"
@@ -131,7 +132,14 @@ func (r *ReconcileIntegration) Reconcile(request reconcile.Request) (reconcile.R
 		if a.CanHandle(instance) {
 			ilog.Infof("Invoking action %s", a.Name())
 			if err := a.Handle(ctx, instance); err != nil {
-				return reconcile.Result{}, err
+				if k8serrors.IsConflict(err) {
+					ilog.Error(err, "conflict")
+					return reconcile.Result{
+						Requeue: true,
+					}, nil
+				}
+
+				return reconcile.Result{}, nil
 			}
 		}
 	}
diff --git a/pkg/controller/integrationcontext/integrationcontext_controller.go b/pkg/controller/integrationcontext/integrationcontext_controller.go
index 75ef37a..f432539 100644
--- a/pkg/controller/integrationcontext/integrationcontext_controller.go
+++ b/pkg/controller/integrationcontext/integrationcontext_controller.go
@@ -10,6 +10,8 @@ import (
 	"k8s.io/apimachinery/pkg/api/errors"
 	"k8s.io/apimachinery/pkg/runtime"
 
+	k8serrors "k8s.io/apimachinery/pkg/api/errors"
+
 	"sigs.k8s.io/controller-runtime/pkg/controller"
 	"sigs.k8s.io/controller-runtime/pkg/event"
 	"sigs.k8s.io/controller-runtime/pkg/handler"
@@ -117,7 +119,14 @@ func (r *ReconcileIntegrationContext) Reconcile(request reconcile.Request) (reco
 		if a.CanHandle(instance) {
 			ilog.Infof("Invoking action %s", a.Name())
 			if err := a.Handle(ctx, instance); err != nil {
-				return reconcile.Result{}, err
+				if k8serrors.IsConflict(err) {
+					ilog.Error(err, "conflict")
+					return reconcile.Result{
+						Requeue: true,
+					}, nil
+				}
+
+				return reconcile.Result{}, nil
 			}
 		}
 	}
diff --git a/pkg/controller/integrationplatform/integrationplatform_controller.go b/pkg/controller/integrationplatform/integrationplatform_controller.go
index 795c3e2..385cad5 100644
--- a/pkg/controller/integrationplatform/integrationplatform_controller.go
+++ b/pkg/controller/integrationplatform/integrationplatform_controller.go
@@ -10,6 +10,8 @@ import (
 	"k8s.io/apimachinery/pkg/api/errors"
 	"k8s.io/apimachinery/pkg/runtime"
 
+	k8serrors "k8s.io/apimachinery/pkg/api/errors"
+
 	"sigs.k8s.io/controller-runtime/pkg/controller"
 	"sigs.k8s.io/controller-runtime/pkg/event"
 	"sigs.k8s.io/controller-runtime/pkg/handler"
@@ -117,7 +119,14 @@ func (r *ReconcileIntegrationPlatform) Reconcile(request reconcile.Request) (rec
 		if a.CanHandle(instance) {
 			ilog.Infof("Invoking action %s", a.Name())
 			if err := a.Handle(ctx, instance); err != nil {
-				return reconcile.Result{}, err
+				if k8serrors.IsConflict(err) {
+					ilog.Error(err, "conflict")
+					return reconcile.Result{
+						Requeue: true,
+					}, nil
+				}
+
+				return reconcile.Result{}, nil
 			}
 		}
 	}