Commit 1065302b authored by Victor Marmol's avatar Victor Marmol

Merge pull request #6327 from mikedanese/readiness-probe-busted

Fix readiness probe
parents a94ffc86 32c7de29
...@@ -66,10 +66,14 @@ func (kl *Kubelet) probeContainer(pod *api.Pod, status api.PodStatus, container ...@@ -66,10 +66,14 @@ func (kl *Kubelet) probeContainer(pod *api.Pod, status api.PodStatus, container
ref, ok := kl.containerRefManager.GetRef(containerID) ref, ok := kl.containerRefManager.GetRef(containerID)
if !ok { if !ok {
glog.Warningf("No ref for pod '%v' - '%v'", containerID, container.Name) glog.Warningf("No ref for pod '%v' - '%v'", containerID, container.Name)
} else { return probe.Success, err
kl.recorder.Eventf(ref, "unhealthy", "Liveness Probe Failed %v - %v", containerID, container.Name)
} }
return ready, err
if ready != probe.Success {
kl.recorder.Eventf(ref, "unhealthy", "Readiness Probe Failed %v - %v", containerID, container.Name)
}
return probe.Success, nil
} }
// probeContainerLiveness probes the liveness of a container. // probeContainerLiveness probes the liveness of a container.
......
...@@ -256,14 +256,14 @@ func TestProbeContainer(t *testing.T) { ...@@ -256,14 +256,14 @@ func TestProbeContainer(t *testing.T) {
testContainer: api.Container{ testContainer: api.Container{
ReadinessProbe: &api.Probe{InitialDelaySeconds: 100}, ReadinessProbe: &api.Probe{InitialDelaySeconds: 100},
}, },
expectedResult: probe.Failure, expectedResult: probe.Success,
expectedReadiness: false, expectedReadiness: false,
}, },
{ {
testContainer: api.Container{ testContainer: api.Container{
ReadinessProbe: &api.Probe{InitialDelaySeconds: -100}, ReadinessProbe: &api.Probe{InitialDelaySeconds: -100},
}, },
expectedResult: probe.Unknown, expectedResult: probe.Success,
expectedReadiness: false, expectedReadiness: false,
}, },
{ {
...@@ -275,8 +275,8 @@ func TestProbeContainer(t *testing.T) { ...@@ -275,8 +275,8 @@ func TestProbeContainer(t *testing.T) {
}, },
}, },
}, },
expectedResult: probe.Failure, expectedResult: probe.Success,
expectedReadiness: false, expectedReadiness: true,
}, },
{ {
testContainer: api.Container{ testContainer: api.Container{
...@@ -299,8 +299,8 @@ func TestProbeContainer(t *testing.T) { ...@@ -299,8 +299,8 @@ func TestProbeContainer(t *testing.T) {
}, },
}, },
}, },
expectedResult: probe.Unknown, expectedResult: probe.Success,
expectedReadiness: false, expectedReadiness: true,
}, },
{ {
testContainer: api.Container{ testContainer: api.Container{
...@@ -311,9 +311,9 @@ func TestProbeContainer(t *testing.T) { ...@@ -311,9 +311,9 @@ func TestProbeContainer(t *testing.T) {
}, },
}, },
}, },
expectError: true, expectError: false,
expectedResult: probe.Unknown, expectedResult: probe.Success,
expectedReadiness: false, expectedReadiness: true,
}, },
// Both LivenessProbe and ReadinessProbe. // Both LivenessProbe and ReadinessProbe.
{ {
...@@ -321,7 +321,7 @@ func TestProbeContainer(t *testing.T) { ...@@ -321,7 +321,7 @@ func TestProbeContainer(t *testing.T) {
LivenessProbe: &api.Probe{InitialDelaySeconds: 100}, LivenessProbe: &api.Probe{InitialDelaySeconds: 100},
ReadinessProbe: &api.Probe{InitialDelaySeconds: 100}, ReadinessProbe: &api.Probe{InitialDelaySeconds: 100},
}, },
expectedResult: probe.Failure, expectedResult: probe.Success,
expectedReadiness: false, expectedReadiness: false,
}, },
{ {
...@@ -329,7 +329,7 @@ func TestProbeContainer(t *testing.T) { ...@@ -329,7 +329,7 @@ func TestProbeContainer(t *testing.T) {
LivenessProbe: &api.Probe{InitialDelaySeconds: 100}, LivenessProbe: &api.Probe{InitialDelaySeconds: 100},
ReadinessProbe: &api.Probe{InitialDelaySeconds: -100}, ReadinessProbe: &api.Probe{InitialDelaySeconds: -100},
}, },
expectedResult: probe.Unknown, expectedResult: probe.Success,
expectedReadiness: false, expectedReadiness: false,
}, },
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment