@@ -56,6 +56,8 @@ type ApiCheckReconciler struct {
56
56
func (r * ApiCheckReconciler ) Reconcile (ctx context.Context , req ctrl.Request ) (ctrl.Result , error ) {
57
57
logger := log .FromContext (ctx )
58
58
59
+ logger .V (1 ).Info ("Reconciler started" )
60
+
59
61
apiCheckFinalizer := "k8s.checklyhq.com/finalizer"
60
62
61
63
apiCheck := & checklyv1alpha1.ApiCheck {}
@@ -67,7 +69,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
67
69
if err != nil {
68
70
if errors .IsNotFound (err ) {
69
71
// The resource has been deleted
70
- logger .Info ("Deleted" , "checkly ID" , apiCheck .Status .ID , "endpoint" , apiCheck .Spec .Endpoint , "name" , apiCheck .Name )
72
+ logger .V ( 1 ). Info ("Deleted" , "checkly ID" , apiCheck .Status .ID , "endpoint" , apiCheck .Spec .Endpoint , "name" , apiCheck .Name )
71
73
return ctrl.Result {}, nil
72
74
}
73
75
// Error reading the object
@@ -77,7 +79,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
77
79
78
80
if apiCheck .GetDeletionTimestamp () != nil {
79
81
if controllerutil .ContainsFinalizer (apiCheck , apiCheckFinalizer ) {
80
- logger .Info ("Finalizer is present, trying to delete Checkly check" , "checkly ID" , apiCheck .Status .ID )
82
+ logger .V ( 1 ). Info ("Finalizer is present, trying to delete Checkly check" , "checkly ID" , apiCheck .Status .ID )
81
83
err := external .Delete (apiCheck .Status .ID , r .ApiClient )
82
84
if err != nil {
83
85
logger .Error (err , "Failed to delete checkly API check" )
@@ -89,15 +91,16 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
89
91
controllerutil .RemoveFinalizer (apiCheck , apiCheckFinalizer )
90
92
err = r .Update (ctx , apiCheck )
91
93
if err != nil {
94
+ logger .Error (err , "Failed to delete finalizer" )
92
95
return ctrl.Result {}, err
93
96
}
94
- logger .Info ("Successfully deleted finalizer" )
97
+ logger .V ( 1 ). Info ("Successfully deleted finalizer" )
95
98
}
96
99
return ctrl.Result {}, nil
97
100
}
98
101
99
102
// Object found, let's do something with it. It's either updated, or it's new.
100
- logger .Info ("Object found" , "endpoint" , apiCheck .Spec .Endpoint )
103
+ logger .V ( 1 ). Info ("Object found" , "endpoint" , apiCheck .Spec .Endpoint )
101
104
102
105
// /////////////////////////////
103
106
// Finalizer logic
@@ -109,7 +112,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
109
112
logger .Error (err , "Failed to update ApiCheck status" )
110
113
return ctrl.Result {}, err
111
114
}
112
- logger .Info ("Added finalizer" , "checkly ID" , apiCheck .Status .ID , "endpoint" , apiCheck .Spec .Endpoint )
115
+ logger .V ( 1 ). Info ("Added finalizer" , "checkly ID" , apiCheck .Status .ID , "endpoint" , apiCheck .Spec .Endpoint )
113
116
return ctrl.Result {}, nil
114
117
}
115
118
@@ -121,7 +124,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
121
124
if err != nil {
122
125
if errors .IsNotFound (err ) {
123
126
// The resource has been deleted
124
- logger .Info ( "Group not found, probably deleted or does not exist" , "name" , apiCheck .Spec .Group )
127
+ logger .Error ( err , "Group not found, probably deleted or does not exist" , "name" , apiCheck .Spec .Group )
125
128
return ctrl.Result {}, err
126
129
}
127
130
// Error reading the object
@@ -130,7 +133,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
130
133
}
131
134
132
135
if group .Status .ID == 0 {
133
- logger .Info ("Group ID has not been populated, we're too quick, requeining for retry" , "group name" , apiCheck .Spec .Group )
136
+ logger .V ( 1 ). Info ("Group ID has not been populated, we're too quick, requeining for retry" , "group name" , apiCheck .Spec .Group )
134
137
return ctrl.Result {Requeue : true }, nil
135
138
}
136
139
@@ -155,7 +158,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
155
158
// Determine if it's a new object or if it's an update to an existing object
156
159
if apiCheck .Status .ID != "" {
157
160
// Existing object, we need to update it
158
- logger .Info ("Existing object, with ID" , "checkly ID" , apiCheck .Status .ID , "endpoint" , apiCheck .Spec .Endpoint )
161
+ logger .V ( 1 ). Info ("Existing object, with ID" , "checkly ID" , apiCheck .Status .ID , "endpoint" , apiCheck .Spec .Endpoint )
159
162
err := external .Update (internalCheck , r .ApiClient )
160
163
// err :=
161
164
if err != nil {
@@ -185,7 +188,7 @@ func (r *ApiCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
185
188
logger .Error (err , "Failed to update ApiCheck status" )
186
189
return ctrl.Result {}, err
187
190
}
188
- logger .Info ("New checkly check created with" , "checkly ID" , apiCheck .Status .ID , "endpoint " , apiCheck .Spec . Endpoint )
191
+ logger .V ( 1 ). Info ("New checkly check created with" , "checkly ID" , apiCheck .Status .ID , "spec " , apiCheck .Spec )
189
192
190
193
return ctrl.Result {}, nil
191
194
}
0 commit comments