Skip to content

Commit

Permalink
operator: Fix use of Resource.Events() in CEC controller
Browse files Browse the repository at this point in the history
The commit "resource: Refactor the API for simplified usage" was tested
against older master, before the commit "cli: Add configuration flag for service LB"
which used the older API, causing the build to fail.

This updates StartCECController() to use the new Resource.Events method.

Fixes: f3a9b0a ("resource: Refactor the API for simplified usage")
Signed-off-by: Jussi Maki <jussi@isovalent.com>
  • Loading branch information
joamaki committed Dec 22, 2022
1 parent 817b52d commit f396bcd
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions operator/watchers/cec.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,16 @@ func StartCECController(ctx context.Context, clientset k8sClient.Clientset, serv
log.WithError(err).Fatal("Error creating CiliumEnvoyConfiguration manager")
}
go m.Run(ctx)

services.Observe(
ctx,
func(ev resource.Event[*slim_corev1.Service]) {
ev.Handle(
func() error {
m.MarkSynced()
return nil
},
func(_ resource.Key, svc *slim_corev1.Service) error {
return m.OnUpdateService(nil, svc)
},
func(_ resource.Key, svc *slim_corev1.Service) error {
return m.OnDeleteService(svc)
},
)
},
func(error) { /* only completes when stopping */ },
)
for ev := range services.Events(ctx) {
switch ev.Kind {
case resource.Sync:
m.MarkSynced()
ev.Done(nil)
case resource.Upsert:
ev.Done(m.OnUpdateService(nil, ev.Object))
case resource.Delete:
ev.Done(m.OnDeleteService(ev.Object))
}
}
}()
}

0 comments on commit f396bcd

Please sign in to comment.