Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource tries to pull image with incorrect digest #33

Closed
martinsbalodis opened this issue Apr 18, 2016 · 6 comments
Closed

Resource tries to pull image with incorrect digest #33

martinsbalodis opened this issue Apr 18, 2016 · 6 comments

Comments

@martinsbalodis
Copy link

Hi!
I am running fly execute but it fails while pulling a docker image. From the output I can see that it tries to pull a version of a container that has never existed in the repository (private http repository).

Here is the task.yml part:

...
image_resource:
  type: docker-image
  source:
   repository: 1.2.3.4:5000/my-image
   insecure_registries: ["1.2.3.4:5000"]
   email: martins@example.com
   username: martins
   password: pass
...

Fly command:

fly -t lc execute -c task.yml

Output of the fly command:

...
initializing
WARNING: login credentials saved in /root/.docker/config.json
Login Succeeded
Pulling 1.2.3.4:5000/my-image@sha256:59795eb87abd170f1b97f82f5838db5637890962d7bd623f5ce04c7833ef29f0...
Error response from daemon: manifest unknown: manifest unknown

Pulling 1.2.3.4:5000/my-image@sha256:59795eb87abd170f1b97f82f5838db5637890962d7bd623f5ce04c7833ef29f0 (attempt 2 of 3)...
Error response from daemon: manifest unknown: manifest unknown

Pulling 1.2.3.4:5000/my-image@sha256:59795eb87abd170f1b97f82f5838db5637890962d7bd623f5ce04c7833ef29f0 (attempt 3 of 3)...
Error response from daemon: manifest unknown: manifest unknown


Failed to pull image 1.2.3.4:5000/my-image@sha256:59795eb87abd170f1b97f82f5838db5637890962d7bd623f5ce04c7833ef29f0.resource script '/opt/resource/in [/tmp/build/get]' failed: exit status 1
errored

The docker registry doesn't contain a version of this image that has sha256 like 59795eb87abd. I also checked the directory where the images are stored to make sure.

@concourse-bot
Copy link
Collaborator

Hi there!

We use Pivotal Tracker to provide visibility into what our team is working on. A story for this issue has been automatically created.

The current status is as follows:

  • #117790211 Resource tries to pull image with incorrect digest

This comment, as well as the labels on the issue, will be automatically updated as the status in Tracker changes.

@vito
Copy link
Member

vito commented Apr 18, 2016

Don't really know what to tell ya. We collect these versions from the registry API and then just go back and try to fetch them from the same registry. Sounds like your registry is broken or inconsistent? Are you running a v2 registry?

@databus23
Copy link
Contributor

databus23 commented Apr 19, 2016

I've been hit by this too, today when we upgraded the registry from from 2.3.0 to 2.4.0.

@martinsbalodis Are you be any chance running a registry version >= 2.3.1?

I think this change is causing the problem: distribution/distribution@d7eb5d1

It seems the docker-image check method is fetching v1 digests but docker pull expects v2 digests.

Running the docker-image resource returns a digest that can't be pulled:

echo '{"source":{"repository":"docker.mo.sap.corp/concourse/monsoon-version","tag":"latest"}}'| docker run --rm -i docker-image-resource /opt/resource/check
[{"digest":"sha256:a8348e02225831b1b78b54654e78ae480430f4f652f145024859bfdb3ffb6dad"}]

docker pull docker.mo.sap.corp/concourse/monsoon-version@sha256:a8348e02225831b1b78b54654e78ae480430f4f652f145024859bfdb3ffb6dad
Error response from daemon: manifest unknown: manifest unknown

Fetching the manifest via curl gets me the same hash which is the v1 manifest digest

$> curl -I https://docker.mo.sap.corp/v2/concourse/monsoon-version/manifests/latest
HTTP/1.1 200 OK
Content-Length: 9314
Content-Type: application/vnd.docker.distribution.manifest.v1+prettyjws
Docker-Content-Digest: sha256:a8348e02225831b1b78b54654e78ae480430f4f652f145024859bfdb3ffb6dad
Docker-Distribution-Api-Version: registry/2.0
Etag: "sha256:a8348e02225831b1b78b54654e78ae480430f4f652f145024859bfdb3ffb6dad"
X-Content-Type-Options: nosniff
Date: Tue, 19 Apr 2016 13:10:13 GMT

When explicitly requesting the v2 manifest header I get different digest which can be pulled

$> curl -I -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' https://docker.mo.sap.corp/v2/concourse/monsoon-version/manifests/latest
HTTP/1.1 200 OK
Content-Length: 2802
Content-Type: application/vnd.docker.distribution.manifest.v2+json
Docker-Content-Digest: sha256:9aeec19e23ad3e57fd872df6493bfc5f392d10b0e2fab25e46c7a18f2c93f517
Docker-Distribution-Api-Version: registry/2.0
Etag: "sha256:9aeec19e23ad3e57fd872df6493bfc5f392d10b0e2fab25e46c7a18f2c93f517"
X-Content-Type-Options: nosniff
Date: Tue, 19 Apr 2016 13:10:47 GMT
docker pull docker.mo.sap.corp/concourse/monsoon-version@sha256:9aeec19e23ad3e57fd872df6493bfc5f392d10b0e2fab25e46c7a18f2c93f517
sha256:9aeec19e23ad3e57fd872df6493bfc5f392d10b0e2fab25e46c7a18f2c93f517: Pulling from concourse/monsoon-version
Digest: sha256:9aeec19e23ad3e57fd872df6493bfc5f392d10b0e2fab25e46c7a18f2c93f517
Status: Downloaded newer image for docker.mo.sap.corp/concourse/monsoon-version@sha256:9aeec19e23ad3e57fd872df6493bfc5f392d10b0e2fab25e46c7a18f2c93f517

databus23 added a commit to databus23/docker-image-resource that referenced this issue Apr 19, 2016
This is a fix for concourse#33
This fixes discovering digests on docker distribution >= 2.3.1 by explicitly requesting schema v2 manifests.
Before distribution 2.3.1 the v2 schema v1 manifests contained the v2 schema digest by accident which was fixed with this commit distribution/distribution@d7eb5d1.
docker pull (at least on recent versions of docker) only works with v2 digest. So this only worked by accident until it was fixed.
@martinsbalodis
Copy link
Author

I think I found the problem. The docker-image-resource might be looking at the wrong digest. I dumped the communication between docker-registry and docker-image-resource with tcpdump. Below is a request that is made by the docker-image-resource client. It seems that it is requesting the manifest of the image. The docker-registry responds with a Docker-Content-Digest header. This digest is then used by the docker-image-resource as the required digest for image. I think this digest is the digest of the response message and not the image.

GET /v2/docker-image-name/manifests/latest HTTP/1.1
Host: 1.2.3.4:5000
User-Agent: Go-http-client/1.1
Authorization: Basic asd
Accept-Encoding: gzip
Connection: close

HTTP/1.1 200 OK
Content-Length: 20775
Content-Type: application/vnd.docker.distribution.manifest.v1+prettyjws
Docker-Content-Digest: sha256:59795eb87abd170f1b97f82f5838db5637890962d7bd623f5ce04c7833ef29f0
Docker-Distribution-Api-Version: registry/2.0
Etag: "sha256:59795eb87abd170f1b97f82f5838db5637890962d7bd623f5ce04c7833ef29f0"
X-Content-Type-Options: nosniff
Date: Wed, 20 Apr 2016 07:48:46 GMT
Connection: close

{
   "schemaVersion": 1,
   "name": "docker-image-name",
   "tag": "latest",
   "architecture": "amd64",
   "fsLayers": [
      {
         "blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
      },
...

The next request made to the docker-registry looks like this:

GET /v2/docker-image-name/manifests/sha256:59795eb87abd170f1b97f82f5838db5637890962d7bd623f5ce04c7833ef29f0 HTTP/1.1

@databus23
Copy link
Contributor

@martinsbalodis The Docker-Content-Digest header of a manifest request is the digest that is needed to pull an image by digest. This is not the problem. The problem is that there are different schema versions of an image manifest yielding different digests. The docker-image-resource is not requesting the correct version for newer registries (>=2.3.1). See my previous post for more details.

@vito
Copy link
Member

vito commented Apr 22, 2016

Closing this out as @databus23's PR was merged (thanks!). This will be in the next release.

@vito vito closed this as completed Apr 22, 2016
DennisDenuto pushed a commit to cloudfoundry/runtime-ci that referenced this issue Jun 3, 2016
anEXPer pushed a commit to cloudfoundry/runtime-ci that referenced this issue Jun 9, 2016
…rhub. (Required for fix: concourse/docker-image-resource#33)"

This reverts commit 274f316.
We no longer need this workaround, as we're moving to an RC that uses
the new version of the resource in question.

Signed-off-by: Jesse Alford <jalford@pivotal.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants