Merge pull request #72554 from misterikkit/cachecompare

Move CacheDebugger signal handling into the package.
pull/564/head
Kubernetes Prow Robot 2019-01-04 16:20:42 -08:00 committed by GitHub
commit dd53c82d7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 20 deletions

View File

@ -5,8 +5,6 @@ go_library(
srcs = [
"factory.go",
"plugins.go",
"signal.go",
"signal_windows.go",
],
importpath = "k8s.io/kubernetes/pkg/scheduler/factory",
visibility = ["//visibility:public"],

View File

@ -20,8 +20,6 @@ package factory
import (
"fmt"
"os"
"os/signal"
"reflect"
"time"
@ -385,28 +383,18 @@ func NewConfigFactory(args *ConfigFactoryArgs) Configurator {
},
)
// Setup cache comparer
// Setup cache debugger
debugger := cachedebugger.New(
args.NodeInformer.Lister(),
args.PodInformer.Lister(),
c.schedulerCache,
c.podQueue,
)
ch := make(chan os.Signal, 1)
signal.Notify(ch, compareSignal)
debugger.ListenForSignal(c.StopEverything)
go func() {
for {
select {
case <-c.StopEverything:
c.podQueue.Close()
return
case <-ch:
debugger.Comparer.Compare()
debugger.Dumper.DumpAll()
}
}
<-c.StopEverything
c.podQueue.Close()
}()
return c

View File

@ -6,6 +6,8 @@ go_library(
"comparer.go",
"debugger.go",
"dumper.go",
"signal.go",
"signal_windows.go",
],
importpath = "k8s.io/kubernetes/pkg/scheduler/internal/cache/debugger",
visibility = ["//pkg/scheduler:__subpackages__"],

View File

@ -17,6 +17,9 @@ limitations under the License.
package debugger
import (
"os"
"os/signal"
corelisters "k8s.io/client-go/listers/core/v1"
internalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache"
internalqueue "k8s.io/kubernetes/pkg/scheduler/internal/queue"
@ -48,3 +51,22 @@ func New(
},
}
}
// ListenForSignal starts a goroutine that will trigger the CacheDebugger's
// behavior when the process receives SIGINT (Windows) or SIGUSER2 (non-Windows).
func (d *CacheDebugger) ListenForSignal(stopCh <-chan struct{}) {
ch := make(chan os.Signal, 1)
signal.Notify(ch, compareSignal)
go func() {
for {
select {
case <-stopCh:
return
case <-ch:
d.Comparer.Compare()
d.Dumper.DumpAll()
}
}
}()
}

View File

@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package factory
package debugger
import "syscall"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package factory
package debugger
import "os"