Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 12 additions & 5 deletions depot/steps/run_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ func (step *runStep) Run(signals <-chan os.Signal, ready chan<- struct{}) error
select {
case err := <-errChan:
if err != nil {
step.logger.Error("failed-creating-process", err, lager.Data{"duration": step.clock.Now().Sub(runStartTime)})
processErrorMessage := "failed-creating-process"
step.logger.Error(processErrorMessage, err, lager.Data{"duration": step.clock.Now().Sub(runStartTime)})
step.WriteToStdOut(fmt.Sprintf("%s: %s", processErrorMessage, err))

return err
}
case process = <-processChan:
Expand Down Expand Up @@ -227,10 +230,7 @@ func (step *runStep) Run(signals <-chan os.Signal, ready chan<- struct{}) error
}
}

if !step.model.SuppressLogOutput {
step.streamer.Stdout().Write([]byte(exitErrorMessage))
step.streamer.Flush()
}
step.WriteToStdOut(exitErrorMessage)

if killed {
return new(ExceededGracefulShutdownIntervalError)
Expand Down Expand Up @@ -349,3 +349,10 @@ func (step *runStep) networkingEnvVars() []string {

return envVars
}

func (step *runStep) WriteToStdOut(message string) {
if !step.model.SuppressLogOutput {
step.streamer.Stdout().Write([]byte(message))
step.streamer.Flush()
}
}
12 changes: 12 additions & 0 deletions depot/steps/run_step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,18 @@ var _ = Describe("RunAction", func() {

})
})

Context("when Garden Run errors out", func() {
BeforeEach(func() {
gardenClient.Connection.RunStub = func(string, garden.ProcessSpec, garden.ProcessIO) (garden.Process, error) {
return nil, errors.New("some-error-from-garden")
}
})

It("it receives an error from the streamer", func() {
Expect(fakeStreamer.Stdout()).To(gbytes.Say("failed-creating-process: some-error-from-garden"))
})
})
})

Context("CF_INSTANCE_* networking env vars", func() {
Expand Down