mirror of
https://github.com/moby/moby.git
synced 2026-06-30 19:58:03 +00:00
Merge pull request #52698 from MD-Mushfiqur123/fix/issue-52570-swarm-auth-error
fix: propagate registry auth error in swarm image pull
This commit is contained in:
@@ -174,6 +174,14 @@ func (r *controller) Prepare(ctx context.Context) error {
|
||||
// If you don't want this behavior, lock down your image to an
|
||||
// immutable tag or digest.
|
||||
log.G(ctx).WithError(r.pullErr).Error("pulling image failed")
|
||||
|
||||
// If the pull failed with an authentication error, return it
|
||||
// so the actual cause is propagated instead of the misleading
|
||||
// "No such image" error that would otherwise result from the
|
||||
// container create below.
|
||||
if cerrdefs.IsUnauthorized(r.pullErr) {
|
||||
return r.pullErr
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,8 @@ func translatePullError(err error, ref reference.Named) error {
|
||||
switch v.Code {
|
||||
case errcode.ErrorCodeDenied, v2.ErrorCodeManifestUnknown, v2.ErrorCodeNameUnknown:
|
||||
return notFoundError{v, ref}
|
||||
case errcode.ErrorCodeUnauthorized:
|
||||
return errdefs.Unauthorized(v)
|
||||
}
|
||||
case xfer.DoNotRetry:
|
||||
return translatePullError(v.Err, ref)
|
||||
|
||||
Reference in New Issue
Block a user