fix(system): ignore failure to connect to docker [EE-4825] (#8231)

pull/8237/head
Chaim Lev-Ari 2 years ago committed by GitHub
parent 649c1c9cee
commit e5fd0c9595
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,6 +6,7 @@ import (
"github.com/docker/docker/client"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
const (
@ -48,18 +49,25 @@ func DetermineContainerPlatform() (ContainerPlatform, error) {
return PlatformNomad, nil
}
if !isRunningInContainer() {
return "", nil
}
dockerCli, err := client.NewClientWithOpts()
if err != nil {
return "", errors.WithMessage(err, "failed to create docker client")
}
defer dockerCli.Close()
if !isRunningInContainer() {
return "", nil
}
info, err := dockerCli.Info(context.Background())
if err != nil {
if client.IsErrConnectionFailed(err) {
log.Warn().
Err(err).
Msg("failed to retrieve docker info")
return "", nil
}
return "", errors.WithMessage(err, "failed to retrieve docker info")
}

Loading…
Cancel
Save