Address some comments from thockin@

pull/6/head
Brendan Burns 2014-07-09 16:53:31 -07:00
parent 56735fe2ec
commit 6312ffebcf
5 changed files with 11 additions and 10 deletions

View File

@ -116,11 +116,10 @@ type HTTPGetProbe struct {
// LivenessProbe describes a liveness probe to be examined to the container.
type LivenessProbe struct {
Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
// Type of liveness probe. Current legal values "http"
Type string `yaml:"type,omitempty" json:"type,omitempty"`
// HTTPGetProbe parameters, required if Type == 'http'
HTTPGet HTTPGetProbe `yaml:"httpGet,omitempty" json:"httpGet,omitempty"`
HTTPGet *HTTPGetProbe `yaml:"httpGet,omitempty" json:"httpGet,omitempty"`
// Length of time before health checking is activated. In seconds.
InitialDelaySeconds int64 `yaml:"initialDelaySeconds,omitempty" json:"initialDelaySeconds,omitempty"`
}
@ -141,9 +140,9 @@ type Container struct {
// Optional: Defaults to unlimited.
Memory int `yaml:"memory,omitempty" json:"memory,omitempty"`
// Optional: Defaults to unlimited.
CPU int `yaml:"cpu,omitempty" json:"cpu,omitempty"`
VolumeMounts []VolumeMount `yaml:"volumeMounts,omitempty" json:"volumeMounts,omitempty"`
LivenessProbe LivenessProbe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
CPU int `yaml:"cpu,omitempty" json:"cpu,omitempty"`
VolumeMounts []VolumeMount `yaml:"volumeMounts,omitempty" json:"volumeMounts,omitempty"`
LivenessProbe *LivenessProbe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
}
// Percentile represents a pair which contains a percentage from 0 to 100 and

View File

@ -79,6 +79,9 @@ func (h *HTTPHealthChecker) findPort(container api.Container, portName string) i
// IsHealthy checks if the container is healthy by trying sending HTTP Get requests to the container.
func (h *HTTPHealthChecker) IsHealthy(container api.Container) (bool, error) {
params := container.LivenessProbe.HTTPGet
if params == nil {
return true, fmt.Errorf("Error, no HTTP parameters specified: %v", container)
}
port := h.findPort(container, params.Port)
if port == -1 {
var err error

View File

@ -46,8 +46,8 @@ func TestHttpHealth(t *testing.T) {
}
container := api.Container{
LivenessProbe: api.LivenessProbe{
HTTPGet: api.HTTPGetProbe{
LivenessProbe: &api.LivenessProbe{
HTTPGet: &api.HTTPGetProbe{
Port: "8080",
Path: "/foo/bar",
},

View File

@ -991,7 +991,7 @@ func (kl *Kubelet) GetMachineStats() (*api.ContainerStats, error) {
func (kl *Kubelet) healthy(container api.Container, dockerContainer *docker.APIContainers) (bool, error) {
// Give the container 60 seconds to start up.
if !container.LivenessProbe.Enabled {
if container.LivenessProbe == nil {
return true, nil
}
if time.Now().Unix()-dockerContainer.Created < container.LivenessProbe.InitialDelaySeconds {

View File

@ -448,8 +448,7 @@ func TestSyncManifestsUnhealthy(t *testing.T) {
ID: "foo",
Containers: []api.Container{
{Name: "bar",
LivenessProbe: api.LivenessProbe{
Enabled: true,
LivenessProbe: &api.LivenessProbe{
// Always returns healthy == false
Type: "false",
},