Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn on node level validation, and make the validation set dynamic. #2855

Merged
merged 1 commit into from
Dec 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (g *APIGroupVersion) InstallREST(container *restful.Container, root string,
}

// TODO: Convert to go-restful
func InstallValidator(mux Mux, servers map[string]Server) {
func InstallValidator(mux Mux, servers func() map[string]Server) {
validator, err := NewValidator(servers)
if err != nil {
glog.Errorf("failed to set up validator: %v", err)
Expand Down
8 changes: 4 additions & 4 deletions pkg/apiserver/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Server struct {
// validator is responsible for validating the cluster and serving
type validator struct {
// a list of servers to health check
servers map[string]Server
servers func() map[string]Server
client httpGet
}

Expand Down Expand Up @@ -72,7 +72,7 @@ type ServerStatus struct {

func (v *validator) ServeHTTP(w http.ResponseWriter, r *http.Request) {
reply := []ServerStatus{}
for name, server := range v.servers {
for name, server := range v.servers() {
status, msg, err := server.check(v.client)
var errorMsg string
if err != nil {
Expand All @@ -93,7 +93,7 @@ func (v *validator) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

// NewValidator creates a validator for a set of servers.
func NewValidator(servers map[string]Server) (http.Handler, error) {
func NewValidator(servers func() map[string]Server) (http.Handler, error) {
return &validator{
servers: servers,
client: &http.Client{},
Expand All @@ -114,7 +114,7 @@ func makeTestValidator(servers map[string]string, get httpGet) (http.Handler, er
result[name] = Server{Addr: host, Port: val, Path: "/healthz"}
}

v, e := NewValidator(result)
v, e := NewValidator(func() map[string]Server { return result })
if e == nil {
v.(*validator).client = get
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/master/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ func (m *Master) init(c *Config) {
apiserver.InstallSupport(m.handlerContainer, m.rootWebService)

// TODO: use go-restful
serversToValidate := m.getServersToValidate(c)
apiserver.InstallValidator(m.mux, serversToValidate)
apiserver.InstallValidator(m.mux, func() map[string]apiserver.Server { return m.getServersToValidate(c) })
if c.EnableLogsSupport {
apiserver.InstallLogsSupport(m.mux)
}
Expand Down Expand Up @@ -430,7 +429,7 @@ func (m *Master) getServersToValidate(c *Config) map[string]apiserver.Server {
glog.Errorf("Failed to list minions: %v", err)
}
for ix, node := range nodes.Items {
serversToValidate[fmt.Sprintf("node-%d", ix)] = apiserver.Server{Addr: node.Status.HostIP, Port: 10250, Path: "/healthz"}
serversToValidate[fmt.Sprintf("node-%d", ix)] = apiserver.Server{Addr: node.Name, Port: 10250, Path: "/healthz"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work on all platforms? What if there is only an IP address? Will that be used as the Name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we have a general problem here. We really need to have both an "internal" and "external" IP address for minions. Currently HostIP is only populated with external IP, which doesn't work for these health checks.

}
return serversToValidate
}
Expand Down