Skip to content

Commit 5b4ffa2

Browse files
committed
chore: descriptive write errors in blobwriter
1 parent 19f18ec commit 5b4ffa2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

internal/storage/containerd/blobwriter.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,23 @@ func (bw *blobWriter) Size() int64 {
9999
// ReadFrom reads from the provided reader and writes to the containerd blob writer.
100100
func (bw *blobWriter) ReadFrom(r io.Reader) (int64, error) {
101101
n, err := io.Copy(bw.writer, r)
102+
if err != nil {
103+
err = fmt.Errorf("copy data to containerd blob writer: %w", err)
104+
}
102105
bw.size += n
103-
bw.log.WithField("size", n).Debug("Copied data to containerd blob writer.")
106+
bw.log.WithField("size", n).WithError(err).Debug("Copied data to containerd blob writer.")
104107

105108
return n, err
106109
}
107110

108111
// Write writes data to the containerd blob writer.
109112
func (bw *blobWriter) Write(data []byte) (int, error) {
110113
n, err := bw.writer.Write(data)
114+
if err != nil {
115+
err = fmt.Errorf("write data to containerd blob writer: %w", err)
116+
}
111117
bw.size += int64(n)
112-
bw.log.WithField("size", n).Debug("Wrote data to containerd blob writer.")
118+
bw.log.WithField("size", n).WithError(err).Debug("Wrote data to containerd blob writer.")
113119

114120
return n, err
115121
}

0 commit comments

Comments
 (0)