@@ -30,6 +30,7 @@ import (
3030 "github.com/containerd/containerd/images"
3131 "github.com/containerd/containerd/log"
3232 "github.com/containerd/containerd/remotes"
33+ remoteserrors "github.com/containerd/containerd/remotes/errors"
3334 digest "github.com/opencontainers/go-digest"
3435 ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3536 "github.com/pkg/errors"
@@ -112,8 +113,9 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
112113 return nil , errors .Wrapf (errdefs .ErrAlreadyExists , "content %v on remote" , desc .Digest )
113114 }
114115 } else if resp .StatusCode != http .StatusNotFound {
115- // TODO: log error
116- return nil , errors .Errorf ("unexpected response: %s" , resp .Status )
116+ err := remoteserrors .NewUnexpectedStatusErr (resp )
117+ log .G (ctx ).WithField ("resp" , resp ).WithField ("body" , string (err .(remoteserrors.ErrUnexpectedStatus ).Body )).Debug ("unexpected response" )
118+ return nil , err
117119 }
118120 }
119121
@@ -166,8 +168,9 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
166168 })
167169 return nil , errors .Wrapf (errdefs .ErrAlreadyExists , "content %v on remote" , desc .Digest )
168170 default :
169- // TODO: log error
170- return nil , errors .Errorf ("unexpected response: %s" , resp .Status )
171+ err := remoteserrors .NewUnexpectedStatusErr (resp )
172+ log .G (ctx ).WithField ("resp" , resp ).WithField ("body" , string (err .(remoteserrors.ErrUnexpectedStatus ).Body )).Debug ("unexpected response" )
173+ return nil , err
171174 }
172175
173176 var (
@@ -244,8 +247,9 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
244247 switch resp .StatusCode {
245248 case http .StatusOK , http .StatusCreated , http .StatusNoContent :
246249 default :
247- // TODO: log error
248- pr .CloseWithError (errors .Errorf ("unexpected response: %s" , resp .Status ))
250+ err := remoteserrors .NewUnexpectedStatusErr (resp )
251+ log .G (ctx ).WithField ("resp" , resp ).WithField ("body" , string (err .(remoteserrors.ErrUnexpectedStatus ).Body )).Debug ("unexpected response" )
252+ pr .CloseWithError (err )
249253 }
250254 respC <- resp
251255 }()
0 commit comments