@@ -59,6 +59,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
59
59
logger := log .FromContext (ctx )
60
60
61
61
apiCheckFinalizer := fmt .Sprintf ("%s/finalizer" , r .ControllerDomain )
62
+ logger .V (1 ).Info ("Reconciler started" )
62
63
63
64
apiCheck := & checklyv1alpha1.ApiCheck {}
64
65
@@ -69,7 +70,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
69
70
if err != nil {
70
71
if errors .IsNotFound (err ) {
71
72
// 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 )
73
74
return ctrl.Result {}, nil
74
75
}
75
76
// Error reading the object
@@ -79,7 +80,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
79
80
80
81
if apiCheck .GetDeletionTimestamp () != nil {
81
82
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 )
83
84
err := external .Delete (apiCheck .Status .ID , r .ApiClient )
84
85
if err != nil {
85
86
logger .Error (err , "Failed to delete checkly API check" )
@@ -91,15 +92,16 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
91
92
controllerutil .RemoveFinalizer (apiCheck , apiCheckFinalizer )
92
93
err = r .Update (ctx , apiCheck )
93
94
if err != nil {
95
+ logger .Error (err , "Failed to delete finalizer" )
94
96
return ctrl.Result {}, err
95
97
}
96
- logger .Info ("Successfully deleted finalizer" )
98
+ logger .V ( 1 ). Info ("Successfully deleted finalizer" )
97
99
}
98
100
return ctrl.Result {}, nil
99
101
}
100
102
101
103
// 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 )
103
105
104
106
// /////////////////////////////
105
107
// Finalizer logic
@@ -111,7 +113,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
111
113
logger .Error (err , "Failed to update ApiCheck status" )
112
114
return ctrl.Result {}, err
113
115
}
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 )
115
117
return ctrl.Result {}, nil
116
118
}
117
119
@@ -123,7 +125,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
123
125
if err != nil {
124
126
if errors .IsNotFound (err ) {
125
127
// 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 )
127
129
return ctrl.Result {}, err
128
130
}
129
131
// Error reading the object
@@ -132,7 +134,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
132
134
}
133
135
134
136
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 )
136
138
return ctrl.Result {Requeue : true }, nil
137
139
}
138
140
@@ -157,7 +159,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
157
159
// Determine if it's a new object or if it's an update to an existing object
158
160
if apiCheck .Status .ID != "" {
159
161
// 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 )
161
163
err := external .Update (internalCheck , r .ApiClient )
162
164
// err :=
163
165
if err != nil {
@@ -187,7 +189,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
187
189
logger .Error (err , "Failed to update ApiCheck status" )
188
190
return ctrl.Result {}, err
189
191
}
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 )
191
193
192
194
return ctrl.Result {}, nil
193
195
}
0 commit comments