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
12 changes: 6 additions & 6 deletions depot/log_streamer/log_streamer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ var _ = Describe("LogStreamer", func() {
maxLogLinesPerSecond, maxLogBytesPerSecond = 1, 100
streamer = log_streamer.New(logConfig, fakeClient, maxLogLinesPerSecond, maxLogBytesPerSecond, metricReportInterval)

fmt.Fprintf(streamer.Stdout(), strings.Repeat("a", 1000)+"\n")
fmt.Fprintf(streamer.Stdout(), "bbbbbbb\n")
fmt.Fprintln(streamer.Stdout(), strings.Repeat("a", 1000))
fmt.Fprintln(streamer.Stdout(), "bbbbbbb")
})

It("causes outages of logs", func() {
Expand Down Expand Up @@ -454,7 +454,7 @@ var _ = Describe("LogStreamer", func() {
message = strings.Repeat("7", log_streamer.MAX_MESSAGE_SIZE)
Expect([]byte(message)).To(HaveLen(log_streamer.MAX_MESSAGE_SIZE), "Ensure that the byte representation of our message is under the limit")

fmt.Fprintf(streamer.Stdout(), message+"\n")
fmt.Fprintln(streamer.Stdout(), message)
})

It("should not break the message up and send a single messages", func() {
Expand Down Expand Up @@ -512,8 +512,8 @@ var _ = Describe("LogStreamer", func() {
})

It("emits both messages correctly", func() {
fmt.Fprintf(streamer.Stdout(), message+utfChar[0:2])
fmt.Fprintf(streamer.Stdout(), utfChar+"\n")
fmt.Fprint(streamer.Stdout(), message+utfChar[0:2])
fmt.Fprintln(streamer.Stdout(), utfChar)

Expect(fakeClient.SendAppLogCallCount()).To(Equal(2))

Expand Down Expand Up @@ -579,7 +579,7 @@ var _ = Describe("LogStreamer", func() {
})

It("should handle long messages", func() {
fmt.Fprintf(streamer.Stderr(), strings.Repeat("e", log_streamer.MAX_MESSAGE_SIZE+1)+"\n")
fmt.Fprintln(streamer.Stderr(), strings.Repeat("e", log_streamer.MAX_MESSAGE_SIZE+1))
Expect(fakeClient.SendAppErrorLogCallCount()).To(Equal(2))

msg, _, _ := fakeClient.SendAppErrorLogArgsForCall(0)
Expand Down
9 changes: 5 additions & 4 deletions depot/steps/download_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ func (step *downloadStep) perform() error {
errString = "Downloading failed"
}

step.emitError(fmt.Sprintf("%s\n", errString))
return NewEmittableError(err, errString)
step.emitError("%s\n", errString)
return NewEmittableError(err, "%s", errString)
}

err = step.streamIn(step.model.To, downloadedFile)
Expand All @@ -103,8 +103,9 @@ func (step *downloadStep) perform() error {
} else {
errString = fmt.Sprintf("Copying into the container failed: %v", err)
}
step.emitError(fmt.Sprintf("%s\n", errString))
return NewEmittableError(err, errString)

step.emitError("%s\n", errString)
return NewEmittableError(err, "%s", errString)
}

if downloadedSize != 0 {
Expand Down
2 changes: 1 addition & 1 deletion depot/steps/output_wrapper_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ func (step *outputWrapperStep) Run(signals <-chan os.Signal, ready chan<- struct
if step.prefix != "" {
msg = step.prefix + ": " + msg
}
return NewEmittableError(subStepErr, msg)
return NewEmittableError(subStepErr, "%s", msg)
}
2 changes: 1 addition & 1 deletion depot/steps/run_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (step *runStep) Run(signals <-chan os.Signal, ready chan<- struct{}) error

if exitStatus != 0 {
logger.Error("run-step-failed-with-nonzero-status-code", errors.New(exitErrorMessage), lager.Data{"status-code": exitStatus})
return NewEmittableError(nil, emittableExitErrorMessage)
return NewEmittableError(nil, "%s", emittableExitErrorMessage)
}

return nil
Expand Down
8 changes: 4 additions & 4 deletions depot/steps/run_step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ var _ = Describe("RunAction", func() {

It("should return an emittable error with the exit code", func() {
errMsg := fmt.Sprintf("%s: Exited with status 19", testLogSource)
Eventually(process.Wait()).Should(Receive(MatchError(steps.NewEmittableError(nil, errMsg))))
Eventually(process.Wait()).Should(Receive(MatchError(steps.NewEmittableError(nil, "%s", errMsg))))
})
})

Expand All @@ -460,7 +460,7 @@ var _ = Describe("RunAction", func() {

It("should return an emittable error with the exit code", func() {
errMsg := fmt.Sprintf("%s: Exited with status 19", testLogSource)
Eventually(process.Wait()).Should(Receive(MatchError(steps.NewEmittableError(nil, errMsg))))
Eventually(process.Wait()).Should(Receive(MatchError(steps.NewEmittableError(nil, "%s", errMsg))))
})
})
})
Expand Down Expand Up @@ -534,7 +534,7 @@ var _ = Describe("RunAction", func() {

It("returns an emittable error", func() {
errMsg := fmt.Sprintf("%s: Exited with status 19 (out of memory)", testLogSource)
Eventually(process.Wait()).Should(Receive(MatchError(steps.NewEmittableError(nil, errMsg))))
Eventually(process.Wait()).Should(Receive(MatchError(steps.NewEmittableError(nil, "%s", errMsg))))
})
})

Expand All @@ -552,7 +552,7 @@ var _ = Describe("RunAction", func() {

It("returns an emittable error", func() {
errMsg := fmt.Sprintf("%s: Exited with status 19 (out of memory)", testLogSource)
Eventually(process.Wait()).Should(Receive(MatchError(steps.NewEmittableError(nil, errMsg))))
Eventually(process.Wait()).Should(Receive(MatchError(steps.NewEmittableError(nil, "%s", errMsg))))
})
})

Expand Down
2 changes: 1 addition & 1 deletion depot/steps/timeout_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (step *timeoutStep) Run(signals <-chan os.Signal, ready chan<- struct{}) (e
step.logger.Error("timed-out", nil)
subStepSignals <- os.Interrupt
err := <-resultCh
return NewEmittableError(err, emittableMessage(step.timeout, err))
return NewEmittableError(err, "%s", emittableMessage(step.timeout, err))
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions depot/steps/upload_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (step *uploadStep) Run(signals <-chan os.Signal, ready chan<- struct{}) (er
step.logger.Error("failed-to-create-tmp-dir", err)
errString := step.artifactErrString(ErrCreateTmpDir)
step.emitError(errString)
return NewEmittableError(err, errString)
return NewEmittableError(err, "%s", errString)
}

defer os.RemoveAll(tempDir)
Expand All @@ -101,7 +101,7 @@ func (step *uploadStep) Run(signals <-chan os.Signal, ready chan<- struct{}) (er
step.logger.Error("failed-to-stream-out", err)
errString := step.artifactErrString(ErrEstablishStream)
step.emitError(errString)
return NewEmittableError(err, errString)
return NewEmittableError(err, "%s", errString)
}
defer outStream.Close()

Expand All @@ -112,15 +112,15 @@ func (step *uploadStep) Run(signals <-chan os.Signal, ready chan<- struct{}) (er
step.logger.Error("failed-to-read-stream", err)
errString := step.artifactErrString(ErrReadTar)
step.emitError(errString)
return NewEmittableError(err, errString)
return NewEmittableError(err, "%s", errString)
}

tempFile, err := os.CreateTemp(step.tempDir, "compressed")
if err != nil {
step.logger.Error("failed-to-create-tmp-dir", err)
errString := step.artifactErrString(ErrCreateTmpFile)
step.emitError(errString)
return NewEmittableError(err, errString)
return NewEmittableError(err, "%s", errString)
}
finalFileLocation := tempFile.Name()
defer func() {
Expand All @@ -140,7 +140,7 @@ func (step *uploadStep) Run(signals <-chan os.Signal, ready chan<- struct{}) (er
step.logger.Error("failed-to-copy-stream", err)
errString := step.artifactErrString(ErrCopyStreamToTmp)
step.emitError(errString)
return NewEmittableError(err, errString)
return NewEmittableError(err, "%s", errString)
}

finished := make(chan struct{})
Expand Down
6 changes: 4 additions & 2 deletions depot/steps/upload_step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ var _ = Describe("UploadStep", func() {
It("should emits an error with the artifact name", func() {
err := <-ifrit.Invoke(step).Wait()
Expect(err).To(HaveOccurred())
Expect(err).To(MatchError(steps.NewEmittableError(errStream, fmt.Sprintf("%s for %s", steps.ErrEstablishStream, "artifact"))))
errString := fmt.Sprintf("%s for %s", steps.ErrEstablishStream, "artifact")
Expect(err).To(MatchError(steps.NewEmittableError(errStream, "%s", errString)))
})

It("should log error with artifact name", func() {
Expand Down Expand Up @@ -505,7 +506,8 @@ var _ = Describe("UploadStep", func() {
It("should emits an error with the artifact name", func() {
err := <-ifrit.Invoke(step).Wait()
Expect(err).To(HaveOccurred())
Expect(err).To(MatchError(steps.NewEmittableError(errStream, fmt.Sprintf("%s for %s", steps.ErrReadTar, "artifact"))))
errString := fmt.Sprintf("%s for %s", steps.ErrReadTar, "artifact")
Expect(err).To(MatchError(steps.NewEmittableError(errStream, "%s", errString)))
})

It("should log error with artifact name", func() {
Expand Down