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

Fix OCIString parsing of local docker images #556

Merged
merged 1 commit into from
Mar 16, 2020

Conversation

darkowlzz
Copy link
Contributor

Local docker images don't have repo name in the OCI string.
Example: docker://sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e

URL parsing OCI string of local docker image fails because of the
invalid url format.

I was working on local image import from a tar file and came across this issue when importing with runtime docker. Importing with containerd resulted in proper OCI string with repo name in it. When /var/lib/firecracker/image contains any image metadata with invalid OCI source ID, any ignite execution that reads images starts failing with errors like:

FATA[0000] v1alpha2.Image.Status: v1alpha2.ImageStatus.OCISource: v1alpha2.OCIImageSource.Size: ID: unmarshalerDecoder: parse docker://sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e: invalid port ":fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e" after host, error found in #10 byte of ...|1675f587e","size":"1|..., bigger context ...|977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e","size":"1840B"}}}|... 

After debugging, the actual error was about the URL parse failure at parseOCIString():

parse docker://sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e: invalid port ":fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e" after host

Adds tests to verify the fix.

@darkowlzz darkowlzz requested a review from twelho as a code owner March 9, 2020 19:43
@@ -6,6 +6,10 @@ import (
"net/url"
"strings"

// "github.com/opencontainers/go-digest" requires us to load the algorithms
// that we want to use into the binary. (it calls algorithm.Available)
_ "crypto/sha256"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got this from @stealthybox 's branch https://github.com/stealthybox/ignite/blob/fix-oci-ref/pkg/apis/meta/v1alpha1/image.go#L9-L11 . Without this, the test run fails with "unsupported digest algorithm" error.

Local docker images don't have repo name in the OCI string.
Example: docker://sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e

URL parsing OCI string of local docker image fails because of the
invalid url format.
@stealthybox
Copy link
Contributor

Related #465

@luxas luxas added this to the v0.7.0 milestone Mar 16, 2020
@chanwit
Copy link
Member

chanwit commented Mar 16, 2020

LGTM

@chanwit chanwit merged commit 079a399 into weaveworks:master Mar 16, 2020
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.

4 participants