fix: Handle traits update conflicts gracefully
diff --git a/pkg/controller/integration/integration_controller.go b/pkg/controller/integration/integration_controller.go
index a8c7935..33ecdb2 100644
--- a/pkg/controller/integration/integration_controller.go
+++ b/pkg/controller/integration/integration_controller.go
@@ -19,8 +19,9 @@
import (
"context"
+ "github.com/pkg/errors"
+
appsv1 "k8s.io/api/apps/v1"
- "k8s.io/apimachinery/pkg/api/errors"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
@@ -215,7 +216,7 @@
var instance v1alpha1.Integration
if err := r.client.Get(ctx, request.NamespacedName, &instance); err != nil {
- if errors.IsNotFound(err) {
+ if k8serrors.IsNotFound(err) {
// Request object not found, could have been deleted after reconcile request.
// Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
// Return and don't requeue
@@ -268,6 +269,16 @@
newTarget, err := a.Handle(ctx, target)
if err != nil {
+ // Some traits, like the deployment and knative service ones,
+ // update owned resources in the running phase, so it's better
+ // handling update conflicts gracefully, consistently with the
+ // primary integration update requests.
+ if cause := errors.Cause(err); k8serrors.IsConflict(cause) {
+ log.Error(cause, "conflict")
+ return reconcile.Result{
+ Requeue: true,
+ }, nil
+ }
return reconcile.Result{}, err
}