Skip to content

🐞 Engine 0.6.3 breaks docker publish for non OCI supporting registry #5433

Closed

Description

@nipuna-perera

What is the issue?

We are on Artifactory and since the dagger engine v0.6.3 upgrade we can't push images to Artifactory. We are on Artifactory v6.x. Artifactory v7+ is supposed to support OCI images but I don't have a way to test. We don't have an upgrade planned in the near future so we won't be able to use new features of Dagger if non OCI supporting registries don't work with new Dagger versions.

The specific PR that affected this - #5365

Log output

HTTP 400 from Artifactory

SDK version

Go SDK 0.7.2

OS version

macOS

Activity

  1. sipsma commented on Jul 12, 2023

    @sipsma
    Contributor

    Thanks for reporting and opening the issue @nipuna-perera!

    For a general note, I think the fix here may just have to be adding an option to our APIs to force certain media types. I think the current behavior of using oci mediatypes is good default but need to give users a fallback for these types of cases.

    Also, it would be cool if we could add compatibility tests similar to the ones I added here that test docker load against a range of dockerd versions

    for i, dockerVersion := range []string{"20.10", "23.0", "24.0"} {

    It would require the registry we're testing against can be run in a service container, but as long as that's doable those would be extremely helpful to catch regressions similar to this one going forward.

  2. nipuna-perera commented on Jul 21, 2023

    @nipuna-perera
    ContributorAuthor

    This doesn't seem to be fixed. I am still getting the same error after using the correct DockerMediaType. Upgraded to Go SDK 0.7.4 and engine 0.6.4 and added the additional option to the publish step.

  3. gerhard commented on Jul 25, 2023

    @gerhard
    Contributor

    Should we re-open this one @sipsma @marcosnils ?

  4. sipsma commented on Jul 25, 2023

    @sipsma
    Contributor

    Yes, I'm actually working on it right now

  5. reopened this on Jul 25, 2023
  6. sipsma commented on Jul 25, 2023

    @sipsma
    Contributor

    Running artifactory container registry at version 6.23.25 via docker run --name artifactory -v /var/opt/jfrog/artifactory -d -p 8081:8081 -p 8082:8082 releases-docker.jfrog.io/jfrog/artifactory-jcr:6.23.25 (thank you to @marcosnils for figuring out the rest of the configuration setup!).

    I can successfully publish to it in engine v0.6.0 through v0.6.2. Starting at v0.6.3 and above, I do indeed get this error:
    exporting to image ERROR: failed to push 127.0.0.1:8081/test/testimage:latest: failed commit on ref "manifest-sha256:83d558a4ce4181ea61bdaf9eceef236b0def48afb27a8bb03c475bedd9498308": unexpected status from PUT request to http://127.0.0.1:8081/v2/test/testimage/manifests/latest: 403 Forbidden

    Which interestingly is a somewhat different error than @nipuna-perera has been getting, which is a plain 400 error rather than 403 failed commit on ref {ref}: unexpected status from PUT request to {image}: 400.

    However, given the fact that it breaks on the exact same version, I'm inclined to think it's reasonably likely to be related if not the same thing, so will try out w/ specifying the mediatypes to docker in v0.6.4 and dig into what's different.

  7. sipsma commented on Jul 25, 2023

    @sipsma
    Contributor

    Okay so @nipuna-perera I just ran at v0.6.4 with this test code:

    func TestArtifactory(t *testing.T) {
    	c, ctx := connect(t)
    	defer c.Close()
    
    	testRef := "127.0.0.1:8081/test/testimage2:latest"
    	pass := c.SetSecret("password", "<the password>")
    	pushedRef, err := c.Container().
    		From("alpine:3.18").
    		WithExec([]string{"sh", "-c", "echo 'hello world!!!!' > /foo"}).
    		WithRegistryAuth("127.0.0.1:8081/test", "admin", pass).
    		Publish(ctx, testRef, dagger.ContainerPublishOpts{
    			MediaTypes: dagger.Dockermediatypes,
    		})
    	require.NoError(t, err)
    	require.NotEqual(t, testRef, pushedRef)
    	require.Contains(t, pushedRef, "@sha256:")
    
    	contents, err := c.Container().
    		From(pushedRef).Rootfs().File("/etc/alpine-release").Contents(ctx)
    	require.NoError(t, err)
    	require.Equal(t, contents, "3.18.2\n")
    	contents, err = c.Container().
    		From(pushedRef).Rootfs().File("/foo").Contents(ctx)
    	require.NoError(t, err)
    	require.Equal(t, contents, "hello world!!!!\n")
    }

    And was able to successfully publish to my local v6.23.25 artifactory container registry instance, but only when I set MediaTypes: dagger.Dockermediatypes, otherwise I'd get that 403 error mentioned above.

    I know you said that you were including that setting too, so I'm not sure what the delta is here.

    A few things to check and/or try:

    1. How are you running the dagger-engine container? Is it just in your local docker installation? Or do you have a more custom deployment?
    2. Are you using _EXPERIMENTAL_DAGGER_CLI_BIN at all? If so, worth making sure that is upgraded to v0.6.4 also as that would be required for the new setting to work
    3. For an easy "random shot in the dark" attempt at a solution, you could try additionally including ForcedCompression: dagger.Gzip, in the dagger.ContainerPublishOpts.
      • I would be very surprised if this fixed it, but if somehow your engine's cache got layers that use a different compression than the default of gzip, it's possible you could end up including those in your publish attempts and maybe confuse the older version of artifactory. No clue how/why that would happen, but really easy to try so worth a shot I suppose.
  8. nipuna-perera commented on Jul 25, 2023

    @nipuna-perera
    ContributorAuthor

    Let me try that @sipsma . I am not using any experimental flags. Just vanilla dagger.

  9. nipuna-perera commented on Jul 25, 2023

    @nipuna-perera
    ContributorAuthor

    using dagger.Gzip didn't work.

    I tried running dagger run --debug and I see something interesting. this is my publish snippet

    	addr, err := dockerImage.Publish(ctx, publishImageName, dagger.ContainerPublishOpts{
    		MediaTypes:        dagger.Dockermediatypes,
    		ForcedCompression: dagger.Gzip,
    	})

    But in the log I see this

    [4.31s] ERROR publish(address: "myregistry.com/image-demo:a515466.local1690166155", mediaTypes: "OCIMediaTypes")
    

    Why is it still "OCIMediaTypes"

    I checked my go.mod which is using dagger v0.7.4. And docker ps shows it running engine 0.6.4. My dagger CLI is also 0.6.4.

  10. sipsma commented on Jul 25, 2023

    @sipsma
    Contributor

    Why is it still "OCIMediaTypes"

    @nipuna-perera Great find! That's definitely not expected. Just to double check, what's the output of running dagger version?

  11. nipuna-perera commented on Jul 25, 2023

    @nipuna-perera
    ContributorAuthor

    image

  12. sipsma commented on Jul 25, 2023

    @sipsma
    Contributor

    When I do dagger run --debug I see the expected log output: [0.98s] publish(forcedCompression: "Gzip", mediaTypes: "DockerMediaTypes", address: "127.0.0.1:8081/test/testimage2:latest"), so something is still different...

    I am on Linux, so I'll try on macos directly too since that's what you are using based on the version. No clue how that could be related, but will give it a shot anyways.

    @nipuna-perera as another shot-in-the-dark, could you try running docker rm -fv dagger-engine-691afa1f6ab7b8d7, which should clear out your existing engine, and then re-run again? Just to double check there's not some stale cache state that could be (unexpectedly) interfering.

  13. nipuna-perera commented on Jul 25, 2023

    @nipuna-perera
    ContributorAuthor

    Same result :(

  14. sipsma commented on Jul 25, 2023

    @sipsma
    Contributor

    I can't run artifactory in docker desktop on macos for some reason (get a huge java stack trace at startup, cannot discern actual issue), but I can still use dagger run --debug and at least see this: [0.69s] ERROR publish(address: "127.0.0.1:8081/test/testimage2:latest", forcedCompression: "Gzip", mediaTypes: "DockerMediaTypes")

    So the options are still what would be expected at least and different from what you are getting.... I need to think about what else could possibly be happening here, I'll get back to you when I have any other ideas. Sorry about the hassle here, something very bizarre seems to be happening.

  15. nipuna-perera commented on Jul 25, 2023

    @nipuna-perera
    ContributorAuthor

    I'm baffled, I see that you have forcedCompression in your log. It's not showing me that although I have it in my code.. So I don't think the MediaTypes are taken at all.. I tried go build, go install my binary and running. Same result with dagger run --debug

    I only have a single Publish in my code, so I can't be running something un-intended.

  16. sipsma commented on Jul 25, 2023

    @sipsma
    Contributor

    I only have a single Publish in my code, so I can't be running something un-intended.

    I know there's probably proprietary stuff you can't share, but is there anyway you could strip the proprietary parts out and send over the code you're running (can be DM on discord)? Just to make sure there's not some weird corner case where if Publish is called in some particular way it ends up ignoring options.

  17. nipuna-perera commented on Jul 25, 2023

    @nipuna-perera
    ContributorAuthor

    Let me see if I can simplify it to a point which I can share. As it stands now it'll be tough to share context with my current code base.

  18. nipuna-perera commented on Jul 25, 2023

    @nipuna-perera
    ContributorAuthor

    I figured it out @sipsma . I DID have another entrypoint for publish which I meant to remove a while back and my tests were using that. I am so sorry for taking so much of your valuable time on this! Thank you for sticking to it and helping me figure it out.

  19. sipsma commented on Jul 25, 2023

    @sipsma
    Contributor

    @nipuna-perera No worries at all! I'm just glad that it is working! Honestly the fact that this was so non-obvious probably means we need to improve our visibility+debuggability somewhere. If you have any suggestions on that front in the context of your code, please let us know!

  20. nipuna-perera commented on Jul 28, 2023

    @nipuna-perera
    ContributorAuthor

    Thank you @sipsma ! I think the project zenith work might help. If debug logging could output exact entrypoints to what it's running that may help debugging. But the code could have other strange endpoints the developer forgot to clean up. Those are tough to track for sure. If I think of anything else I will definitely let you know :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions