Merge pull request #70031 from nrfox/requeue-on-error

Sample Controller: requeue work item on syncHandler error
This commit is contained in:
k8s-ci-robot 2018-10-27 03:19:59 -07:00 committed by GitHub
commit b7b0aae435
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -219,7 +219,9 @@ func (c *Controller) processNextWorkItem() bool {
// Run the syncHandler, passing it the namespace/name string of the // Run the syncHandler, passing it the namespace/name string of the
// Foo resource to be synced. // Foo resource to be synced.
if err := c.syncHandler(key); err != nil { if err := c.syncHandler(key); err != nil {
return fmt.Errorf("error syncing '%s': %s", key, err.Error()) // Put the item back on the workqueue to handle any transient errors.
c.workqueue.AddRateLimited(key)
return fmt.Errorf("error syncing '%s': %s, requeuing", key, err.Error())
} }
// Finally, if no error occurs we Forget this item so it does not // Finally, if no error occurs we Forget this item so it does not
// get queued again until another change happens. // get queued again until another change happens.