Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Fix oci image #1

Closed
wants to merge 7 commits into from
Closed

Fix oci image #1

wants to merge 7 commits into from

Conversation

gsanchezgavier
Copy link

Reroller fails to get image digests when are generated by Buildkit (OCI). Some extra details

Copy link

@roobre roobre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some suggestions. Overall I'm not super happy with moving things to src, but I abandoned this project first so I won't be pestering about style guides :P

@@ -50,9 +48,18 @@ func DockerLikeImageInfo(baseUrl string) func(image, tag string) ([]string, erro
req.Header.Set("Authorization", "Bearer "+token)
}

digests := []string{}

retDigests, err := ociDigests(req)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple functions mutating this request can be a bit error prone, I'd be weary of this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes is not the best way I agree, TBH I just extended the current code to contemplate this case, didn't want to do a bigger refactor for this knowing that we will replace it soon.

Copy link
Author

@gsanchezgavier gsanchezgavier Mar 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh the request! you are right i didn't pay attention to that , I guess was a way to reuse auth, I will improve it Set replace the previous values , so not ideal but no bug here I think

return nil, fmt.Errorf("getting oci image digests from docker: %w", err)
}

digests = append(digests, retDigests...)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need both OCI-formatted digests and v2 manifest digests?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept both to avoid breaking changes on the non oci images.

Comment on lines +97 to +98
// OCI images will not respond with the list of digest
return nil, nil
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than calling dockerContentDigest unconditionally and muting this error, would it be better to avoid calling dockerContentDigest at all if OCI digests are found?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not completely sure about it (is a bit blurry to me how this API works) so I followed the existing mechanism that was adding digest to the array.

Comment on lines +115 to +117
if resp.Header.Get("Content-Type") != acceptHeader {
return nil, nil
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this should be an error or at least a log, wouldn't it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the api return different content-type event if the accept header is set to the image one. this was a quick way to filter this responses, but I didn't want to log error since this is expected and logging this will pollute the logs.

src/registry/docker/docker.go Outdated Show resolved Hide resolved
src/registry/docker/docker.go Outdated Show resolved Hide resolved
require.NoError(t, err)
require.Contains(t, digests, "sha256:7300aec653dbe8aaef96b92d2f8319a2cef8e03e99b4420ba846b46a1447ea6b")

// test buildkit image https://github.com/moby/buildkit/issues/2251
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we split this to a second test? That way we will know which one is failing.

Co-authored-by: Roberto Santalla <roobre@users.noreply.github.com>
@gsanchezgavier
Copy link
Author

Left some suggestions. Overall I'm not super happy with moving things to src, but I abandoned this project first so I won't be pestering about style guides :P

oh the reason for that was to have the possibility to do a go run to quickly test without having the image.

Copy link

@kang-makes kang-makes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hack Just Works ™️ but as there is a plan to decommission the canaries reroller I would prefer to just have it working that having a perfect solution.

I left a couple of comments that are worrying me a bit tho.

Comment on lines -14 to -17
- uses: docker/login-action@v1
with:
username: roobre
password: ${{ secrets.DOCKERHUB_TOKEN }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: docker/login-action@v1
with:
username: roobre
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

Comment on lines -18 to -21
- name: Build docker image
run: |
docker build . -t roobre/reroller:${DOCKER_IMAGE_TAG}
docker tag roobre/reroller:${DOCKER_IMAGE_TAG} roobre/reroller:latest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Build docker image
run: |
docker build . -t roobre/reroller:${DOCKER_IMAGE_TAG}
docker tag roobre/reroller:${DOCKER_IMAGE_TAG} roobre/reroller:latest
- name: Build docker image
run: |
docker build . -t ghcr.io/${{ github.repository }}:${DOCKER_IMAGE_TAG}
docker tag ghcr.io/${{ github.repository }}:${DOCKER_IMAGE_TAG} ghcr.io/${{ github.repository }}:latest

Comment on lines -22 to -25
- name: Push docker image
run: |
docker push roobre/reroller:${DOCKER_IMAGE_TAG}
docker push roobre/reroller:latest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Push docker image
run: |
docker push roobre/reroller:${DOCKER_IMAGE_TAG}
docker push roobre/reroller:latest
- name: Push docker image
run: |
docker push ghcr.io/${{ github.repository }}:${DOCKER_IMAGE_TAG}
docker push ghcr.io/${{ github.repository }}:latest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub has an OCI registry per repo. Instead of publishing to Roobre's registry, we can still publish to the GitHub one.

This way you will neither need to upload the image to your account nor we will not need a secret to upload to new relic's registry. We will be able to archive this repository easily too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh this is a very good one, I will do that.


go 1.16
go 1.20

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are having issues with Go 1.20 and Alpine. We think that it is because we are compiling with CGO_ENABLED=1 but it might be more things failing. I would stick to 1.19 for now.

@gsanchezgavier
Copy link
Author

I will open another PR with just the changes we finally need. removing the package arrangement that I did to the go run thing

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants