Skip to content

Commit

Permalink
Add more comments to the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlewi committed Mar 25, 2018
1 parent 477bc5e commit 5f5d859
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ type Controller struct {
// means we can ensure we only process a fixed amount of resources at a
// time, and makes it easy to ensure we are never processing the same item
// simultaneously in two different workers.
//
// Items in the work queue correspond to the name of the job.
// In response to various events (e.g. Add, Update, Delete), the informer
// is configured to add events to the queue. Since the item in the queue
// represents a job and not a particular event, we end up aggregating events for
// a job and ensure that a particular job isn't being processed by multiple
// workers simultaneously.
//
// We rely on the informer to periodically generate Update events. This ensures
// we regularly check on each TFJob and take any action needed.
//
// If there is a problem processing a job, processNextWorkItem just requeues
// the work item. This ensures that we end up retrying it. In this case
// we rely on the rateLimiter in the worker queue to retry with exponential
// backoff.
WorkQueue workqueue.RateLimitingInterface

// recorder is an event recorder for recording Event resources to the
Expand Down Expand Up @@ -195,6 +210,7 @@ func (c *Controller) processNextWorkItem() bool {
if quit {
return false
}

defer c.WorkQueue.Done(key)

_, err := c.syncHandler(key.(string))
Expand Down

0 comments on commit 5f5d859

Please sign in to comment.