mirror of https://github.com/k3s-io/k3s
Merge pull request #72554 from misterikkit/cachecompare
Move CacheDebugger signal handling into the package.pull/564/head
commit
dd53c82d7c
|
@ -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"],
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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__"],
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package factory
|
||||
package debugger
|
||||
|
||||
import "syscall"
|
||||
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package factory
|
||||
package debugger
|
||||
|
||||
import "os"
|
||||
|
Loading…
Reference in New Issue