mirror of https://github.com/k3s-io/k3s
Make getSchedulingLatency use master proxy
parent
775369a8f1
commit
4852ca23ef
|
@ -53,7 +53,7 @@ kube-scheduler
|
|||
### Options
|
||||
|
||||
```
|
||||
--address=127.0.0.1: The IP address to serve on (set to 0.0.0.0 for all interfaces)
|
||||
--address=0.0.0.0: The IP address to serve on (set to 0.0.0.0 for all interfaces)
|
||||
--algorithm-provider="DefaultProvider": The scheduling algorithm provider to use, one of: DefaultProvider
|
||||
--bind-pods-burst=100: Number of bindings per second scheduler is allowed to make during bursts
|
||||
--bind-pods-qps=50: Number of bindings per second scheduler is allowed to continuously make
|
||||
|
@ -68,7 +68,7 @@ kube-scheduler
|
|||
--profiling[=true]: Enable profiling via web interface host:port/debug/pprof/
|
||||
```
|
||||
|
||||
###### Auto generated by spf13/cobra on 13-Oct-2015
|
||||
###### Auto generated by spf13/cobra on 14-Dec-2015
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
|
|
|
@ -64,7 +64,7 @@ type SchedulerServer struct {
|
|||
func NewSchedulerServer() *SchedulerServer {
|
||||
s := SchedulerServer{
|
||||
Port: ports.SchedulerPort,
|
||||
Address: net.ParseIP("127.0.0.1"),
|
||||
Address: net.ParseIP("0.0.0.0"),
|
||||
AlgorithmProvider: factory.DefaultProvider,
|
||||
BindPodsQPS: 50.0,
|
||||
BindPodsBurst: 100,
|
||||
|
|
|
@ -145,7 +145,7 @@ var _ = Describe("Density [Skipped]", func() {
|
|||
// Verify scheduler metrics.
|
||||
// TODO: Reset metrics at the beginning of the test.
|
||||
// We should do something similar to how we do it for APIserver.
|
||||
expectNoError(VerifySchedulerLatency())
|
||||
expectNoError(VerifySchedulerLatency(c))
|
||||
})
|
||||
|
||||
// Explicitly put here, to delete namespace at the end of the test
|
||||
|
|
|
@ -31,6 +31,7 @@ import (
|
|||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||
"k8s.io/kubernetes/pkg/master/ports"
|
||||
"k8s.io/kubernetes/pkg/util/sets"
|
||||
|
||||
"github.com/prometheus/common/expfmt"
|
||||
|
@ -256,15 +257,41 @@ func getMetrics(c *client.Client) (string, error) {
|
|||
}
|
||||
|
||||
// Retrieves scheduler metrics information.
|
||||
func getSchedulingLatency() (SchedulingLatency, error) {
|
||||
func getSchedulingLatency(c *client.Client) (SchedulingLatency, error) {
|
||||
result := SchedulingLatency{}
|
||||
|
||||
cmd := "curl http://localhost:10251/metrics"
|
||||
sshResult, err := SSH(cmd, getMasterHost()+":22", testContext.Provider)
|
||||
if err != nil || sshResult.Code != 0 {
|
||||
return result, fmt.Errorf("unexpected error (code: %d) in ssh connection to master: %#v", sshResult.Code, err)
|
||||
// Check if master Node is registered
|
||||
nodes, err := c.Nodes().List(api.ListOptions{})
|
||||
expectNoError(err)
|
||||
|
||||
var data string
|
||||
var masterRegistered = false
|
||||
for _, node := range nodes.Items {
|
||||
if strings.HasSuffix(node.Name, "master") {
|
||||
masterRegistered = true
|
||||
}
|
||||
}
|
||||
samples, err := extractMetricSamples(sshResult.Stdout)
|
||||
if masterRegistered {
|
||||
rawData, err := c.Get().
|
||||
Prefix("proxy").
|
||||
Namespace(api.NamespaceSystem).
|
||||
Resource("pods").
|
||||
Name(fmt.Sprintf("kube-scheduler-%v:%v", testContext.CloudConfig.MasterName, ports.SchedulerPort)).
|
||||
Suffix("metrics").
|
||||
Do().Raw()
|
||||
|
||||
expectNoError(err)
|
||||
data = string(rawData)
|
||||
} else {
|
||||
// If master is not registered fall back to old method of using SSH.
|
||||
cmd := "curl http://localhost:10251/metrics"
|
||||
sshResult, err := SSH(cmd, getMasterHost()+":22", testContext.Provider)
|
||||
if err != nil || sshResult.Code != 0 {
|
||||
return result, fmt.Errorf("unexpected error (code: %d) in ssh connection to master: %#v", sshResult.Code, err)
|
||||
}
|
||||
data = sshResult.Stdout
|
||||
}
|
||||
samples, err := extractMetricSamples(data)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
@ -294,8 +321,8 @@ func getSchedulingLatency() (SchedulingLatency, error) {
|
|||
}
|
||||
|
||||
// Verifies (currently just by logging them) the scheduling latencies.
|
||||
func VerifySchedulerLatency() error {
|
||||
latency, err := getSchedulingLatency()
|
||||
func VerifySchedulerLatency(c *client.Client) error {
|
||||
latency, err := getSchedulingLatency(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue