Skip to content

Commit

Permalink
store: add a call to Driver.updateIngressStatuses after a resource is…
Browse files Browse the repository at this point in the history
… updated
  • Loading branch information
jrobsonchase committed Feb 16, 2024
1 parent 4706442 commit dcd3914
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions helm/ingress-controller/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
version: 2.14.1
digest: sha256:878897ea31cf8046483dda555119f1120b6280dd5ed88d5496eef987e04b29f0
generated: "2024-01-12T12:49:10.501156544-06:00"
version: 2.15.1
digest: sha256:10c0c43763ec8b38161eb1e31f4d686f973bd5fed864371084b0e675f326e95f
generated: "2024-02-15T17:01:55.139356684-05:00"
2 changes: 1 addition & 1 deletion internal/controller/ingress/ingress_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (r *IngressReconciler) SetupWithManager(mgr ctrl.Manager) error {
for _, obj := range storedResources {
builder = builder.Watches(
obj,
store.NewUpdateStoreHandler(obj.GetObjectKind().GroupVersionKind().Kind, r.Driver))
store.NewUpdateStoreHandler(obj.GetObjectKind().GroupVersionKind().Kind, r.Driver, r.Client))
}

return builder.Complete(r)
Expand Down
19 changes: 14 additions & 5 deletions internal/store/updatestorehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/go-logr/logr"
"k8s.io/client-go/util/workqueue"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
)
Expand All @@ -18,15 +19,19 @@ var _ handler.EventHandler = &UpdateStoreHandler{}
// It is used to simply watch some resources and keep their values updated in the store.
// It is used to keep various crds like edges/tunnels/domains, and core resources like ingress classes, updated.
type UpdateStoreHandler struct {
store Storer
log logr.Logger
client client.Client
driver *Driver
store Storer
log logr.Logger
}

// NewUpdateStoreHandler creates a new UpdateStoreHandler
func NewUpdateStoreHandler(resourceName string, d *Driver) *UpdateStoreHandler {
func NewUpdateStoreHandler(resourceName string, d *Driver, client client.Client) *UpdateStoreHandler {
return &UpdateStoreHandler{
store: d.store,
log: d.log.WithValues("UpdateStoreHandlerFor", resourceName),
driver: d,
client: client,
store: d.store,
log: d.log.WithValues("UpdateStoreHandlerFor", resourceName),
}
}

Expand All @@ -44,6 +49,10 @@ func (e *UpdateStoreHandler) Update(ctx context.Context, evt event.UpdateEvent,
e.log.Error(err, "error updating object in update", "object", evt.ObjectNew)
return
}
if err := e.driver.updateIngressStatuses(ctx, e.client); err != nil {
e.log.Error(err, "error syncing after object update", "object", evt.ObjectNew)
return
}
}

// Delete is called in response to a delete event - e.g. Edge Deleted.
Expand Down

0 comments on commit dcd3914

Please sign in to comment.