Merge pull request #125154 from alvaroaleman/rename
Sample Controller: Use one variable for key throughout
This commit is contained in:
		| @@ -204,27 +204,27 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// We wrap this block in a func so we can defer c.workqueue.Done. | 	// We wrap this block in a func so we can defer c.workqueue.Done. | ||||||
| 	err := func(key string) error { | 	err := func() error { | ||||||
| 		// We call Done here so the workqueue knows we have finished | 		// We call Done here so the workqueue knows we have finished | ||||||
| 		// processing this item. We also must remember to call Forget if we | 		// processing this item. We also must remember to call Forget if we | ||||||
| 		// do not want this work item being re-queued. For example, we do | 		// do not want this work item being re-queued. For example, we do | ||||||
| 		// not call Forget if a transient error occurs, instead the item is | 		// not call Forget if a transient error occurs, instead the item is | ||||||
| 		// put back on the workqueue and attempted again after a back-off | 		// put back on the workqueue and attempted again after a back-off | ||||||
| 		// period. | 		// period. | ||||||
| 		defer c.workqueue.Done(key) | 		defer c.workqueue.Done(obj) | ||||||
| 		// 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(ctx, key); err != nil { | 		if err := c.syncHandler(ctx, obj); err != nil { | ||||||
| 			// Put the item back on the workqueue to handle any transient errors. | 			// Put the item back on the workqueue to handle any transient errors. | ||||||
| 			c.workqueue.AddRateLimited(key) | 			c.workqueue.AddRateLimited(obj) | ||||||
| 			return fmt.Errorf("error syncing '%s': %s, requeuing", key, err.Error()) | 			return fmt.Errorf("error syncing '%s': %s, requeuing", obj, 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. | ||||||
| 		c.workqueue.Forget(obj) | 		c.workqueue.Forget(obj) | ||||||
| 		logger.Info("Successfully synced", "resourceName", key) | 		logger.Info("Successfully synced", "resourceName", obj) | ||||||
| 		return nil | 		return nil | ||||||
| 	}(obj) | 	}() | ||||||
|  |  | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		utilruntime.HandleError(err) | 		utilruntime.HandleError(err) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot