@@ -13,7 +13,6 @@ import (
1313 bindingsv1alpha1 "github.com/ngrok/ngrok-operator/api/bindings/v1alpha1"
1414 ngrokv1alpha1 "github.com/ngrok/ngrok-operator/api/ngrok/v1alpha1"
1515 "github.com/ngrok/ngrok-operator/internal/ngrokapi"
16- "golang.org/x/sync/errgroup"
1716 v1 "k8s.io/api/core/v1"
1817 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1918 "k8s.io/apimachinery/pkg/runtime"
@@ -216,22 +215,21 @@ func (r *BoundEndpointPoller) reconcileBoundEndpointsFromAPI(ctx context.Context
216215 toCreate , toUpdate , toDelete := r .filterBoundEndpointActions (ctx , existingBoundEndpoints , desiredBoundEndpoints )
217216
218217 // create context + errgroup for managing/closing the future goroutine in the reconcile actions loops
219- errGroup , reconcileActionCtx := errgroup .WithContext (context .Background ())
220- reconcileActionCtx , cancel := context .WithCancel (reconcileActionCtx )
218+ reconcileActionCtx , cancel := context .WithCancel (context .Background ())
221219 reconcileActionCtx = ctrl .LoggerInto (reconcileActionCtx , log )
222220 r .reconcilingCancel = cancel
223221
224222 // launch goroutines to reconcile the BoundEndpoints' actions in the background until the next polling loop
225223
226- r .reconcileBoundEndpointAction (reconcileActionCtx , errGroup , toCreate , "create" , func (reconcileActionCtx context.Context , binding bindingsv1alpha1.BoundEndpoint ) error {
224+ r .reconcileBoundEndpointAction (reconcileActionCtx , toCreate , "create" , func (reconcileActionCtx context.Context , binding bindingsv1alpha1.BoundEndpoint ) error {
227225 return r .createBinding (reconcileActionCtx , binding )
228226 })
229227
230- r .reconcileBoundEndpointAction (reconcileActionCtx , errGroup , toUpdate , "update" , func (reconcileActionCtx context.Context , binding bindingsv1alpha1.BoundEndpoint ) error {
228+ r .reconcileBoundEndpointAction (reconcileActionCtx , toUpdate , "update" , func (reconcileActionCtx context.Context , binding bindingsv1alpha1.BoundEndpoint ) error {
231229 return r .updateBinding (reconcileActionCtx , binding )
232230 })
233231
234- r .reconcileBoundEndpointAction (reconcileActionCtx , errGroup , toDelete , "delete" , func (reconcileActionCtx context.Context , binding bindingsv1alpha1.BoundEndpoint ) error {
232+ r .reconcileBoundEndpointAction (reconcileActionCtx , toDelete , "delete" , func (reconcileActionCtx context.Context , binding bindingsv1alpha1.BoundEndpoint ) error {
235233 return r .deleteBinding (reconcileActionCtx , binding )
236234 })
237235
@@ -243,32 +241,32 @@ type boundEndpointActionFn func(context.Context, bindingsv1alpha1.BoundEndpoint)
243241
244242// reconcileBoundEndpointAction runs a goroutine to try and process a list of BoundEndpoints
245243// for their desired action over and over again until stopChan is closed or receives a value
246- func (r * BoundEndpointPoller ) reconcileBoundEndpointAction (ctx context.Context , errGroup * errgroup. Group , boundEndpoints []bindingsv1alpha1.BoundEndpoint , actionMsg string , action boundEndpointActionFn ) {
244+ func (r * BoundEndpointPoller ) reconcileBoundEndpointAction (ctx context.Context , boundEndpoints []bindingsv1alpha1.BoundEndpoint , actionMsg string , action boundEndpointActionFn ) {
247245 log := ctrl .LoggerFrom (ctx )
248246
249247 if len (boundEndpoints ) == 0 {
250248 // nothing to do
251249 return
252250 }
253251
254- errGroup . Go ( func () error {
252+ go func () {
255253 // attempt reconciliation actions every so often
256- ticker := time .NewTicker (5 * time .Second )
254+ ticker := time .NewTicker (2 * time .Second )
257255 defer ticker .Stop ()
258256
259257 // remainingBindings is the list of BoundEndpoints that still need to be actioned upon
260258 remainingBindings := boundEndpoints
261259
262260 for {
263261 if len (remainingBindings ) == 0 {
264- return nil // all bindings have been processed
262+ return
265263 }
266264
267265 select {
268266 // stop go routine and return, there is a new reconcile poll happening actively
269267 case <- ctx .Done ():
270268 log .Info ("Reconcile Action context canceled, stopping BoundEndpoint reconcile action loop early" , "action" , actionMsg )
271- return nil
269+ return
272270 case <- ticker .C :
273271 log .V (9 ).Info ("Received tick" , "action" , actionMsg , "remaining" , remainingBindings )
274272
@@ -287,7 +285,7 @@ func (r *BoundEndpointPoller) reconcileBoundEndpointAction(ctx context.Context,
287285 remainingBindings = failedBindings
288286 }
289287 }
290- })
288+ }( )
291289}
292290
293291// filterBoundEndpointActions takse 2 sets of existing and desired BoundEndpoints
0 commit comments