fix: Handle traits update conflicts gracefully
@@ -19,8 +19,9 @@ package integration
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 @@ func (r *ReconcileIntegration) Reconcile(request reconcile.Request) (reconcile.R
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 @@ func (r *ReconcileIntegration) Reconcile(request reconcile.Request) (reconcile.R
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
}
