Use hashicorp mirror for container pulls (#17778)

When running the test suite in CI (where requests are centralized from
relatively few IPs), we'd occasionally hit Dockerhub's rate limits.
Luckily Hashicorp runs a (limited) public mirror of the containers we
need, so we can switch to them here in the tests.

For consistency between developer and CI, we've opted to have the tests
always pull from the Hashicorp mirror, rather than updating the CI
runner to prefer the mirror.

We exclude nomad and influxdb as we don't presently mirror these repos.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
This commit is contained in:
Alexander Scheel 2022-11-02 13:33:17 -04:00 committed by GitHub
parent 550fbdc41c
commit 8e6e53cf63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 32 additions and 27 deletions

View file

@ -57,7 +57,7 @@ client 128.0.0.0/1 {
` `
containerfile := ` containerfile := `
FROM jumanjiman/radiusd:latest FROM docker.mirror.hashicorp.services/jumanjiman/radiusd:latest
COPY clients.conf /etc/raddb/clients.conf COPY clients.conf /etc/raddb/clients.conf
` `

View file

@ -18,7 +18,7 @@ var (
func buildZLintContainer(t *testing.T) { func buildZLintContainer(t *testing.T) {
containerfile := ` containerfile := `
FROM golang:latest FROM docker.mirror.hashicorp.services/library/golang:latest
RUN go install github.com/zmap/zlint/v3/cmd/zlint@latest RUN go install github.com/zmap/zlint/v3/cmd/zlint@latest
` `

View file

@ -36,7 +36,7 @@ func prepareRabbitMQTestContainer(t *testing.T) (func(), string) {
} }
runner, err := docker.NewServiceRunner(docker.RunOptions{ runner, err := docker.NewServiceRunner(docker.RunOptions{
ImageRepo: "rabbitmq", ImageRepo: "docker.mirror.hashicorp.services/library/rabbitmq",
ImageTag: "3-management", ImageTag: "3-management",
ContainerName: "rabbitmq", ContainerName: "rabbitmq",
Ports: []string{"15672/tcp"}, Ports: []string{"15672/tcp"},

View file

@ -137,7 +137,7 @@ func prepareTestContainer(t *testing.T, tag, caPublicKeyPEM string) (func(), str
} }
runner, err := docker.NewServiceRunner(docker.RunOptions{ runner, err := docker.NewServiceRunner(docker.RunOptions{
ContainerName: "openssh", ContainerName: "openssh",
ImageRepo: "linuxserver/openssh-server", ImageRepo: "docker.mirror.hashicorp.services/linuxserver/openssh-server",
ImageTag: tag, ImageTag: tag,
Env: []string{ Env: []string{
"DOCKER_MODS=linuxserver/mods:openssh-server-openssh-client", "DOCKER_MODS=linuxserver/mods:openssh-server-openssh-client",

View file

@ -131,7 +131,8 @@ func prepareTestContainer(t *testing.T) (func(), *DockerVaultConfig) {
} }
runner, err := docker.NewServiceRunner(docker.RunOptions{ runner, err := docker.NewServiceRunner(docker.RunOptions{
ImageRepo: "vault", ContainerName: "vault",
ImageRepo: "docker.mirror.hashicorp.services/hashicorp/vault",
ImageTag: "latest", ImageTag: "latest",
Cmd: []string{ Cmd: []string{
"server", "-log-level=trace", "-dev", fmt.Sprintf("-dev-root-token-id=%s", rootToken), "server", "-log-level=trace", "-dev", fmt.Sprintf("-dev-root-token-id=%s", rootToken),

View file

@ -90,7 +90,8 @@ func PrepareTestContainer(t *testing.T, opts ...ContainerOpt) (Host, func()) {
} }
containerCfg := &containerConfig{ containerCfg := &containerConfig{
imageName: "cassandra", imageName: "docker.mirror.hashicorp.services/library/cassandra",
containerName: "cassandra",
version: "3.11", version: "3.11",
env: []string{"CASSANDRA_BROADCAST_ADDRESS=127.0.0.1"}, env: []string{"CASSANDRA_BROADCAST_ADDRESS=127.0.0.1"},
} }

View file

@ -58,7 +58,7 @@ func PrepareTestContainer(t *testing.T, version string, isEnterprise bool, doBoo
if isEnterprise { if isEnterprise {
version += "-ent" version += "-ent"
name = "consul-enterprise" name = "consul-enterprise"
repo = "hashicorp/consul-enterprise" repo = "docker.mirror.hashicorp.services/hashicorp/consul-enterprise"
license, hasLicense := os.LookupEnv("CONSUL_LICENSE") license, hasLicense := os.LookupEnv("CONSUL_LICENSE")
envVars = append(envVars, "CONSUL_LICENSE="+license) envVars = append(envVars, "CONSUL_LICENSE="+license)

View file

@ -27,7 +27,7 @@ func PrepareTestContainer(t *testing.T, version string) (func(), docker.ServiceC
} }
runner, err := docker.NewServiceRunner(docker.RunOptions{ runner, err := docker.NewServiceRunner(docker.RunOptions{
ContainerName: "fake-gcs-server", ContainerName: "fake-gcs-server",
ImageRepo: "fsouza/fake-gcs-server", ImageRepo: "docker.mirror.hashicorp.services/fsouza/fake-gcs-server",
ImageTag: version, ImageTag: version,
Cmd: []string{"-scheme", "http", "-public-host", "storage.gcs.127.0.0.1.nip.io:4443"}, Cmd: []string{"-scheme", "http", "-public-host", "storage.gcs.127.0.0.1.nip.io:4443"},
Ports: []string{"4443/tcp"}, Ports: []string{"4443/tcp"},

View file

@ -14,7 +14,7 @@ func PrepareTestContainer(t *testing.T, version string) (cleanup func(), cfg *ld
runner, err := docker.NewServiceRunner(docker.RunOptions{ runner, err := docker.NewServiceRunner(docker.RunOptions{
// Currently set to "michelvocks" until https://github.com/rroemhild/docker-test-openldap/pull/14 // Currently set to "michelvocks" until https://github.com/rroemhild/docker-test-openldap/pull/14
// has been merged. // has been merged.
ImageRepo: "michelvocks/docker-test-openldap", ImageRepo: "docker.mirror.hashicorp.services/michelvocks/docker-test-openldap",
ImageTag: version, ImageTag: version,
ContainerName: "ldap", ContainerName: "ldap",
Ports: []string{"389/tcp"}, Ports: []string{"389/tcp"},

View file

@ -32,7 +32,7 @@ func PrepareTestContainer(t *testing.T, version string) (func(), *Config) {
} }
runner, err := docker.NewServiceRunner(docker.RunOptions{ runner, err := docker.NewServiceRunner(docker.RunOptions{
ContainerName: "minio", ContainerName: "minio",
ImageRepo: "minio/minio", ImageRepo: "docker.mirror.hashicorp.services/minio/minio",
ImageTag: version, ImageTag: version,
Env: []string{ Env: []string{
"MINIO_ACCESS_KEY=" + accessKeyID, "MINIO_ACCESS_KEY=" + accessKeyID,

View file

@ -27,7 +27,8 @@ func PrepareTestContainerWithDatabase(t *testing.T, version, dbName string) (fun
} }
runner, err := docker.NewServiceRunner(docker.RunOptions{ runner, err := docker.NewServiceRunner(docker.RunOptions{
ImageRepo: "mongo", ContainerName: "mongo",
ImageRepo: "docker.mirror.hashicorp.services/library/mongo",
ImageTag: version, ImageTag: version,
Ports: []string{"27017/tcp"}, Ports: []string{"27017/tcp"},
}) })

View file

@ -29,7 +29,8 @@ func PrepareTestContainer(t *testing.T, legacy bool, pw string) (func(), string)
} }
runner, err := docker.NewServiceRunner(docker.RunOptions{ runner, err := docker.NewServiceRunner(docker.RunOptions{
ImageRepo: "mysql", ContainerName: "mysql",
ImageRepo: "docker.mirror.hashicorp.services/library/mysql",
ImageTag: imageVersion, ImageTag: imageVersion,
Ports: []string{"3306/tcp"}, Ports: []string{"3306/tcp"},
Env: []string{"MYSQL_ROOT_PASSWORD=" + pw}, Env: []string{"MYSQL_ROOT_PASSWORD=" + pw},

View file

@ -17,7 +17,7 @@ func PrepareTestContainer(t *testing.T, version string) (func(), string) {
"POSTGRES_DB=database", "POSTGRES_DB=database",
} }
_, cleanup, url, _ := prepareTestContainer(t, "postgres", "postgres", version, "secret", true, false, false, env) _, cleanup, url, _ := prepareTestContainer(t, "postgres", "docker.mirror.hashicorp.services/postgres", version, "secret", true, false, false, env)
return cleanup, url return cleanup, url
} }
@ -28,7 +28,7 @@ func PrepareTestContainerWithPassword(t *testing.T, version, password string) (f
"POSTGRES_DB=database", "POSTGRES_DB=database",
} }
_, cleanup, url, _ := prepareTestContainer(t, "postgres", "postgres", version, password, true, false, false, env) _, cleanup, url, _ := prepareTestContainer(t, "postgres", "docker.mirror.hashicorp.services/postgres", version, password, true, false, false, env)
return cleanup, url return cleanup, url
} }
@ -40,7 +40,7 @@ func PrepareTestContainerRepmgr(t *testing.T, name, version string, envVars []st
"REPMGR_PASSWORD=repmgrpass", "REPMGR_PASSWORD=repmgrpass",
"POSTGRESQL_PASSWORD=secret") "POSTGRESQL_PASSWORD=secret")
return prepareTestContainer(t, name, "bitnami/postgresql-repmgr", version, "secret", false, true, true, env) return prepareTestContainer(t, name, "docker.mirror.hashicorp.services/bitnami/postgresql-repmgr", version, "secret", false, true, true, env)
} }
func prepareTestContainer(t *testing.T, name, repo, version, password string, func prepareTestContainer(t *testing.T, name, repo, version, password string,

View file

@ -41,7 +41,7 @@ type aerospikeConfig struct {
func prepareAerospikeContainer(t *testing.T) (func(), *aerospikeConfig) { func prepareAerospikeContainer(t *testing.T) (func(), *aerospikeConfig) {
runner, err := docker.NewServiceRunner(docker.RunOptions{ runner, err := docker.NewServiceRunner(docker.RunOptions{
ImageRepo: "aerospike/aerospike-server", ImageRepo: "docker.mirror.hashicorp.services/aerospike/aerospike-server",
ContainerName: "aerospikedb", ContainerName: "aerospikedb",
ImageTag: "5.6.0.5", ImageTag: "5.6.0.5",
Ports: []string{"3000/tcp", "3001/tcp", "3002/tcp", "3003/tcp"}, Ports: []string{"3000/tcp", "3001/tcp", "3002/tcp", "3003/tcp"},

View file

@ -36,7 +36,7 @@ func prepareCockroachDBTestContainer(t *testing.T) (func(), *Config) {
} }
runner, err := docker.NewServiceRunner(docker.RunOptions{ runner, err := docker.NewServiceRunner(docker.RunOptions{
ImageRepo: "cockroachdb/cockroach", ImageRepo: "docker.mirror.hashicorp.services/cockroachdb/cockroach",
ImageTag: "release-1.0", ImageTag: "release-1.0",
ContainerName: "cockroachdb", ContainerName: "cockroachdb",
Cmd: []string{"start", "--insecure"}, Cmd: []string{"start", "--insecure"},

View file

@ -86,7 +86,8 @@ func prepareCouchdbDBTestContainer(t *testing.T) (func(), *couchDB) {
} }
runner, err := docker.NewServiceRunner(docker.RunOptions{ runner, err := docker.NewServiceRunner(docker.RunOptions{
ImageRepo: "couchdb", ContainerName: "couchdb",
ImageRepo: "docker.mirror.hashicorp.services/library/couchdb",
ImageTag: "1.6", ImageTag: "1.6",
Ports: []string{"5984/tcp"}, Ports: []string{"5984/tcp"},
DoNotAutoRemove: true, DoNotAutoRemove: true,

View file

@ -381,7 +381,7 @@ func prepareDynamoDBTestContainer(t *testing.T) (func(), *Config) {
} }
runner, err := docker.NewServiceRunner(docker.RunOptions{ runner, err := docker.NewServiceRunner(docker.RunOptions{
ImageRepo: "cnadiminti/dynamodb-local", ImageRepo: "docker.mirror.hashicorp.services/cnadiminti/dynamodb-local",
ImageTag: "latest", ImageTag: "latest",
ContainerName: "dynamodb", ContainerName: "dynamodb",
Ports: []string{"8000/tcp"}, Ports: []string{"8000/tcp"},