Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
4b3f4bc7
Unverified
Commit
4b3f4bc7
authored
Nov 16, 2023
by
Bruce MacDonald
Committed by
GitHub
Nov 16, 2023
Browse files
return failure details when unauthorized to push (#1131)
Co-authored-by:
Jeffrey Morgan
<
jmorganca@gmail.com
>
parent
a5ccf742
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
server/images.go
server/images.go
+8
-3
No files found.
server/images.go
View file @
4b3f4bc7
...
...
@@ -954,6 +954,9 @@ func PushModel(ctx context.Context, name string, regOpts *RegistryOptions, fn fu
for
_
,
layer
:=
range
layers
{
if
err
:=
uploadBlob
(
ctx
,
mp
,
layer
,
regOpts
,
fn
);
err
!=
nil
{
log
.
Printf
(
"error uploading blob: %v"
,
err
)
if
errors
.
Is
(
err
,
errUnauthorized
)
{
return
fmt
.
Errorf
(
"unable to push %s, make sure this namespace exists and you are authorized to push to it"
,
ParseModelPath
(
name
)
.
GetNamespaceRepository
())
}
return
err
}
}
...
...
@@ -1140,7 +1143,10 @@ func GetSHA256Digest(r io.Reader) (string, int64) {
return
fmt
.
Sprintf
(
"sha256:%x"
,
h
.
Sum
(
nil
)),
n
}
var
errUnauthorized
=
fmt
.
Errorf
(
"unauthorized"
)
func
makeRequestWithRetry
(
ctx
context
.
Context
,
method
string
,
requestURL
*
url
.
URL
,
headers
http
.
Header
,
body
io
.
ReadSeeker
,
regOpts
*
RegistryOptions
)
(
*
http
.
Response
,
error
)
{
lastErr
:=
errMaxRetriesExceeded
for
try
:=
0
;
try
<
maxRetries
;
try
++
{
resp
,
err
:=
makeRequest
(
ctx
,
method
,
requestURL
,
headers
,
body
,
regOpts
)
if
err
!=
nil
{
...
...
@@ -1161,8 +1167,7 @@ func makeRequestWithRetry(ctx context.Context, method string, requestURL *url.UR
if
body
!=
nil
{
body
.
Seek
(
0
,
io
.
SeekStart
)
}
continue
lastErr
=
errUnauthorized
case
resp
.
StatusCode
==
http
.
StatusNotFound
:
return
nil
,
os
.
ErrNotExist
case
resp
.
StatusCode
>=
http
.
StatusBadRequest
:
...
...
@@ -1177,7 +1182,7 @@ func makeRequestWithRetry(ctx context.Context, method string, requestURL *url.UR
}
}
return
nil
,
errMaxRetriesExceeded
return
nil
,
lastErr
}
func
makeRequest
(
ctx
context
.
Context
,
method
string
,
requestURL
*
url
.
URL
,
headers
http
.
Header
,
body
io
.
Reader
,
regOpts
*
RegistryOptions
)
(
*
http
.
Response
,
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment