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
0bd0454e
Unverified
Commit
0bd0454e
authored
Mar 29, 2025
by
CYJiang
Committed by
GitHub
Mar 28, 2025
Browse files
server: organize error types (#9465)
Co-authored-by:
Bruce MacDonald
<
brucewmacdonald@gmail.com
>
parent
01aa7887
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
9 deletions
+10
-9
server/download.go
server/download.go
+4
-3
server/images.go
server/images.go
+3
-2
server/modelpath.go
server/modelpath.go
+2
-3
server/routes.go
server/routes.go
+1
-1
No files found.
server/download.go
View file @
0bd0454e
...
...
@@ -29,8 +29,9 @@ import (
const
maxRetries
=
6
var
(
errMaxRetriesExceeded
=
errors
.
New
(
"max retries exceeded"
)
errPartStalled
=
errors
.
New
(
"part stalled"
)
errMaxRetriesExceeded
=
errors
.
New
(
"max retries exceeded"
)
errPartStalled
=
errors
.
New
(
"part stalled"
)
errMaxRedirectsExceeded
=
errors
.
New
(
"maximum redirects exceeded (10) for directURL"
)
)
var
blobDownloadManager
sync
.
Map
...
...
@@ -236,7 +237,7 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *regis
newOpts
.
CheckRedirect
=
func
(
req
*
http
.
Request
,
via
[]
*
http
.
Request
)
error
{
if
len
(
via
)
>
10
{
return
err
ors
.
New
(
"maximum r
edirects
e
xceeded
(10) for directURL"
)
return
err
MaxR
edirects
E
xceeded
}
// if the hostname is the same, allow the redirect
...
...
server/images.go
View file @
0bd0454e
...
...
@@ -35,6 +35,7 @@ var (
errCapabilityCompletion
=
errors
.
New
(
"completion"
)
errCapabilityTools
=
errors
.
New
(
"tools"
)
errCapabilityInsert
=
errors
.
New
(
"insert"
)
errInsecureProtocol
=
errors
.
New
(
"insecure protocol http"
)
)
type
Capability
string
...
...
@@ -479,7 +480,7 @@ func PushModel(ctx context.Context, name string, regOpts *registryOptions, fn fu
fn
(
api
.
ProgressResponse
{
Status
:
"retrieving manifest"
})
if
mp
.
ProtocolScheme
==
"http"
&&
!
regOpts
.
Insecure
{
return
err
ors
.
New
(
"i
nsecure
p
rotocol
http"
)
return
err
I
nsecure
P
rotocol
}
manifest
,
_
,
err
:=
GetManifest
(
mp
)
...
...
@@ -543,7 +544,7 @@ func PullModel(ctx context.Context, name string, regOpts *registryOptions, fn fu
}
if
mp
.
ProtocolScheme
==
"http"
&&
!
regOpts
.
Insecure
{
return
err
ors
.
New
(
"i
nsecure
p
rotocol
http"
)
return
err
I
nsecure
P
rotocol
}
fn
(
api
.
ProgressResponse
{
Status
:
"pulling manifest"
})
...
...
server/modelpath.go
View file @
0bd0454e
...
...
@@ -31,9 +31,10 @@ const (
var
(
ErrInvalidImageFormat
=
errors
.
New
(
"invalid image format"
)
ErrInvalidDigestFormat
=
errors
.
New
(
"invalid digest format"
)
ErrInvalidProtocol
=
errors
.
New
(
"invalid protocol scheme"
)
ErrInsecureProtocol
=
errors
.
New
(
"insecure protocol http"
)
Err
InvalidDigestFormat
=
errors
.
New
(
"invalid
digest form
at"
)
Err
ModelPathInvalid
=
errors
.
New
(
"invalid
model p
at
h
"
)
)
func
ParseModelPath
(
name
string
)
ModelPath
{
...
...
@@ -73,8 +74,6 @@ func ParseModelPath(name string) ModelPath {
return
mp
}
var
errModelPathInvalid
=
errors
.
New
(
"invalid model path"
)
func
(
mp
ModelPath
)
GetNamespaceRepository
()
string
{
return
fmt
.
Sprintf
(
"%s/%s"
,
mp
.
Namespace
,
mp
.
Repository
)
}
...
...
server/routes.go
View file @
0bd0454e
...
...
@@ -777,7 +777,7 @@ func (s *Server) ShowHandler(c *gin.Context) {
func
GetModelInfo
(
req
api
.
ShowRequest
)
(
*
api
.
ShowResponse
,
error
)
{
name
:=
model
.
ParseName
(
req
.
Model
)
if
!
name
.
IsValid
()
{
return
nil
,
e
rrModelPathInvalid
return
nil
,
E
rrModelPathInvalid
}
name
,
err
:=
getExistingName
(
name
)
if
err
!=
nil
{
...
...
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