Skip to content
This repository has been archived by the owner on Oct 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #62 from rebuy-de/mute-globally
Browse files Browse the repository at this point in the history
mute ErrImagePull globally
  • Loading branch information
svenwltr authored Jul 11, 2017
2 parents 2ff0966 + dc5912e commit f20026c
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkg/interceptors/waiter/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ var (
type DeploymentWaitInterceptor struct {
client kubernetes.Interface

ctx context.Context
cancel context.CancelFunc
waitgroup *sync.WaitGroup
ctx context.Context
cancel context.CancelFunc
waitgroup *sync.WaitGroup
errImagePullMute time.Time
}

func NewDeploymentWaitInterceptor(client kubernetes.Interface) *DeploymentWaitInterceptor {
ctx, cancel := context.WithCancel(context.Background())

return &DeploymentWaitInterceptor{
client: client,
ctx: ctx,
cancel: cancel,
waitgroup: new(sync.WaitGroup),
client: client,
ctx: ctx,
cancel: cancel,
waitgroup: new(sync.WaitGroup),
errImagePullMute: time.Now(),
}
}

Expand Down Expand Up @@ -111,8 +113,6 @@ func (dwi *DeploymentWaitInterceptor) run(deployment *v1beta1.Deployment) {
func (dwi *DeploymentWaitInterceptor) podNotifier(ctx context.Context, rs *v1beta1.ReplicaSet) {
defer dwi.waitgroup.Done()

errImagePullMute := time.Now()

for pod := range kubeutil.WatchPods(ctx, dwi.client, fields.Everything()) {
if !kubeutil.IsOwner(rs.ObjectMeta, pod.ObjectMeta) {
continue
Expand All @@ -126,10 +126,10 @@ func (dwi *DeploymentWaitInterceptor) podNotifier(ctx context.Context, rs *v1bet

_, ok := err.(kubeutil.ErrImagePull)
if ok {
if time.Now().Before(errImagePullMute) {
if time.Now().Before(dwi.errImagePullMute) {
continue
}
errImagePullMute = time.Now().Add(ErrImagePullMuteDuration)
dwi.errImagePullMute = time.Now().Add(ErrImagePullMuteDuration)
}

if err != nil {
Expand Down

0 comments on commit f20026c

Please sign in to comment.