@@ -59,6 +59,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
5959 logger := log .FromContext (ctx )
6060
6161 apiCheckFinalizer := fmt .Sprintf ("%s/finalizer" , r .ControllerDomain )
62+ logger .V (1 ).Info ("Reconciler started" )
6263
6364 apiCheck := & checklyv1alpha1.ApiCheck {}
6465
@@ -69,7 +70,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
6970 if err != nil {
7071 if errors .IsNotFound (err ) {
7172 // The resource has been deleted
72- logger .Info ("Deleted" , "checkly ID" , apiCheck .Status .ID , "endpoint" , apiCheck .Spec .Endpoint , "name" , apiCheck .Name )
73+ logger .V ( 1 ). Info ("Deleted" , "checkly ID" , apiCheck .Status .ID , "endpoint" , apiCheck .Spec .Endpoint , "name" , apiCheck .Name )
7374 return ctrl.Result {}, nil
7475 }
7576 // Error reading the object
@@ -79,7 +80,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
7980
8081 if apiCheck .GetDeletionTimestamp () != nil {
8182 if controllerutil .ContainsFinalizer (apiCheck , apiCheckFinalizer ) {
82- logger .Info ("Finalizer is present, trying to delete Checkly check" , "checkly ID" , apiCheck .Status .ID )
83+ logger .V ( 1 ). Info ("Finalizer is present, trying to delete Checkly check" , "checkly ID" , apiCheck .Status .ID )
8384 err := external .Delete (apiCheck .Status .ID , r .ApiClient )
8485 if err != nil {
8586 logger .Error (err , "Failed to delete checkly API check" )
@@ -91,15 +92,16 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
9192 controllerutil .RemoveFinalizer (apiCheck , apiCheckFinalizer )
9293 err = r .Update (ctx , apiCheck )
9394 if err != nil {
95+ logger .Error (err , "Failed to delete finalizer" )
9496 return ctrl.Result {}, err
9597 }
96- logger .Info ("Successfully deleted finalizer" )
98+ logger .V ( 1 ). Info ("Successfully deleted finalizer" )
9799 }
98100 return ctrl.Result {}, nil
99101 }
100102
101103 // Object found, let's do something with it. It's either updated, or it's new.
102- logger .Info ("Object found" , "endpoint" , apiCheck .Spec .Endpoint )
104+ logger .V ( 1 ). Info ("Object found" , "endpoint" , apiCheck .Spec .Endpoint )
103105
104106 // /////////////////////////////
105107 // Finalizer logic
@@ -111,7 +113,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
111113 logger .Error (err , "Failed to update ApiCheck status" )
112114 return ctrl.Result {}, err
113115 }
114- logger .Info ("Added finalizer" , "checkly ID" , apiCheck .Status .ID , "endpoint" , apiCheck .Spec .Endpoint )
116+ logger .V ( 1 ). Info ("Added finalizer" , "checkly ID" , apiCheck .Status .ID , "endpoint" , apiCheck .Spec .Endpoint )
115117 return ctrl.Result {}, nil
116118 }
117119
@@ -123,7 +125,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
123125 if err != nil {
124126 if errors .IsNotFound (err ) {
125127 // The resource has been deleted
126- logger .Info ( "Group not found, probably deleted or does not exist" , "name" , apiCheck .Spec .Group )
128+ logger .Error ( err , "Group not found, probably deleted or does not exist" , "name" , apiCheck .Spec .Group )
127129 return ctrl.Result {}, err
128130 }
129131 // Error reading the object
@@ -132,7 +134,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
132134 }
133135
134136 if group .Status .ID == 0 {
135- logger .Info ("Group ID has not been populated, we're too quick, requeining for retry" , "group name" , apiCheck .Spec .Group )
137+ logger .V ( 1 ). Info ("Group ID has not been populated, we're too quick, requeining for retry" , "group name" , apiCheck .Spec .Group )
136138 return ctrl.Result {Requeue : true }, nil
137139 }
138140
@@ -157,7 +159,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
157159 // Determine if it's a new object or if it's an update to an existing object
158160 if apiCheck .Status .ID != "" {
159161 // Existing object, we need to update it
160- logger .Info ("Existing object, with ID" , "checkly ID" , apiCheck .Status .ID , "endpoint" , apiCheck .Spec .Endpoint )
162+ logger .V ( 1 ). Info ("Existing object, with ID" , "checkly ID" , apiCheck .Status .ID , "endpoint" , apiCheck .Spec .Endpoint )
161163 err := external .Update (internalCheck , r .ApiClient )
162164 // err :=
163165 if err != nil {
@@ -187,7 +189,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
187189 logger .Error (err , "Failed to update ApiCheck status" )
188190 return ctrl.Result {}, err
189191 }
190- logger .Info ("New checkly check created with" , "checkly ID" , apiCheck .Status .ID , "endpoint " , apiCheck .Spec . Endpoint )
192+ logger .V ( 1 ). Info ("New checkly check created with" , "checkly ID" , apiCheck .Status .ID , "spec " , apiCheck .Spec )
191193
192194 return ctrl.Result {}, nil
193195}
0 commit comments