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

Panic: runtime error occurred when the number of image layers is 0 #14

Open
qinshaoxuan opened this issue Feb 25, 2020 · 3 comments
Open
Assignees

Comments

@qinshaoxuan
Copy link

The progress crashed when server receiving a scan request that the number of image layers is 0

Trace

panic: runtime error: index out of range [-1]

goroutine 167 [running]:
github.com/goharbor/harbor-scanner-clair/pkg/scanner.(*adapter).Scan(0xc00026d4a0, 0xc0003a7f50, 0x2f, 0xc000425400, 0x4a2, 0xc00022aa00, 0x12, 0xc0003d02d0, 0x47, 0xc0000eed80, ...)
	/home/travis/gopath/src/github.com/goharbor/harbor-scanner-clair/pkg/scanner/adapter.go:51 +0x782
github.com/goharbor/harbor-scanner-clair/pkg/scanner.(*worker).scan(0xc000562600, 0xc000000005, 0x961a62)
	/home/travis/gopath/src/github.com/goharbor/harbor-scanner-clair/pkg/scanner/worker.go:36 +0xe3
github.com/goharbor/harbor-scanner-clair/pkg/scanner.(*worker).Task(0xc000562600)
	/home/travis/gopath/src/github.com/goharbor/harbor-scanner-clair/pkg/scanner/worker.go:20 +0xd4
github.com/goharbor/harbor-scanner-clair/pkg/work.(*Pool).Start.func1.1(0x9fb980, 0xc000562600)
	/home/travis/gopath/src/github.com/goharbor/harbor-scanner-clair/pkg/work/work.go:34 +0x89
created by github.com/goharbor/harbor-scanner-clair/pkg/work.(*Pool).Start.func1
	/home/travis/gopath/src/github.com/goharbor/harbor-scanner-clair/pkg/work/work.go:32 +0xb1

Cause by

return s.getReport(req.Artifact, layers[len(layers)-1].Name)

@danielpacak
Copy link
Contributor

Good catch @qinshaoxuan . Does that mean that you pushed a scratch image to your registry and tried scanning it with Clair scanner? If not would you mind sharing the Dockerfile to reproduce it?

@danielpacak danielpacak self-assigned this Feb 26, 2020
@qinshaoxuan
Copy link
Author

@danielpacak Yes. It's a scratch image with some labels.
Dockerfile:

FROM scratch

LABEL ENV=a

@tariq1890
Copy link

@danielpacak @qinshaoxuan Any updates on this? We are facing this issue still with our clair scanners.

We should be failing gracefully here IMO

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

Successfully merging a pull request may close this issue.

3 participants