@@ -286,18 +286,23 @@ func (r *MirrorReconciler) syncGateway(ctx context.Context, gw *gwapiv1.Gateway)
286286 if apierrors .IsNotFound (err ) {
287287 log .Infof ("Mirror: creating Gateway %s (from %s/%s)" , apoxyName , gw .Namespace , gw .Name )
288288 if _ , err := r .apoxyClient .GatewayV1 ().Gateways ().Create (ctx , apoxy , metav1.CreateOptions {}); err != nil {
289+ MirrorSyncErrors .WithLabelValues ("Gateway" ).Inc ()
289290 return reconcile.Result {}, fmt .Errorf ("creating Apoxy Gateway %s: %w" , apoxyName , err )
290291 }
292+ MirrorSyncedResources .WithLabelValues ("Gateway" ).Inc ()
291293 return reconcile.Result {}, nil
292294 } else if err != nil {
295+ MirrorSyncErrors .WithLabelValues ("Gateway" ).Inc ()
293296 return reconcile.Result {}, fmt .Errorf ("getting Apoxy Gateway %s: %w" , apoxyName , err )
294297 }
295298
296299 apoxy .ResourceVersion = existing .ResourceVersion
297300 log .Infof ("Mirror: updating Gateway %s (from %s/%s)" , apoxyName , gw .Namespace , gw .Name )
298301 if _ , err := r .apoxyClient .GatewayV1 ().Gateways ().Update (ctx , apoxy , metav1.UpdateOptions {}); err != nil {
302+ MirrorSyncErrors .WithLabelValues ("Gateway" ).Inc ()
299303 return reconcile.Result {}, fmt .Errorf ("updating Apoxy Gateway %s: %w" , apoxyName , err )
300304 }
305+ MirrorSyncedResources .WithLabelValues ("Gateway" ).Inc ()
301306 return reconcile.Result {}, nil
302307}
303308
@@ -348,18 +353,23 @@ func (r *MirrorReconciler) syncHTTPRoute(ctx context.Context, route *gwapiv1.HTT
348353 if apierrors .IsNotFound (err ) {
349354 log .Infof ("Mirror: creating HTTPRoute %s (from %s/%s)" , apoxyName , route .Namespace , route .Name )
350355 if _ , err := r .apoxyClient .GatewayV1 ().HTTPRoutes ().Create (ctx , apoxy , metav1.CreateOptions {}); err != nil {
356+ MirrorSyncErrors .WithLabelValues ("HTTPRoute" ).Inc ()
351357 return reconcile.Result {}, fmt .Errorf ("creating Apoxy HTTPRoute %s: %w" , apoxyName , err )
352358 }
359+ MirrorSyncedResources .WithLabelValues ("HTTPRoute" ).Inc ()
353360 return reconcile.Result {}, nil
354361 } else if err != nil {
362+ MirrorSyncErrors .WithLabelValues ("HTTPRoute" ).Inc ()
355363 return reconcile.Result {}, fmt .Errorf ("getting Apoxy HTTPRoute %s: %w" , apoxyName , err )
356364 }
357365
358366 apoxy .ResourceVersion = existing .ResourceVersion
359367 log .Infof ("Mirror: updating HTTPRoute %s (from %s/%s)" , apoxyName , route .Namespace , route .Name )
360368 if _ , err := r .apoxyClient .GatewayV1 ().HTTPRoutes ().Update (ctx , apoxy , metav1.UpdateOptions {}); err != nil {
369+ MirrorSyncErrors .WithLabelValues ("HTTPRoute" ).Inc ()
361370 return reconcile.Result {}, fmt .Errorf ("updating Apoxy HTTPRoute %s: %w" , apoxyName , err )
362371 }
372+ MirrorSyncedResources .WithLabelValues ("HTTPRoute" ).Inc ()
363373 return reconcile.Result {}, nil
364374}
365375
@@ -410,18 +420,23 @@ func (r *MirrorReconciler) syncGRPCRoute(ctx context.Context, route *gwapiv1.GRP
410420 if apierrors .IsNotFound (err ) {
411421 log .Infof ("Mirror: creating GRPCRoute %s (from %s/%s)" , apoxyName , route .Namespace , route .Name )
412422 if _ , err := r .apoxyClient .GatewayV1 ().GRPCRoutes ().Create (ctx , apoxy , metav1.CreateOptions {}); err != nil {
423+ MirrorSyncErrors .WithLabelValues ("GRPCRoute" ).Inc ()
413424 return reconcile.Result {}, fmt .Errorf ("creating Apoxy GRPCRoute %s: %w" , apoxyName , err )
414425 }
426+ MirrorSyncedResources .WithLabelValues ("GRPCRoute" ).Inc ()
415427 return reconcile.Result {}, nil
416428 } else if err != nil {
429+ MirrorSyncErrors .WithLabelValues ("GRPCRoute" ).Inc ()
417430 return reconcile.Result {}, fmt .Errorf ("getting Apoxy GRPCRoute %s: %w" , apoxyName , err )
418431 }
419432
420433 apoxy .ResourceVersion = existing .ResourceVersion
421434 log .Infof ("Mirror: updating GRPCRoute %s (from %s/%s)" , apoxyName , route .Namespace , route .Name )
422435 if _ , err := r .apoxyClient .GatewayV1 ().GRPCRoutes ().Update (ctx , apoxy , metav1.UpdateOptions {}); err != nil {
436+ MirrorSyncErrors .WithLabelValues ("GRPCRoute" ).Inc ()
423437 return reconcile.Result {}, fmt .Errorf ("updating Apoxy GRPCRoute %s: %w" , apoxyName , err )
424438 }
439+ MirrorSyncedResources .WithLabelValues ("GRPCRoute" ).Inc ()
425440 return reconcile.Result {}, nil
426441}
427442
@@ -472,18 +487,23 @@ func (r *MirrorReconciler) syncTCPRoute(ctx context.Context, route *gwapiv1alpha
472487 if apierrors .IsNotFound (err ) {
473488 log .Infof ("Mirror: creating TCPRoute %s (from %s/%s)" , apoxyName , route .Namespace , route .Name )
474489 if _ , err := r .apoxyClient .GatewayV1alpha2 ().TCPRoutes ().Create (ctx , apoxy , metav1.CreateOptions {}); err != nil {
490+ MirrorSyncErrors .WithLabelValues ("TCPRoute" ).Inc ()
475491 return reconcile.Result {}, fmt .Errorf ("creating Apoxy TCPRoute %s: %w" , apoxyName , err )
476492 }
493+ MirrorSyncedResources .WithLabelValues ("TCPRoute" ).Inc ()
477494 return reconcile.Result {}, nil
478495 } else if err != nil {
496+ MirrorSyncErrors .WithLabelValues ("TCPRoute" ).Inc ()
479497 return reconcile.Result {}, fmt .Errorf ("getting Apoxy TCPRoute %s: %w" , apoxyName , err )
480498 }
481499
482500 apoxy .ResourceVersion = existing .ResourceVersion
483501 log .Infof ("Mirror: updating TCPRoute %s (from %s/%s)" , apoxyName , route .Namespace , route .Name )
484502 if _ , err := r .apoxyClient .GatewayV1alpha2 ().TCPRoutes ().Update (ctx , apoxy , metav1.UpdateOptions {}); err != nil {
503+ MirrorSyncErrors .WithLabelValues ("TCPRoute" ).Inc ()
485504 return reconcile.Result {}, fmt .Errorf ("updating Apoxy TCPRoute %s: %w" , apoxyName , err )
486505 }
506+ MirrorSyncedResources .WithLabelValues ("TCPRoute" ).Inc ()
487507 return reconcile.Result {}, nil
488508}
489509
@@ -534,18 +554,23 @@ func (r *MirrorReconciler) syncTLSRoute(ctx context.Context, route *gwapiv1alpha
534554 if apierrors .IsNotFound (err ) {
535555 log .Infof ("Mirror: creating TLSRoute %s (from %s/%s)" , apoxyName , route .Namespace , route .Name )
536556 if _ , err := r .apoxyClient .GatewayV1alpha2 ().TLSRoutes ().Create (ctx , apoxy , metav1.CreateOptions {}); err != nil {
557+ MirrorSyncErrors .WithLabelValues ("TLSRoute" ).Inc ()
537558 return reconcile.Result {}, fmt .Errorf ("creating Apoxy TLSRoute %s: %w" , apoxyName , err )
538559 }
560+ MirrorSyncedResources .WithLabelValues ("TLSRoute" ).Inc ()
539561 return reconcile.Result {}, nil
540562 } else if err != nil {
563+ MirrorSyncErrors .WithLabelValues ("TLSRoute" ).Inc ()
541564 return reconcile.Result {}, fmt .Errorf ("getting Apoxy TLSRoute %s: %w" , apoxyName , err )
542565 }
543566
544567 apoxy .ResourceVersion = existing .ResourceVersion
545568 log .Infof ("Mirror: updating TLSRoute %s (from %s/%s)" , apoxyName , route .Namespace , route .Name )
546569 if _ , err := r .apoxyClient .GatewayV1alpha2 ().TLSRoutes ().Update (ctx , apoxy , metav1.UpdateOptions {}); err != nil {
570+ MirrorSyncErrors .WithLabelValues ("TLSRoute" ).Inc ()
547571 return reconcile.Result {}, fmt .Errorf ("updating Apoxy TLSRoute %s: %w" , apoxyName , err )
548572 }
573+ MirrorSyncedResources .WithLabelValues ("TLSRoute" ).Inc ()
549574 return reconcile.Result {}, nil
550575}
551576
@@ -596,18 +621,23 @@ func (r *MirrorReconciler) syncUDPRoute(ctx context.Context, route *gwapiv1alpha
596621 if apierrors .IsNotFound (err ) {
597622 log .Infof ("Mirror: creating UDPRoute %s (from %s/%s)" , apoxyName , route .Namespace , route .Name )
598623 if _ , err := r .apoxyClient .GatewayV1alpha2 ().UDPRoutes ().Create (ctx , apoxy , metav1.CreateOptions {}); err != nil {
624+ MirrorSyncErrors .WithLabelValues ("UDPRoute" ).Inc ()
599625 return reconcile.Result {}, fmt .Errorf ("creating Apoxy UDPRoute %s: %w" , apoxyName , err )
600626 }
627+ MirrorSyncedResources .WithLabelValues ("UDPRoute" ).Inc ()
601628 return reconcile.Result {}, nil
602629 } else if err != nil {
630+ MirrorSyncErrors .WithLabelValues ("UDPRoute" ).Inc ()
603631 return reconcile.Result {}, fmt .Errorf ("getting Apoxy UDPRoute %s: %w" , apoxyName , err )
604632 }
605633
606634 apoxy .ResourceVersion = existing .ResourceVersion
607635 log .Infof ("Mirror: updating UDPRoute %s (from %s/%s)" , apoxyName , route .Namespace , route .Name )
608636 if _ , err := r .apoxyClient .GatewayV1alpha2 ().UDPRoutes ().Update (ctx , apoxy , metav1.UpdateOptions {}); err != nil {
637+ MirrorSyncErrors .WithLabelValues ("UDPRoute" ).Inc ()
609638 return reconcile.Result {}, fmt .Errorf ("updating Apoxy UDPRoute %s: %w" , apoxyName , err )
610639 }
640+ MirrorSyncedResources .WithLabelValues ("UDPRoute" ).Inc ()
611641 return reconcile.Result {}, nil
612642}
613643
@@ -636,6 +666,7 @@ func (r *MirrorReconciler) RunHeartbeat(ctx context.Context, namespace string) e
636666 for {
637667 if err := r .renewLease (ctx , namespace , leaseName , durationSecs ); err != nil {
638668 log .Errorf ("Mirror heartbeat: failed to renew lease %s: %v" , leaseName , err )
669+ MirrorHeartbeatFailures .Inc ()
639670 }
640671
641672 select {
0 commit comments