Skip to content
Snippets Groups Projects
Commit 4d330b51 authored by Pedro Pombeiro's avatar Pedro Pombeiro
Browse files

Merge branch 'docker-pull-image-error-management' into 'main'

Consider all docker pull image system error as runner script failure

Closes #28075

See merge request !3142
parents 26d3b32b 5dabe2a8
No related branches found
No related tags found
Loading
Pipeline #380881467 passed with warnings
Pipeline: gitlab-runner-ubi-images

#380958526

    ......@@ -545,7 +545,7 @@ func TestDockerCommandPullingImageRequestTimeout(t *testing.T) {
    err := build.Run(&common.Config{}, &common.Trace{Writer: os.Stdout})
    require.ErrorAs(t, err, &buildError)
    assert.True(t, docker.IsSystemError(err), "expected docker system error is missing in error chain")
    assert.Equal(t, common.ScriptFailure, buildError.FailureReason, "expected script failure error")
    assert.Contains(t, err.Error(), "request canceled while waiting for connection")
    }
    ......
    ......@@ -3,7 +3,6 @@ package pull
    import (
    "context"
    "fmt"
    "regexp"
    "strings"
    "sync"
    ......@@ -15,16 +14,6 @@ import (
    "gitlab.com/gitlab-org/gitlab-runner/helpers/docker/auth"
    )
    var (
    // These are some docker system error messages returned when
    // not able to pull the given image. As we don't want those errors to be triggered as runner_system_failure
    // (as for all the other docker system error), we specifically catch them and flag them as script_failure
    // "repository does not exist|not found" where kept for compatibility with previous version of docker
    errorRegexp = regexp.MustCompile(
    "request canceled while waiting for connection|no such host|repository does not exist|not found",
    )
    )
    type Manager interface {
    GetDockerImage(imageName string) (*types.ImageInspect, error)
    }
    ......@@ -212,9 +201,6 @@ func (m *manager) pullDockerImage(imageName string, ac *cli.AuthConfig) (*types.
    options.RegistryAuth, _ = auth.EncodeConfig(ac)
    if err := m.client.ImagePullBlocking(m.context, ref, options); err != nil {
    if docker.IsSystemError(err) && !errorRegexp.MatchString(err.Error()) {
    return nil, &common.BuildError{Inner: err, FailureReason: common.RunnerSystemFailure}
    }
    return nil, &common.BuildError{Inner: err, FailureReason: common.ScriptFailure}
    }
    ......
    ......@@ -85,7 +85,7 @@ func TestDockerForImagePullFailures(t *testing.T) {
    assert.Nil(t, image)
    assert.Error(t, err)
    require.ErrorAs(t, err, &buildError)
    assert.Equal(t, buildError.FailureReason, common.RunnerSystemFailure)
    assert.Equal(t, buildError.FailureReason, common.ScriptFailure)
    },
    },
    "ImagePullBlocking wrapped system failure": {
    ......@@ -101,7 +101,7 @@ func TestDockerForImagePullFailures(t *testing.T) {
    assert.Nil(t, image)
    assert.Error(t, err)
    require.ErrorAs(t, err, &buildError)
    assert.Equal(t, buildError.FailureReason, common.RunnerSystemFailure)
    assert.Equal(t, buildError.FailureReason, common.ScriptFailure)
    },
    },
    "ImagePullBlocking two level wrapped system failure": {
    ......@@ -117,7 +117,7 @@ func TestDockerForImagePullFailures(t *testing.T) {
    assert.Nil(t, image)
    assert.Error(t, err)
    require.ErrorAs(t, err, &buildError)
    assert.Equal(t, buildError.FailureReason, common.RunnerSystemFailure)
    assert.Equal(t, buildError.FailureReason, common.ScriptFailure)
    },
    },
    "ImagePullBlocking wrapped request timeout failure": {
    ......
    ......@@ -16,7 +16,6 @@ import (
    "github.com/docker/docker/api/types/network"
    "github.com/docker/docker/api/types/volume"
    "github.com/docker/docker/client"
    "github.com/docker/docker/errdefs"
    "github.com/docker/docker/pkg/jsonmessage"
    "github.com/docker/go-connections/tlsconfig"
    "github.com/sirupsen/logrus"
    ......@@ -39,21 +38,6 @@ func IsErrNotFound(err error) bool {
    return client.IsErrNotFound(err)
    }
    // IsSystemError checks whether a returned error is due to an system error
    // Proxies the docker implementation.
    func IsSystemError(err error) bool {
    for {
    if errdefs.IsSystem(err) {
    return true
    }
    err = errors.Unwrap(err)
    if err == nil {
    return false
    }
    }
    }
    // type officialDockerClient wraps a "github.com/docker/docker/client".Client,
    // giving it the methods it needs to satisfy the docker.Client interface
    type officialDockerClient struct {
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment