You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Error reading the object - requeue the request.
278
+
reqLogger.Error(err, "Failed to get Memcached")
279
+
return reconcile.Result{}, err
280
+
}
281
+
```
282
+
283
+
#### 2. Without an error:
284
+
285
+
There are several situations where although no error occured, the reconcile loop should signify
286
+
during its return that it needs to run again.
287
+
288
+
**Usage**
289
+
```Go
290
+
return reconcile.Result{Requeue: true}, nil
291
+
```
292
+
293
+
**Example:**
294
+
295
+
In the example below a `reconcile.Result{Requeue: true}, nil` is used because a new resource is being created and as such there is the potential that further processing is required. Thus, the reconcile loop needs to trigger a requeue but there is no error associated with this requeue.
296
+
As a result the request is requeued for another try.
297
+
```Go
298
+
// Define a new deployment
299
+
dep:= r.deploymentForMemcached(memcached)
300
+
...
301
+
302
+
// Deployment created successfully - return and requeue
303
+
return reconcile.Result{Requeue: true}, nil
304
+
```
305
+
306
+
#### 3. Without an error and no need to requeue the request:
307
+
308
+
In some situations, such as when the primary resource has been deleted, there is no need to
309
+
requeue the request for another attempt
310
+
311
+
**Usage**
312
+
```Go
313
+
return reconcile.Result{}, nil
314
+
```
315
+
316
+
**Example:**
317
+
318
+
In the example below a `reconcile.Result{}, nil` is used because the Memcached resource was not found, and no further processing is required.
// Request object not found, could have been deleted after reconcile request.
326
+
// Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
327
+
// Return and don't requeue
328
+
reqLogger.Info("Memcached resource not found. Ignoring since object must be deleted")
329
+
return reconcile.Result{}, nil
330
+
}
331
+
...
332
+
```
333
+
334
+
For a guide on Reconcilers, Clients, and interacting with resource Events, see the [Client API doc][doc_client_api] and the [controller-runtime documentation over reconcile][controller-runtime-reconcile-godoc].
253
335
254
336
## Build and run the operator
255
337
@@ -760,6 +842,7 @@ When the operator is not running in a cluster, the Manager will return an error
// Error reading the object - requeue the request.
267
+
reqLogger.Error(err, "Failed to get Memcached")
268
+
return reconcile.Result{}, err
269
+
}
270
+
```
271
+
272
+
#### 2. Without an error:
273
+
274
+
There are several situations where although no error occured, the reconcile loop should signify
275
+
during its return that it needs to run again.
276
+
277
+
**Usage**
278
+
```Go
279
+
return reconcile.Result{Requeue: true}, nil
280
+
```
281
+
282
+
**Example:**
283
+
284
+
In the example below a `reconcile.Result{Requeue: true}, nil` is used because a new resource is being created and as such there is the potential that further processing is required. Thus, the reconcile loop needs to trigger a requeue but there is no error associated with this requeue.
285
+
As a result the request is requeued for another try.
286
+
```Go
287
+
// Define a new deployment
288
+
dep:= r.deploymentForMemcached(memcached)
289
+
...
290
+
291
+
// Deployment created successfully - return and requeue
292
+
return reconcile.Result{Requeue: true}, nil
293
+
```
294
+
295
+
#### 3. Without an error and no need to requeue the request:
296
+
297
+
In some situations, such as when the primary resource has been deleted, there is no need to
298
+
requeue the request for another attempt
299
+
300
+
**Usage**
301
+
```Go
302
+
return reconcile.Result{}, nil
303
+
```
304
+
305
+
**Example:**
306
+
307
+
In the example below a `reconcile.Result{}, nil` is used because the Memcached resource was not found, and no further processing is required.
// Request object not found, could have been deleted after reconcile request.
315
+
// Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
316
+
// Return and don't requeue
317
+
reqLogger.Info("Memcached resource not found. Ignoring since object must be deleted")
318
+
return reconcile.Result{}, nil
319
+
}
320
+
...
321
+
```
322
+
323
+
For a guide on Reconcilers, Clients, and interacting with resource Events, see the [Client API doc][doc_client_api] and the [controller-runtime documentation over reconcile][controller-runtime-reconcile-godoc].
242
324
243
325
## Build and run the operator
244
326
@@ -751,6 +833,7 @@ When the operator is not running in a cluster, the Manager will return an error
0 commit comments