Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions depot/steps/readiness_health_check_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ func (step *readinessHealthCheckStep) runUntilReadyProcess(signals <-chan os.Sig
return err
}
step.logger.Info("transitioned-to-ready")
step.readinessChan <- IsReady
fmt.Fprint(step.logStreamer.Stdout(), "Container passed the readiness health check. Container marked ready and added to route pool.\n")
return nil
select {
case step.readinessChan <- IsReady:
fmt.Fprint(step.logStreamer.Stdout(), "Container passed the readiness health check. Container marked ready and added to route pool.\n")
return nil
case <-signals:
return new(CancelledError)
}
case s := <-signals:
untilReadyProcess.Signal(s)
<-untilReadyProcess.Wait()
Expand All @@ -81,9 +85,13 @@ func (step *readinessHealthCheckStep) runUntilFailureProcess(signals <-chan os.S
case err := <-untilFailureProcess.Wait():
if err != nil {
step.logger.Info("transitioned-to-not-ready")
fmt.Fprint(step.logStreamer.Stdout(), "Container failed the readiness health check. Container marked not ready and removed from route pool.\n")
step.readinessChan <- IsNotReady
return nil
select {
case step.readinessChan <- IsNotReady:
fmt.Fprint(step.logStreamer.Stdout(), "Container failed the readiness health check. Container marked not ready and removed from route pool.\n")
return nil
case <-signals:
return new(CancelledError)
}
}
step.logger.Error("unexpected-until-failure-check-result", err)
return nil
Expand Down
30 changes: 29 additions & 1 deletion depot/steps/readiness_health_check_step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package steps_test

import (
"errors"
"fmt"
"os"

"code.cloudfoundry.org/executor/depot/log_streamer/fake_log_streamer"
Expand Down Expand Up @@ -205,6 +206,33 @@ var _ = Describe("NewReadinessHealthCheckStep", func() {
})
})

Context("while waiting on the readines channel to receive", func() {
Context("while doing the untilReadyCheck", func() {
JustBeforeEach(func() {
Eventually(untilReadyCheck.RunCallCount).Should(Equal(1))
untilReadyCheck.TriggerExit(nil)
})
It("cancels the in-flight check", func() {
process.Signal(os.Interrupt)
Eventually(process.Wait()).Should(Receive(Equal(new(steps.CancelledError))))
})
})
Context("while doing the untilFailureCheck", func() {
JustBeforeEach(func() {
untilReadyCheck.TriggerExit(nil)
state := <-readinessChan
Expect(state).To(Equal(steps.IsReady))
Eventually(untilFailureCheck.RunCallCount).Should(Equal(1))
})

It("cancels the in-flight check", func() {
untilFailureCheck.TriggerExit(fmt.Errorf("meow"))
process.Signal(os.Interrupt)
Eventually(process.Wait()).Should(Receive(Equal(new(steps.CancelledError))))
})
})
})

Context("while doing the untilFailure check", func() {
JustBeforeEach(func() {
untilReadyCheck.TriggerExit(nil)
Expand All @@ -216,7 +244,7 @@ var _ = Describe("NewReadinessHealthCheckStep", func() {
It("cancels the in-flight check", func() {
process.Signal(os.Interrupt)
Eventually(untilFailureCheck.WaitForCall()).Should(Receive(Equal(os.Interrupt)))
untilFailureCheck.TriggerExit(nil)
untilFailureCheck.TriggerExit(fmt.Errorf("meow"))
Eventually(process.Wait()).Should(Receive(Equal(new(steps.CancelledError))))
})
})
Expand Down