concourse / registry-image-resource

a resource for images in a Docker registry
Apache License 2.0
89 stars 107 forks source link

`in` hangs when unpacking image #303

Closed Infinoid closed 2 years ago

Infinoid commented 3 years ago

I have a container image which hangs during the get stage. I built this image myself, but there's nothing special about it. Public images work fine. Other images that I've built work fine. Not sure what's weird about this one.

I tried setting debug=true in the source definition; it listed all of the files it was unpacking, and then just stopped generating output. The image has 8 layers, it unpacked all 8 correctly, it just didn't finish execution afterwards.

I let it run for a few hours, it never finished.

So I went and sprinkled some log messages into the code. Turns out, the hang is in the progress bar. In unpackImage(), the call to progress.Wait() never returns.

If I manually trigger completion of the bar at the end of extractLayer(), like this:

    bar.SetTotal(bar.Current(), true)

    return nil
}

…, then it works fine.

Maybe the layer object reported the wrong size or something? I'm looking for advice on how to debug this further.

Infinoid commented 3 years ago

I threw the bad image up on Github Packages so you folks can try to reproduce it.

I ran this in the registry-image-resource checkout folder, saw the hang, and hit ctrl-C to kill it:

$ go run ./cmd/in tmp <bad.json 
fetching ghcr.io/infinoid/test-image-303@sha256:97259f5b269ca30658a2072caaf5abe46c6475833cbdaee309b66fd976040479
95eb225f2117 [==============================================================================] 2.8MiB/2.8MiB
186214be6882 [==============================================================================] 2.1MiB/2.1MiB
d9c49a7c740b [==============================================================================] 26.4MiB/26.4MiB
55102405217b [==============================================================================] 9.1MiB/9.1MiB
^Csignal: interrupt

bad.json:

{
  "source": {
    "repository": "ghcr.io/infinoid/test-image-303",
    "tag": "bad"
  },
  "version": {
    "digest": "sha256:97259f5b269ca30658a2072caaf5abe46c6475833cbdaee309b66fd976040479"
  }
}

good.json:

{
  "source": {
    "repository": "ghcr.io/infinoid/test-image-303",
    "tag": "good"
  },
  "version": {
    "digest": "sha256:2f759cec621e1846b06a7269de9c0362ad5dc0b693369736468760470aa20640"
  }
}

The "bad" and "good" tags only differ by 1 layer. The good one works; the bad one hangs.

I think the Dockerfile is nothing special:

FROM alpine

RUN apk update
RUN apk add --no-cache py3-pip py3-wheel libxslt-dev sqlite s6-overlay
RUN apk add --no-cache py3-flask py3-pillow py3-pytest py3-sqlalchemy uwsgi uwsgi-python3 # BAD?

ENV HOME=/app

ENTRYPOINT ["/init"]

It was built with: podman build --tag ghcr.io/infinoid/test-image-303:bad ./docker.

The "good" tag is what I got when commenting out the "BAD?" line.

xtremerui commented 2 years ago

Should be fixed by latest release.