testing: use Docker Hub registry mirror for CI (#25703)

As of April 1, Docker Hub rate limits tightened. With only 10 pulls/hr/IP, we're
likely to encounter test failures. Switch all Docker images getting pulled from
this repository to use the HashiCorp managed registry mirror.

Note that most of our tests in `drivers/docker` don't pull from the remote
registry but load a local image, while others will need to pull from the remote
and fetch different images depending on OS/arch. Refactor the definition of test
task configuration to make it clear which is which, and de-factor some false
sharing of setup functions.

Updates the E2E tests to use that registry by configuring the Docker
daemon. This required changing out a few container images that we don't have in
the registry, but these new images are all smaller. There are a couple of tests
that still use explicitly-tagged `docker.io` images or other third-party
registries, which have been left in place.

Ref: https://hashicorp.atlassian.net/browse/NET-12233

update E2E images to those in the registry mirror

fix windows and docklog test build

fix stopsignal test

mop-up

more mop-up
This commit is contained in:
Tim Gross
2025-04-18 14:21:49 -04:00
committed by GitHub
parent c205688857
commit 88dc842729
15 changed files with 134 additions and 134 deletions

View File

@@ -368,7 +368,8 @@ func TestDockerCoordinator_PullImage_ProgressError(t *testing.T) {
readErr := errors.New("a bad bad thing happened")
mock.pullReader = &readErrorer{readErr: readErr}
_, _, err := coordinator.PullImage("foo", nil, uuid.Generate(), nil, timeout, timeout)
_, _, err := coordinator.PullImage(
"docker.invalid/"+uuid.Generate(), nil, uuid.Generate(), nil, timeout, timeout)
must.ErrorIs(t, err, readErr)
}

View File

@@ -10,7 +10,7 @@ import (
"fmt"
"io"
"os"
"strings"
"runtime"
"testing"
"time"
@@ -26,13 +26,16 @@ import (
"github.com/hashicorp/nomad/testutil"
)
func testContainerDetails() (image string, imageName string, imageTag string) {
image = testutil.TestBusyboxImage()
parts := strings.Split(image, ":")
imageName = parts[0]
imageTag = parts[1]
func testRemoteContainerImage() string {
if runtime.GOOS == "windows" {
return "hashicorpdev/busybox-windows:server2016-0.1"
}
return image, imageName, imageTag
if testutil.IsCI() {
// use our mirror to avoid rate-limiting in CI
return "docker.mirror.hashicorp.services/busybox:1"
}
return "docker.io/busybox:1"
}
func TestDockerLogger_Success(t *testing.T) {
@@ -40,7 +43,7 @@ func TestDockerLogger_Success(t *testing.T) {
ctu.DockerCompatible(t)
ctx := context.Background()
containerImage, containerImageName, containerImageTag := testContainerDetails()
containerImage := testRemoteContainerImage()
client, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
@@ -49,7 +52,7 @@ func TestDockerLogger_Success(t *testing.T) {
if img, _, err := client.ImageInspectWithRaw(ctx, containerImage); err != nil || img.ID == "" {
t.Log("image not found locally, downloading...")
out, err := client.ImagePull(ctx, fmt.Sprintf("%s:%s", containerImageName, containerImageTag), image.PullOptions{})
out, err := client.ImagePull(ctx, containerImage, image.PullOptions{})
must.NoError(t, err, must.Sprint("failed to pull image"))
defer out.Close()
io.Copy(os.Stdout, out)
@@ -112,7 +115,7 @@ func TestDockerLogger_Success_TTY(t *testing.T) {
ctu.DockerCompatible(t)
ctx := context.Background()
containerImage, containerImageName, containerImageTag := testContainerDetails()
containerImage := testRemoteContainerImage()
client, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
@@ -121,7 +124,7 @@ func TestDockerLogger_Success_TTY(t *testing.T) {
if img, _, err := client.ImageInspectWithRaw(ctx, containerImage); err != nil || img.ID == "" {
t.Log("image not found locally, downloading...")
_, err = client.ImagePull(ctx, fmt.Sprintf("%s:%s", containerImageName, containerImageTag), image.PullOptions{})
_, err = client.ImagePull(ctx, containerImage, image.PullOptions{})
must.NoError(t, err, must.Sprint("failed to pull image"))
}
@@ -197,7 +200,7 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) {
ctu.DockerCompatible(t)
ctx := context.Background()
containerImage, containerImageName, containerImageTag := testContainerDetails()
containerImage := testRemoteContainerImage()
client, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
@@ -206,7 +209,7 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) {
if img, _, err := client.ImageInspectWithRaw(ctx, containerImage); err != nil || img.ID == "" {
t.Log("image not found locally, downloading...")
_, err = client.ImagePull(ctx, fmt.Sprintf("%s:%s", containerImageName, containerImageTag), image.PullOptions{})
_, err = client.ImagePull(ctx, containerImage, image.PullOptions{})
require.NoError(t, err, "failed to pull image")
}

View File

@@ -97,7 +97,7 @@ func dockerTask(t *testing.T) (*drivers.TaskConfig, *TaskConfig, []int) {
dockerReserved := ports[0]
dockerDynamic := ports[1]
cfg := newTaskConfig("", busyboxLongRunningCmd)
cfg := newTaskConfig(busyboxLongRunningCmd)
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "redis-demo",
@@ -250,6 +250,20 @@ func newTestDockerClient(t *testing.T) *client.Client {
return client
}
// testRemoteDockerImage is used only for tests where we need to pull the Docker
// image from a remote. Most tests should use newTaskConfig instead.
func testRemoteDockerImage(name, tag string) string {
img := name + ":" + tag
if tu.IsCI() {
// use our mirror to avoid rate-limiting in CI
img = "docker.mirror.hashicorp.services/" + img
} else {
// explicitly include docker.io for podman
img = "docker.io/" + img
}
return img
}
// Following tests have been removed from this file.
// [TestDockerDriver_Fingerprint, TestDockerDriver_Fingerprint_Bridge, TestDockerDriver_Check_DockerHealthStatus]
// If you want to checkout/revert those tests, please check commit: 41715b1860778aa80513391bd64abd721d768ab0
@@ -258,7 +272,7 @@ func TestDockerDriver_Start_Wait(t *testing.T) {
ci.Parallel(t)
testutil.DockerCompatible(t)
taskCfg := newTaskConfig("", busyboxLongRunningCmd)
taskCfg := newTaskConfig(busyboxLongRunningCmd)
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "nc-demo",
@@ -292,7 +306,7 @@ func TestDockerDriver_Start_WaitFinish(t *testing.T) {
ci.Parallel(t)
testutil.DockerCompatible(t)
taskCfg := newTaskConfig("", []string{"echo", "hello"})
taskCfg := newTaskConfig([]string{"echo", "hello"})
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "nc-demo",
@@ -333,7 +347,7 @@ func TestDockerDriver_Start_StoppedContainer(t *testing.T) {
ci.Parallel(t)
testutil.DockerCompatible(t)
taskCfg := newTaskConfig("", []string{"sleep", "9001"})
taskCfg := newTaskConfig([]string{"sleep", "9001"})
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "nc-demo",
@@ -448,7 +462,7 @@ func TestDockerDriver_Start_LoadImage(t *testing.T) {
ci.Parallel(t)
testutil.DockerCompatible(t)
taskCfg := newTaskConfig("", []string{"sh", "-c", "echo hello > $NOMAD_TASK_DIR/output"})
taskCfg := newTaskConfig([]string{"sh", "-c", "echo hello > $NOMAD_TASK_DIR/output"})
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "busybox-demo",
@@ -568,7 +582,7 @@ func TestDockerDriver_Start_Wait_AllocDir(t *testing.T) {
exp := []byte{'w', 'i', 'n'}
file := "output.txt"
taskCfg := newTaskConfig("", []string{
taskCfg := newTaskConfig([]string{
"sh",
"-c",
fmt.Sprintf(`sleep 1; echo -n %s > $%s/%s`,
@@ -621,7 +635,7 @@ func TestDockerDriver_Start_Kill_Wait(t *testing.T) {
ci.Parallel(t)
testutil.DockerCompatible(t)
taskCfg := newTaskConfig("", busyboxLongRunningCmd)
taskCfg := newTaskConfig(busyboxLongRunningCmd)
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "busybox-demo",
@@ -672,7 +686,7 @@ func TestDockerDriver_Start_KillTimeout(t *testing.T) {
}
timeout := 2 * time.Second
taskCfg := newTaskConfig("", []string{"sleep", "10"})
taskCfg := newTaskConfig([]string{"sleep", "10"})
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "busybox-demo",
@@ -770,23 +784,19 @@ func TestDockerDriver_StartNVersions(t *testing.T) {
task1, cfg1, _ := dockerTask(t)
tcfg1 := newTaskConfig("", []string{"echo", "hello"})
tcfg1 := newTaskConfig([]string{"echo", "hello"})
cfg1.Image = tcfg1.Image
cfg1.LoadImage = tcfg1.LoadImage
must.NoError(t, task1.EncodeConcreteDriverConfig(cfg1))
task2, cfg2, _ := dockerTask(t)
tcfg2 := newTaskConfig("musl", []string{"echo", "hello"})
cfg2.Image = tcfg2.Image
cfg2.LoadImage = tcfg2.LoadImage
cfg2.Image = "busybox:1.29.3"
cfg2.LoadImage = "busybox_musl.tar"
must.NoError(t, task2.EncodeConcreteDriverConfig(cfg2))
task3, cfg3, _ := dockerTask(t)
tcfg3 := newTaskConfig("glibc", []string{"echo", "hello"})
cfg3.Image = tcfg3.Image
cfg3.LoadImage = tcfg3.LoadImage
cfg3.Image = "busybox:1.29.3"
cfg3.LoadImage = "busybox_glibc.tar"
must.NoError(t, task3.EncodeConcreteDriverConfig(cfg3))
taskList := []*drivers.TaskConfig{task1, task2, task3}
@@ -2274,7 +2284,7 @@ func setupDockerVolumes(t *testing.T, cfg map[string]interface{}, hostpath strin
}
containerFile := filepath.Join(containerPath, randfn)
taskCfg := newTaskConfig("", []string{"touch", containerFile})
taskCfg := newTaskConfig([]string{"touch", containerFile})
taskCfg.Volumes = []string{fmt.Sprintf("%s:%s", hostpath, containerPath)}
task := &drivers.TaskConfig{
@@ -2585,7 +2595,7 @@ func TestDockerDriver_OOMKilled(t *testing.T) {
testutil.CgroupsCompatibleV2(t)
taskCfg := newTaskConfig("", []string{"sh", "-c", `sleep 2 && x=a && while true; do x="$x$x"; done`})
taskCfg := newTaskConfig([]string{"sh", "-c", `sleep 2 && x=a && while true; do x="$x$x"; done`})
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "oom-killed",
@@ -3098,19 +3108,23 @@ func TestDockerDriver_StopSignal(t *testing.T) {
cases := []struct {
name string
imageName string
imageLoad string
variant string
jobKillSignal string
expectedSignals []string
}{
{
name: "stopsignal-only",
variant: "stopsignal",
imageName: "busybox:1.29.3-stopsignal",
imageLoad: "busybox_stopsignal.tar",
jobKillSignal: "",
expectedSignals: []string{"19", "9"},
},
{
name: "stopsignal-killsignal",
variant: "stopsignal",
imageName: "busybox:1.29.3-stopsignal",
imageLoad: "busybox_stopsignal.tar",
jobKillSignal: "SIGTERM",
expectedSignals: []string{"15", "19", "9"},
},
@@ -3131,7 +3145,11 @@ func TestDockerDriver_StopSignal(t *testing.T) {
for i := range cases {
c := cases[i]
t.Run(c.name, func(t *testing.T) {
taskCfg := newTaskConfig(c.variant, []string{"sleep", "9901"})
taskCfg := newTaskConfig([]string{"sleep", "9901"})
if c.imageLoad != "" {
taskCfg.Image = c.imageName
taskCfg.LoadImage = c.imageLoad
}
task := &drivers.TaskConfig{
ID: uuid.Generate(),
@@ -3145,11 +3163,7 @@ func TestDockerDriver_StopSignal(t *testing.T) {
cleanup := d.MkAllocDir(task, true)
defer cleanup()
if c.variant == "stopsignal" {
copyImage(t, task.TaskDir(), "busybox_stopsignal.tar") // Default busybox image with STOPSIGNAL 19 added
} else {
copyImage(t, task.TaskDir(), taskCfg.LoadImage)
}
client := newTestDockerClient(t)
@@ -3222,7 +3236,7 @@ func TestDockerDriver_CollectStats(t *testing.T) {
// we want to generate at least some CPU usage
args := []string{"/bin/sh", "-c", "cat /dev/urandom | base64 > /dev/null"}
taskCfg := newTaskConfig("", args)
taskCfg := newTaskConfig(args)
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "nc-demo",

View File

@@ -28,7 +28,6 @@ import (
"github.com/hashicorp/nomad/plugins/drivers"
dtestutil "github.com/hashicorp/nomad/plugins/drivers/testutils"
ntestutil "github.com/hashicorp/nomad/testutil"
tu "github.com/hashicorp/nomad/testutil"
"github.com/shoenig/test/must"
)
@@ -37,7 +36,6 @@ func TestDockerDriver_User(t *testing.T) {
testutil.DockerCompatible(t)
task, cfg, _ := dockerTask(t)
task.User = "alice"
cfg.Command = "/bin/sleep"
cfg.Args = []string{"10000"}
@@ -78,7 +76,7 @@ func TestDockerDriver_NetworkAliases_Bridge(t *testing.T) {
must.NoError(t, err)
expected := []string{"foobar"}
taskCfg := newTaskConfig("", busyboxLongRunningCmd)
taskCfg := newTaskConfig(busyboxLongRunningCmd)
taskCfg.NetworkMode = network.Name
taskCfg.NetworkAliases = expected
task := &drivers.TaskConfig{
@@ -114,7 +112,7 @@ func TestDockerDriver_NetworkMode_Host(t *testing.T) {
testutil.DockerCompatible(t)
expected := "host"
taskCfg := newTaskConfig("", busyboxLongRunningCmd)
taskCfg := newTaskConfig(busyboxLongRunningCmd)
taskCfg.NetworkMode = expected
task := &drivers.TaskConfig{
@@ -673,8 +671,8 @@ func TestDockerDriver_Cleanup(t *testing.T) {
testutil.DockerCompatible(t)
// using a small image and an specific point release to avoid accidental conflicts with other tasks
cfg := newTaskConfig("", []string{"sleep", "100"})
cfg.Image = ntestutil.TestDockerImage("busybox", "1.29.2")
cfg := newTaskConfig([]string{"sleep", "100"})
cfg.Image = testRemoteDockerImage("busybox", "1.29.2")
cfg.LoadImage = ""
task := &drivers.TaskConfig{
ID: uuid.Generate(),
@@ -697,7 +695,7 @@ func TestDockerDriver_Cleanup(t *testing.T) {
must.NoError(t, driver.DestroyTask(task.ID, true))
// Ensure image was removed
tu.WaitForResult(func() (bool, error) {
ntestutil.WaitForResult(func() (bool, error) {
if _, _, err := client.ImageInspectWithRaw(context.Background(), cfg.Image); err == nil {
return false, fmt.Errorf("image exists but should have been removed. Does another %v container exist?", cfg.Image)
}
@@ -742,7 +740,10 @@ func TestDockerDriver_Start_Image_HTTPS(t *testing.T) {
harness.DestroyTask(task.ID, true)
}
func newTaskConfig(variant string, command []string) TaskConfig {
// newTaskConfig returns a busybox task config that loads the image from
// test-resources. You'll need to call copyImage to copy this image into the
// TaskDir after the task has been defined.
func newTaskConfig(command []string) TaskConfig {
var busyboxImageID, loadImage string
@@ -755,15 +756,8 @@ func newTaskConfig(variant string, command []string) TaskConfig {
loadImage = "busybox_linux_amd64.tar"
}
image := busyboxImageID
if variant != "" {
image = fmt.Sprintf("%s-%s", busyboxImageID, variant)
loadImage = fmt.Sprintf("busybox_%s.tar", variant)
}
return TaskConfig{
Image: image,
Image: busyboxImageID,
ImagePullTimeout: "5m",
LoadImage: loadImage,
Command: command[0],
@@ -771,6 +765,14 @@ func newTaskConfig(variant string, command []string) TaskConfig {
}
}
// copyImage copies the Docker image in test-resources into the task directory
// for use with a task configuration with LoadImage (used by most of our tests).
//
// Note that if a test loads this image during task start, the local Docker
// daemon will now have it available for all other tests. Tests don't know if
// the image already existed before the test run, so we can't delete it from the
// local Docker daemon without causing side-effects on the host or making this
// all a lot more complicated.
func copyImage(t *testing.T, taskDir *allocdir.TaskDir, image string) {
dst := filepath.Join(taskDir.LocalDir, image)
copyFile(filepath.Join("./test-resources/docker", image), dst, t)
@@ -804,7 +806,7 @@ func TestDocker_ExecTaskStreaming(t *testing.T) {
ci.Parallel(t)
testutil.DockerCompatible(t)
taskCfg := newTaskConfig("", []string{"/bin/sleep", "1000"})
taskCfg := newTaskConfig([]string{"/bin/sleep", "1000"})
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "nc-demo",
@@ -862,7 +864,7 @@ func Test_dnsConfig(t *testing.T) {
t.Run(c.name, func(t *testing.T) {
harness := dockerDriverHarness(t, nil)
taskCfg := newTaskConfig("", []string{"/bin/sleep", "1000"})
taskCfg := newTaskConfig([]string{"/bin/sleep", "1000"})
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "nc-demo",

View File

@@ -6,20 +6,23 @@
package docker
import (
"os"
"testing"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/plugins/drivers"
"github.com/hashicorp/nomad/testutil"
"github.com/shoenig/test/must"
)
func newTaskConfig(variant string, command []string) TaskConfig {
// busyboxImageID is an id of an image containing nanoserver windows and
// a busybox exe.
busyboxImageID := testutil.TestBusyboxImage()
func newTaskConfig(command []string) TaskConfig {
busyboxImageID := testRemoteDockerImage("hashicorpdev/busybox-windows", "server2016-0.1")
// BUSYBOX_IMAGE environment variable overrides the busybox image name
if img, ok := os.LookupEnv("BUSYBOX_IMAGE"); ok {
busyboxImageID = img
}
return TaskConfig{
Image: busyboxImageID,
@@ -41,7 +44,7 @@ func Test_validateImageUser(t *testing.T) {
Name: "busybox-demo",
User: "nomadUser",
}
taskDriverCfg := newTaskConfig("", []string{"sh", "-c", "sleep 1"})
taskDriverCfg := newTaskConfig([]string{"sh", "-c", "sleep 1"})
tests := []struct {
name string

View File

@@ -195,7 +195,6 @@ func TestDanglingContainerRemoval_network(t *testing.T) {
c, iErr := dockerClient.ContainerInspect(context.Background(), id)
must.NoError(t, iErr)
must.Eq(t, "running", c.State.Status)
fmt.Println("state", c.State)
// cleanup pause container
err = dd.DestroyNetwork(allocID, spec)

View File

@@ -29,7 +29,7 @@ job "sleepytar" {
driver = "docker"
config {
image = "bash:latest"
image = "busybox:1"
command = "sleep"
args = ["infinity"]
network_mode = "none"
@@ -42,4 +42,3 @@ job "sleepytar" {
}
}
}

View File

@@ -242,7 +242,8 @@ job "linux" {
}
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
args = ["-c", "cat local/go.mod && sleep 10"]
}
resources {
@@ -259,7 +260,8 @@ job "linux" {
}
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
args = ["-c", "cat local/my/path/go.mod && sleep 10"]
}
resources {
@@ -277,7 +279,8 @@ job "linux" {
}
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
args = ["-c", "cat ${NOMAD_ALLOC_DIR}/go.mod && sleep 10"]
}
resources {
@@ -293,7 +296,8 @@ job "linux" {
}
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
args = ["-c", "cat local/go-set-main/go.mod && sleep 10"]
}
resources {
@@ -310,7 +314,8 @@ job "linux" {
}
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
args = ["-c", "cat local/my/zip/go-set-main/go.mod && sleep 10"]
}
resources {
@@ -327,7 +332,8 @@ job "linux" {
}
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
args = ["-c", "cat local/repository/go.mod && sleep 10"]
}
resources {

View File

@@ -22,7 +22,7 @@ job "plugin-aws-efs-nodes" {
driver = "docker"
config {
image = "amazon/aws-efs-csi-driver:v1.3.6"
image = "public.ecr.aws/efs-csi-driver/amazon/aws-efs-csi-driver:v1.3.6"
args = [
"node",
"--endpoint=${CSI_ENDPOINT}",

View File

@@ -39,11 +39,13 @@ job "configure-docker" {
unveil = ["r:${NOMAD_TASK_DIR}/daemon.json", "rwc:${var.docker_conf_dir}"]
}
# note we need to keep the existing registry-mirrors from the host configuration
template {
destination = "local/daemon.json"
perms = "644"
data = <<EOH
{
"registry-mirrors": ["https://docker.mirror.hashicorp.services"],
"insecure-registries": [
"${var.registry_address}"
]

View File

@@ -21,7 +21,7 @@ job "redis" {
driver = "docker"
config {
image = "docker.io/library/redis:7"
image = "redis:7"
ports = ["db"]
auth_soft_fail = true
}

View File

@@ -81,6 +81,13 @@ echo "Installing third-party tools"
# Docker
echo "Installing Docker CE"
sudo apt-get install -y docker-ce docker-ce-cli
sudo mkdir -p /etc/docker
cat <<EOF > /tmp/daemon.json
{
"registry-mirrors": ["https://docker.mirror.hashicorp.services"]
}
EOF
sudo mv /tmp/daemon.json /etc/docker/daemon.json
# Java
echo "Installing Java"

View File

@@ -16,7 +16,8 @@ job "identity" {
task "none" {
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
#HACK(schmichael) without the ending `sleep 2` we seem to sometimes miss logs :(
args = ["-c", "wc -c < secrets/nomad_token; env | grep NOMAD_TOKEN; echo done; sleep 2"]
@@ -35,7 +36,8 @@ job "identity" {
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
#HACK(schmichael) without the ending `sleep 2` we seem to sometimes miss logs :(
args = ["-c", "wc -c < secrets/nomad_token; env | grep NOMAD_TOKEN; echo done; sleep 2"]
@@ -57,7 +59,8 @@ job "identity" {
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
#HACK(schmichael) without the ending `sleep 2` we seem to sometimes miss logs :(
args = ["-c", "wc -c < secrets/nomad_token; env | grep NOMAD_TOKEN; echo done; sleep 2"]
@@ -78,7 +81,8 @@ job "identity" {
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
#HACK(schmichael) without the ending `sleep 2` we seem to sometimes miss logs :(
args = ["-c", "wc -c < secrets/nomad_token; env | grep NOMAD_TOKEN; echo done; sleep 2"]
@@ -99,7 +103,8 @@ job "identity" {
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
#HACK without the ending `sleep 2` we seem to sometimes miss logs :(
args = ["-c", "wc -c < local/nomad_token; env | grep NOMAD_TOKEN; echo done; sleep 2"]
@@ -121,7 +126,8 @@ job "identity" {
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
#HACK(schmichael) without the ending `sleep 2` we seem to sometimes miss logs :(
args = ["-c", "wc -c < secrets/nomad_token; env | grep NOMAD_TOKEN; echo done; sleep 2"]

View File

@@ -23,7 +23,8 @@ job "nobodyid" {
driver = "docker"
config {
image = "bash:5"
image = "busybox:1"
command = "/bin/sh"
args = ["-c", "stat -c 'perms=%#a username=%U' secrets/nomad_token; echo done; sleep 2"]
}
resources {

View File

@@ -1,43 +0,0 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package testutil
import (
"os"
"runtime"
)
const (
// BusyboxImageEnvName is always used, if set, by TestBusyboxImage()
BusyboxImageEnvName = "BUSYBOX_IMAGE"
)
func TestDockerImage(name, tag string) string {
img := name + ":" + tag
if IsCI() {
// use our mirror to avoid rate-limiting in CI
img = "docker.mirror.hashicorp.services/" + img
} else {
// explicitly include docker.io for podman
img = "docker.io/" + img
}
return img
}
func TestBusyboxImage() string {
// if env is set, use it verbatim
if img, ok := os.LookupEnv(BusyboxImageEnvName); ok {
return img
}
// otherwise, figure it out
name := "busybox"
tag := "1"
if runtime.GOOS == "windows" {
// this image is maintained in https://github.com/hashicorp/busybox-windows
name = "hashicorpdev/busybox-windows"
tag = "server2016-0.1"
}
return TestDockerImage(name, tag)
}