Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0532c462
Commit
0532c462
authored
Feb 10, 2015
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a more detailed error message for potential auth fails in docker pull.
parent
e27d534b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletion
+45
-1
keyring.go
pkg/credentialprovider/keyring.go
+9
-0
docker.go
pkg/kubelet/dockertools/docker.go
+15
-1
docker_test.go
pkg/kubelet/dockertools/docker_test.go
+21
-0
No files found.
pkg/credentialprovider/keyring.go
View file @
0532c462
...
@@ -143,3 +143,12 @@ func (dk *lazyDockerKeyring) Lookup(image string) (docker.AuthConfiguration, boo
...
@@ -143,3 +143,12 @@ func (dk *lazyDockerKeyring) Lookup(image string) (docker.AuthConfiguration, boo
return
keyring
.
Lookup
(
image
)
return
keyring
.
Lookup
(
image
)
}
}
type
FakeKeyring
struct
{
auth
docker
.
AuthConfiguration
ok
bool
}
func
(
f
*
FakeKeyring
)
Lookup
(
image
string
)
(
docker
.
AuthConfiguration
,
bool
)
{
return
f
.
auth
,
f
.
ok
}
pkg/kubelet/dockertools/docker.go
View file @
0532c462
...
@@ -222,7 +222,21 @@ func (p dockerPuller) Pull(image string) error {
...
@@ -222,7 +222,21 @@ func (p dockerPuller) Pull(image string) error {
glog
.
V
(
1
)
.
Infof
(
"Pulling image %s without credentials"
,
image
)
glog
.
V
(
1
)
.
Infof
(
"Pulling image %s without credentials"
,
image
)
}
}
return
p
.
client
.
PullImage
(
opts
,
creds
)
err
:=
p
.
client
.
PullImage
(
opts
,
creds
)
// If there was no error, or we had credentials, just return the error.
if
err
==
nil
||
ok
{
return
err
}
// Image spec: [<registry>/]<repository>/<image>[:<version] so we count '/'
explicitRegistry
:=
(
strings
.
Count
(
image
,
"/"
)
==
2
)
glog
.
Errorf
(
"Foo: %s"
,
explicitRegistry
)
// Hack, look for a private registry, and decorate the error with the lack of
// credentials. This is heuristic, and really probably could be done better
// by talking to the registry API directly from the kubelet here.
if
explicitRegistry
{
return
fmt
.
Errorf
(
"image pull failed for %s, this may be because there are no credentials on this request. details: (%v)"
,
image
,
err
)
}
return
err
}
}
func
(
p
throttledDockerPuller
)
Pull
(
image
string
)
error
{
func
(
p
throttledDockerPuller
)
Pull
(
image
string
)
error
{
...
...
pkg/kubelet/dockertools/docker_test.go
View file @
0532c462
...
@@ -196,6 +196,27 @@ func TestParseImageName(t *testing.T) {
...
@@ -196,6 +196,27 @@ func TestParseImageName(t *testing.T) {
}
}
}
}
func
TestDockerKeyringLookupFails
(
t
*
testing
.
T
)
{
fakeKeyring
:=
&
credentialprovider
.
FakeKeyring
{}
fakeClient
:=
&
FakeDockerClient
{
Err
:
fmt
.
Errorf
(
"test error"
),
}
dp
:=
dockerPuller
{
client
:
fakeClient
,
keyring
:
fakeKeyring
,
}
err
:=
dp
.
Pull
(
"host/repository/image:version"
)
if
err
==
nil
{
t
.
Errorf
(
"unexpected non-error"
)
}
msg
:=
"image pull failed for host/repository/image, this may be because there are no credentials on this request. details: (test error)"
if
err
.
Error
()
!=
msg
{
t
.
Errorf
(
"expected: %s, saw: %s"
,
msg
,
err
.
Error
())
}
}
func
TestDockerKeyringLookup
(
t
*
testing
.
T
)
{
func
TestDockerKeyringLookup
(
t
*
testing
.
T
)
{
empty
:=
docker
.
AuthConfiguration
{}
empty
:=
docker
.
AuthConfiguration
{}
...
...
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