From be4ce2e02d1485651e65fbcc7ab300c54bee1bd5 Mon Sep 17 00:00:00 2001 From: Stephen Muth Date: Wed, 15 Feb 2023 18:54:33 -0500 Subject: [PATCH] Ensure the SharedInformerFactory closes eventually (#1585) Otherwise it will continue to collect events in the background, consuming memory that can't be GC'd. --- pipeline/backend/kubernetes/kubernetes.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pipeline/backend/kubernetes/kubernetes.go b/pipeline/backend/kubernetes/kubernetes.go index e2058632c..1d9529625 100644 --- a/pipeline/backend/kubernetes/kubernetes.go +++ b/pipeline/backend/kubernetes/kubernetes.go @@ -17,7 +17,6 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" @@ -200,7 +199,9 @@ func (e *kube) Wait(ctx context.Context, step *types.Step) (*types.State, error) UpdateFunc: podUpdated, }, ) - si.Start(wait.NeverStop) + stop := make(chan struct{}) + si.Start(stop) + defer close(stop) // TODO Cancel on ctx.Done <-finished @@ -246,7 +247,9 @@ func (e *kube) Tail(ctx context.Context, step *types.Step) (io.ReadCloser, error UpdateFunc: podUpdated, }, ) - si.Start(wait.NeverStop) + stop := make(chan struct{}) + si.Start(stop) + defer close(stop) <-up @@ -323,7 +326,7 @@ func (e *kube) Destroy(_ context.Context, conf *types.Config) error { } if err := e.client.CoreV1().Services(e.config.Namespace).Delete(noContext, svc.Name, deleteOpts); err != nil { if errors.IsNotFound(err) { - log.Trace().Err(err).Msgf("Unable to service pod %s", svc.Name) + log.Trace().Err(err).Msgf("Unable to delete service %s", svc.Name) } else { return err }