Merge pull request #105995 from NoicFank/feature-add-error-handle

Add error handling for Write() function
This commit is contained in:
Kubernetes Prow Robot 2022-05-03 17:18:07 -07:00 committed by GitHub
commit be9ef536cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -310,7 +310,10 @@ func (eic *execInContainer) Stop() {
func (eic *execInContainer) Start() error {
data, err := eic.run()
if eic.writer != nil {
eic.writer.Write(data)
// only record the write error, do not cover the command run error
if p, err := eic.writer.Write(data); err != nil {
klog.ErrorS(err, "Unable to write all bytes from execInContainer", "expectedBytes", len(data), "actualBytes", p)
}
}
return err
}