Skip to content

Commit

Permalink
Only watch build phase changes from integration context and integrati…
Browse files Browse the repository at this point in the history
…on controllers
  • Loading branch information
astefanutti authored and lburgazzoli committed Apr 5, 2019
1 parent 4d8768d commit 265134a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
19 changes: 15 additions & 4 deletions pkg/controller/integration/integration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,21 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
}

// Watch for changes to secondary resource Builds and requeue the owner IntegrationContext
err = c.Watch(&source.Kind{Type: &v1alpha1.Build{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &v1alpha1.Integration{},
})
err = c.Watch(&source.Kind{Type: &v1alpha1.Build{}},
&handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &v1alpha1.Integration{},
},
predicate.Funcs{
UpdateFunc: func(e event.UpdateEvent) bool {
oldBuild := e.ObjectOld.(*v1alpha1.Build)
newBuild := e.ObjectNew.(*v1alpha1.Build)
// Ignore updates to the build CR except when the build phase changes
// as it's used to transition the integration from one phase to another
// during image build
return oldBuild.Status.Phase != newBuild.Status.Phase
},
})
if err != nil {
return err
}
Expand Down
19 changes: 15 additions & 4 deletions pkg/controller/integrationcontext/integrationcontext_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,21 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
}

// Watch for changes to secondary resource Builds and requeue the owner IntegrationContext
err = c.Watch(&source.Kind{Type: &v1alpha1.Build{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &v1alpha1.IntegrationContext{},
})
err = c.Watch(&source.Kind{Type: &v1alpha1.Build{}},
&handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &v1alpha1.IntegrationContext{},
},
predicate.Funcs{
UpdateFunc: func(e event.UpdateEvent) bool {
oldBuild := e.ObjectOld.(*v1alpha1.Build)
newBuild := e.ObjectNew.(*v1alpha1.Build)
// Ignore updates to the build CR except when the build phase changes
// as it's used to transition the integration context from one phase
// to another during the image build
return oldBuild.Status.Phase != newBuild.Status.Phase
},
})
if err != nil {
return err
}
Expand Down

0 comments on commit 265134a

Please sign in to comment.