From 880a68ade6ad2b47b554a6572901f867bde21da2 Mon Sep 17 00:00:00 2001 From: John McMeeking Date: Mon, 18 Dec 2017 11:39:51 -0600 Subject: [PATCH] Fix garbage collector when leader-elect=false **What this PR does / why we need it**: In a 1.8.x master with --leader-elect=false, the garbage collector controller does not work. When deleting a deployment with v1meta.DeletePropagationForeground, the deployment had its deletionTimestamp set and a foreground Deletion finalizer was added, but the deployment, rs and pod were not deleted. This is an issue with how the garbage collector graph_builder behaves when the stopCh=nil. This PR creates a dummy stop channel for the garbage collector controller (and other controllers started by the controller-manager) so that they can work more like they do when when the controller-manager is configured with --leader-elect=true. **Which issue(s) this PR fixes** *(optional, in `fixes #(, fixes #, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #57044 **Special notes for your reviewer**: **Release note**: ```release-note Garbage collection doesn't work when the controller-manager uses --leader-elect=false ``` --- cmd/kube-controller-manager/app/controllermanager.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/kube-controller-manager/app/controllermanager.go b/cmd/kube-controller-manager/app/controllermanager.go index d08e9658a8..63044ac44b 100644 --- a/cmd/kube-controller-manager/app/controllermanager.go +++ b/cmd/kube-controller-manager/app/controllermanager.go @@ -162,7 +162,9 @@ func Run(s *options.CMServer) error { } if !s.LeaderElection.LeaderElect { - run(nil) + stopCh := make(chan struct{}) + defer close(stopCh) + run(stopCh) panic("unreachable") }