Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy: pin retries to a const and forget correctly in the dc loop #9756

Merged
merged 1 commit into from
Jul 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/deploy/controller/deploymentconfig/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,22 @@ func (c *DeploymentConfigController) calculateStatus(config deployapi.Deployment

func (c *DeploymentConfigController) handleErr(err error, key interface{}) {
if err == nil {
c.queue.Forget(key)
return
}

if _, isFatal := err.(fatalError); isFatal {
utilruntime.HandleError(err)
c.queue.Forget(key)
return
}

if c.queue.NumRequeues(key) < 10 {
if c.queue.NumRequeues(key) < MaxRetries {
glog.V(2).Infof("Error syncing deployment config %v: %v", key, err)
c.queue.AddRateLimited(key)
} else {
glog.V(2).Infof(err.Error())
c.queue.Forget(key)
return
}

utilruntime.HandleError(err)
c.queue.Forget(key)
}
3 changes: 3 additions & 0 deletions pkg/deploy/controller/deploymentconfig/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const (
// controller stores have synced. If it hasn't synced, to avoid a hot loop, we'll wait this long
// between checks.
StoreSyncedPollPeriod = 100 * time.Millisecond
// MaxRetries is the number of times a deployment config will be retried before it is dropped out
// of the queue.
MaxRetries = 5
)

// NewDeploymentConfigController creates a new DeploymentConfigController.
Expand Down
18 changes: 18 additions & 0 deletions pkg/deploy/controller/generictrigger/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import (
kapi "k8s.io/kubernetes/pkg/api"
kclient "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/runtime"
utilruntime "k8s.io/kubernetes/pkg/util/runtime"
"k8s.io/kubernetes/pkg/util/workqueue"

"github.com/golang/glog"
osclient "github.com/openshift/origin/pkg/client"
oscache "github.com/openshift/origin/pkg/client/cache"
deployapi "github.com/openshift/origin/pkg/deploy/api"
Expand Down Expand Up @@ -213,3 +215,19 @@ func (c *DeploymentTriggerController) update(config *deployapi.DeploymentConfig,
_, err := c.dn.DeploymentConfigs(config.Namespace).UpdateStatus(config)
return err
}

func (c *DeploymentTriggerController) handleErr(err error, key interface{}) {
if err == nil {
c.queue.Forget(key)
return
}

if c.queue.NumRequeues(key) < MaxRetries {
glog.V(2).Infof("Error instantiating deployment config %v: %v", key, err)
c.queue.AddRateLimited(key)
return
}

utilruntime.HandleError(err)
c.queue.Forget(key)
}
13 changes: 5 additions & 8 deletions pkg/deploy/controller/generictrigger/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const (
// stream stores have synced. If it hasn't synced, to avoid a hot loop, we'll wait this long
// between checks.
StoreSyncedPollPeriod = 100 * time.Millisecond
// MaxRetries is the number of times a deployment config will be retried before it is dropped
// out of the queue.
MaxRetries = 5
)

// NewDeploymentTriggerController returns a new DeploymentTriggerController.
Expand Down Expand Up @@ -160,15 +163,9 @@ func (c *DeploymentTriggerController) work() bool {
return false
}

if err := c.Handle(dc); err != nil {
utilruntime.HandleError(err)
err = c.Handle(dc)
c.handleErr(err, key)

if c.queue.NumRequeues(key) < 2 {
c.queue.AddRateLimited(key)
return false
}
}
c.queue.Forget(key)
return false
}

Expand Down