Move isMasterNode function to api/helpers

pull/6/head
gmarek 2016-03-01 11:49:51 +01:00
parent 546bd99d8d
commit 6697834797
2 changed files with 30 additions and 7 deletions

View File

@ -18,7 +18,6 @@ package metrics
import (
"fmt"
"strings"
"time"
"k8s.io/kubernetes/pkg/api"
@ -26,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/system"
"github.com/golang/glog"
)
@ -51,11 +51,6 @@ type MetricsGrabber struct {
registeredMaster bool
}
// TODO: find a better way of figuring out if given node is a registered master.
func isMasterNode(node *api.Node) bool {
return strings.HasSuffix(node.Name, "master")
}
func NewMetricsGrabber(c *client.Client, kubelets bool, scheduler bool, controllers bool, apiServer bool) (*MetricsGrabber, error) {
registeredMaster := false
masterName := ""
@ -67,7 +62,7 @@ func NewMetricsGrabber(c *client.Client, kubelets bool, scheduler bool, controll
glog.Warning("Can't find any Nodes in the API server to grab metrics from")
}
for _, node := range nodeList.Items {
if isMasterNode(&node) {
if system.IsMasterNode(&node) {
registeredMaster = true
masterName = node.Name
break

View File

@ -0,0 +1,28 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package system
import (
"strings"
"k8s.io/kubernetes/pkg/api"
)
// TODO: find a better way of figuring out if given node is a registered master.
func IsMasterNode(node *api.Node) bool {
return strings.HasSuffix(node.Name, "master")
}