Skip to content

Commit

Permalink
Remove memory leak mitigation (#3585)
Browse files Browse the repository at this point in the history
  • Loading branch information
barkbay committed Aug 11, 2020
1 parent 8fbc682 commit d34d62f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
11 changes: 0 additions & 11 deletions pkg/controller/common/reconciler/results.go
Expand Up @@ -6,17 +6,13 @@ package reconciler

import (
"context"
"time"

"github.com/elastic/cloud-on-k8s/pkg/controller/common/tracing"
"go.elastic.co/apm"
k8serrors "k8s.io/apimachinery/pkg/util/errors"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)

// MaximumRequeueAfter is the maximum period of time in which we requeue a reconciliation.
const MaximumRequeueAfter = 10 * time.Hour

type resultKind int

const (
Expand Down Expand Up @@ -109,12 +105,5 @@ func (r *Results) Apply(step string, recoverableStep func(context.Context) (reco

// Aggregate returns the highest priority reconcile result and any errors seen so far.
func (r *Results) Aggregate() (reconcile.Result, error) {
if r.currResult.RequeueAfter > MaximumRequeueAfter {
// A client-go leaky timer issue will cause memory leaks for long requeue periods,
// see https://github.com/elastic/cloud-on-k8s/issues/1984.
// To prevent this from happening, let's restrict the requeue to a fixed short-term value.
// TODO: remove once https://github.com/kubernetes/client-go/issues/701 is fixed.
r.currResult.RequeueAfter = MaximumRequeueAfter
}
return r.currResult, k8serrors.NewAggregate(r.errors)
}
9 changes: 2 additions & 7 deletions pkg/controller/common/reconciler/results_test.go
Expand Up @@ -106,14 +106,9 @@ func TestResultsAggregate(t *testing.T) {
want: reconcile.Result{Requeue: true},
},
{
name: "specific result under MaximumRequeueAfter",
results: &Results{currResult: reconcile.Result{RequeueAfter: 1 * time.Hour}, currKind: specificKind},
want: reconcile.Result{RequeueAfter: 1 * time.Hour},
},
{
name: "specific result over MaximumRequeueAfter",
name: "specific result",
results: &Results{currResult: reconcile.Result{RequeueAfter: 24 * time.Hour}, currKind: specificKind},
want: reconcile.Result{RequeueAfter: MaximumRequeueAfter},
want: reconcile.Result{RequeueAfter: 24 * time.Hour},
},
}

Expand Down

0 comments on commit d34d62f

Please sign in to comment.