Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-runner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Seipel
gitlab-runner
Commits
b7181fe3
Unverified
Commit
b7181fe3
authored
7 years ago
by
Tomasz Maczukin
Browse files
Options
Downloads
Patches
Plain Diff
Add handling of non-existing images for Docker >= 17.07
parent
9d9d3402
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
executors/docker/executor_docker.go
+2
-1
2 additions, 1 deletion
executors/docker/executor_docker.go
executors/docker/executor_docker_command_test.go
+25
-1
25 additions, 1 deletion
executors/docker/executor_docker_command_test.go
with
27 additions
and
2 deletions
executors/docker/executor_docker.go
+
2
−
1
View file @
b7181fe3
...
@@ -141,8 +141,9 @@ func (s *executor) pullDockerImage(imageName string, ac *types.AuthConfig) (*typ
...
@@ -141,8 +141,9 @@ func (s *executor) pullDockerImage(imageName string, ac *types.AuthConfig) (*typ
options
.
RegistryAuth
,
_
=
docker_helpers
.
EncodeAuthConfig
(
ac
)
options
.
RegistryAuth
,
_
=
docker_helpers
.
EncodeAuthConfig
(
ac
)
}
}
errorRegexp
:=
regexp
.
MustCompile
(
"(repository does not exist|not found)"
)
if
err
:=
s
.
client
.
ImagePullBlocking
(
s
.
Context
,
ref
,
options
);
err
!=
nil
{
if
err
:=
s
.
client
.
ImagePullBlocking
(
s
.
Context
,
ref
,
options
);
err
!=
nil
{
if
strings
.
Conta
in
s
(
err
.
Error
()
,
"not found"
)
{
if
errorRegexp
.
MatchStr
in
g
(
err
.
Error
())
{
return
nil
,
&
common
.
BuildError
{
Inner
:
err
}
return
nil
,
&
common
.
BuildError
{
Inner
:
err
}
}
}
return
nil
,
err
return
nil
,
err
...
...
This diff is collapsed.
Click to expand it.
executors/docker/executor_docker_command_test.go
+
25
−
1
View file @
b7181fe3
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"testing"
"testing"
"time"
"time"
"github.com/hashicorp/go-version"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
...
@@ -104,6 +105,23 @@ func TestDockerCommandWithAllowedImagesRun(t *testing.T) {
...
@@ -104,6 +105,23 @@ func TestDockerCommandWithAllowedImagesRun(t *testing.T) {
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
}
}
func
isDockerOlderThan17_07
(
t
*
testing
.
T
)
bool
{
cmd
:=
exec
.
Command
(
"docker"
,
"version"
)
output
,
err
:=
cmd
.
Output
()
require
.
NoError
(
t
,
err
,
"docker version should return output"
)
r
:=
regexp
.
MustCompile
(
`(?ms)Server:\s*\n\s+Version:\s+([^\n]+)$`
)
v
:=
r
.
FindStringSubmatch
(
string
(
output
))[
1
]
localVersion
,
err
:=
version
.
NewVersion
(
v
)
require
.
NoError
(
t
,
err
)
checkedVersion
,
err
:=
version
.
NewVersion
(
"17.07.0-ce"
)
require
.
NoError
(
t
,
err
)
return
localVersion
.
LessThan
(
checkedVersion
)
}
func
TestDockerCommandMissingImage
(
t
*
testing
.
T
)
{
func
TestDockerCommandMissingImage
(
t
*
testing
.
T
)
{
if
helpers
.
SkipIntegrationTests
(
t
,
"docker"
,
"info"
)
{
if
helpers
.
SkipIntegrationTests
(
t
,
"docker"
,
"info"
)
{
return
return
...
@@ -123,7 +141,13 @@ func TestDockerCommandMissingImage(t *testing.T) {
...
@@ -123,7 +141,13 @@ func TestDockerCommandMissingImage(t *testing.T) {
err
:=
build
.
Run
(
&
common
.
Config
{},
&
common
.
Trace
{
Writer
:
os
.
Stdout
})
err
:=
build
.
Run
(
&
common
.
Config
{},
&
common
.
Trace
{
Writer
:
os
.
Stdout
})
require
.
Error
(
t
,
err
)
require
.
Error
(
t
,
err
)
assert
.
IsType
(
t
,
&
common
.
BuildError
{},
err
)
assert
.
IsType
(
t
,
&
common
.
BuildError
{},
err
)
assert
.
Contains
(
t
,
err
.
Error
(),
"not found"
)
contains
:=
"repository does not exist"
if
isDockerOlderThan17_07
(
t
)
{
contains
=
"not found"
}
assert
.
Contains
(
t
,
err
.
Error
(),
contains
)
}
}
func
TestDockerCommandMissingTag
(
t
*
testing
.
T
)
{
func
TestDockerCommandMissingTag
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment