Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle traits update conflicts gracefully #1000

Merged
merged 1 commit into from
Oct 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions pkg/controller/integration/integration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down