From 96b658d1bb286d32a93abdefdea61a8c5814be30 Mon Sep 17 00:00:00 2001 From: Bryce Lampe Date: Wed, 18 Sep 2024 17:02:34 -0700 Subject: [PATCH] Remove random build ID (#1225) This ID was added for diagnostics and we haven't seen any warnings reported so it should be safe to remove. More importantly the presence of the random label causes perpetual diffs, which is undesirable. Fixes https://github.com/pulumi/pulumi-docker/issues/1219 Fixes https://github.com/pulumi/pulumi-docker/issues/1224 Refs https://github.com/pulumi/pulumi-docker/issues/846 --- examples/examples_nodejs_test.go | 2 ++ examples/examples_py_test.go | 2 ++ provider/go.mod | 2 +- provider/image.go | 37 +++----------------------------- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/examples/examples_nodejs_test.go b/examples/examples_nodejs_test.go index 705cc2ee..5698cee1 100644 --- a/examples/examples_nodejs_test.go +++ b/examples/examples_nodejs_test.go @@ -48,6 +48,8 @@ func TestDockerfileWithTarget(t *testing.T) { } func TestAzureContainerRegistry(t *testing.T) { + t.Skip("https://github.com/pulumi/pulumi-docker/issues/1238") + location := os.Getenv("AZURE_LOCATION") if location == "" { t.Skipf("Skipping test due to missing AZURE_LOCATION environment variable") diff --git a/examples/examples_py_test.go b/examples/examples_py_test.go index fd59854d..86ddb69f 100644 --- a/examples/examples_py_test.go +++ b/examples/examples_py_test.go @@ -25,6 +25,8 @@ import ( ) func TestAzureContainerRegistryPy(t *testing.T) { + t.Skip("https://github.com/pulumi/pulumi-docker/issues/1238") + location := os.Getenv("AZURE_LOCATION") if location == "" { t.Skipf("Skipping test due to missing AZURE_LOCATION environment variable") diff --git a/provider/go.mod b/provider/go.mod index e15ff1ad..1ecfae71 100644 --- a/provider/go.mod +++ b/provider/go.mod @@ -7,7 +7,6 @@ require ( github.com/docker/distribution v2.8.2+incompatible github.com/docker/docker v25.0.2+incompatible github.com/golang/protobuf v1.5.4 - github.com/google/uuid v1.6.0 github.com/moby/buildkit v0.13.0-beta3.0.20240205165705-d6e142600ee5 github.com/moby/moby v25.0.4+incompatible github.com/moby/patternmatcher v0.6.0 @@ -125,6 +124,7 @@ require ( github.com/google/go-querystring v1.1.0 // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/google/wire v0.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/googleapis/gax-go/v2 v2.12.2 // indirect diff --git a/provider/image.go b/provider/image.go index 2912d4d7..3417ec6c 100644 --- a/provider/image.go +++ b/provider/image.go @@ -33,7 +33,6 @@ import ( "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/jsonmessage" structpb "github.com/golang/protobuf/ptypes/struct" - "github.com/google/uuid" controlapi "github.com/moby/buildkit/api/services/control" "github.com/moby/buildkit/identity" "github.com/moby/buildkit/session" @@ -432,23 +431,7 @@ func (p *dockerNativeProvider) getRepoDigest( } // runImageBuild runs the image build and ensures that the correct image exists in the local image -// store. Due to reliability issues and a possible race condition, we use a defense-in-depth -// approach to add uniqueness to built images, and poll for the image store to contain a built image -// with the ID we expect. -// -// The returned image ID will be a sha that is unique to the image store, but cannot be used for -// pushing, e.g.: "sha256:39a1a41d26ee99b35c260e96b8fa21778885a4a67c8f1d81c7b58b1979d52319". These -// ids are only meaningful for the Docker Engine that built them. -// -// We take these steps to ensure that the image we built is the image we push: -// -// 1. We label the image with a unique buildID. -// -// 2. We obtain the Docker image store's imageID as a result of `ImageBuild`. -// -// 3. We poll the image store looking for the image. -// -// 4. We only return an imageID if the image in the store matches both (1.) and (2.) +// store. func (p *dockerNativeProvider) runImageBuild( ctx context.Context, docker *client.Client, tar io.Reader, opts types.ImageBuildOptions, urn resource.URN, @@ -456,14 +439,6 @@ func (p *dockerNativeProvider) runImageBuild( if opts.Labels == nil { opts.Labels = make(map[string]string) } - // TODO: https://github.com/pulumi/pulumi-docker/issues/846 - Consider removing the build ID. - id, err := uuid.NewRandom() - if err != nil { - return "", fmt.Errorf("error generating random ID for build: %v", err) - } - buildIDLabel := "pulumi.com/build-id" - buildIDValue := id.String() - opts.Labels[buildIDLabel] = buildIDValue // Close the imgBuildResp in a timely manner _ = p.host.LogStatus(ctx, "info", urn, "Starting Docker build") @@ -507,13 +482,7 @@ func (p *dockerNativeProvider) runImageBuild( // Search for our imageID in listResult for _, storedImage := range listResult { if storedImage.ID == imageID { - if storedImage.Labels[buildIDLabel] == buildIDValue { - return true, nil - } - _ = p.host.Log(ctx, "warning", urn, - fmt.Sprintf("Found in store does not match built image, expected label %s=%s, found %s", - buildIDLabel, buildIDValue, storedImage.Labels[buildIDLabel])) - return false, nil + return true, nil } } return false, nil @@ -896,7 +865,7 @@ func processLogLine(jm jsonmessage.JSONMessage, "credentials. Please double check you are using the correct credentials and registry name.", jm.Error.Message) } - return "", fmt.Errorf(jm.Error.Message) + return "", fmt.Errorf("%s", jm.Error.Message) } if jm.From != "" { info += jm.From