mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Address some comments from thockin@
This commit is contained in:
parent
56735fe2ec
commit
6312ffebcf
@ -116,11 +116,10 @@ type HTTPGetProbe struct {
|
|||||||
|
|
||||||
// LivenessProbe describes a liveness probe to be examined to the container.
|
// LivenessProbe describes a liveness probe to be examined to the container.
|
||||||
type LivenessProbe struct {
|
type LivenessProbe struct {
|
||||||
Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
|
|
||||||
// Type of liveness probe. Current legal values "http"
|
// Type of liveness probe. Current legal values "http"
|
||||||
Type string `yaml:"type,omitempty" json:"type,omitempty"`
|
Type string `yaml:"type,omitempty" json:"type,omitempty"`
|
||||||
// HTTPGetProbe parameters, required if Type == 'http'
|
// 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.
|
// Length of time before health checking is activated. In seconds.
|
||||||
InitialDelaySeconds int64 `yaml:"initialDelaySeconds,omitempty" json:"initialDelaySeconds,omitempty"`
|
InitialDelaySeconds int64 `yaml:"initialDelaySeconds,omitempty" json:"initialDelaySeconds,omitempty"`
|
||||||
}
|
}
|
||||||
@ -143,7 +142,7 @@ type Container struct {
|
|||||||
// Optional: Defaults to unlimited.
|
// Optional: Defaults to unlimited.
|
||||||
CPU int `yaml:"cpu,omitempty" json:"cpu,omitempty"`
|
CPU int `yaml:"cpu,omitempty" json:"cpu,omitempty"`
|
||||||
VolumeMounts []VolumeMount `yaml:"volumeMounts,omitempty" json:"volumeMounts,omitempty"`
|
VolumeMounts []VolumeMount `yaml:"volumeMounts,omitempty" json:"volumeMounts,omitempty"`
|
||||||
LivenessProbe LivenessProbe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
|
LivenessProbe *LivenessProbe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Percentile represents a pair which contains a percentage from 0 to 100 and
|
// Percentile represents a pair which contains a percentage from 0 to 100 and
|
||||||
|
@ -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.
|
// 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) {
|
func (h *HTTPHealthChecker) IsHealthy(container api.Container) (bool, error) {
|
||||||
params := container.LivenessProbe.HTTPGet
|
params := container.LivenessProbe.HTTPGet
|
||||||
|
if params == nil {
|
||||||
|
return true, fmt.Errorf("Error, no HTTP parameters specified: %v", container)
|
||||||
|
}
|
||||||
port := h.findPort(container, params.Port)
|
port := h.findPort(container, params.Port)
|
||||||
if port == -1 {
|
if port == -1 {
|
||||||
var err error
|
var err error
|
||||||
|
@ -46,8 +46,8 @@ func TestHttpHealth(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
container := api.Container{
|
container := api.Container{
|
||||||
LivenessProbe: api.LivenessProbe{
|
LivenessProbe: &api.LivenessProbe{
|
||||||
HTTPGet: api.HTTPGetProbe{
|
HTTPGet: &api.HTTPGetProbe{
|
||||||
Port: "8080",
|
Port: "8080",
|
||||||
Path: "/foo/bar",
|
Path: "/foo/bar",
|
||||||
},
|
},
|
||||||
|
@ -991,7 +991,7 @@ func (kl *Kubelet) GetMachineStats() (*api.ContainerStats, error) {
|
|||||||
|
|
||||||
func (kl *Kubelet) healthy(container api.Container, dockerContainer *docker.APIContainers) (bool, error) {
|
func (kl *Kubelet) healthy(container api.Container, dockerContainer *docker.APIContainers) (bool, error) {
|
||||||
// Give the container 60 seconds to start up.
|
// Give the container 60 seconds to start up.
|
||||||
if !container.LivenessProbe.Enabled {
|
if container.LivenessProbe == nil {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if time.Now().Unix()-dockerContainer.Created < container.LivenessProbe.InitialDelaySeconds {
|
if time.Now().Unix()-dockerContainer.Created < container.LivenessProbe.InitialDelaySeconds {
|
||||||
|
@ -448,8 +448,7 @@ func TestSyncManifestsUnhealthy(t *testing.T) {
|
|||||||
ID: "foo",
|
ID: "foo",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{Name: "bar",
|
{Name: "bar",
|
||||||
LivenessProbe: api.LivenessProbe{
|
LivenessProbe: &api.LivenessProbe{
|
||||||
Enabled: true,
|
|
||||||
// Always returns healthy == false
|
// Always returns healthy == false
|
||||||
Type: "false",
|
Type: "false",
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user