open-component-model / ocm

Open Component Model (Software Bill of Delivery Toolset)
https://ocm.software
Apache License 2.0
31 stars 19 forks source link

Panic when calling GetComponentVersion #756

Closed achimweigel closed 2 months ago

achimweigel commented 2 months ago

What happened:

A panic is thrown when calling GetComponentVersion:

{"level":"info","ts":"2024-04-29T12:53:17.439Z","logger":"controllers.installation","msg":"Observed a panic in reconciler: v0.10.0-dev-0b0279793a6460903581187980406318bb427d9f... is no semver version: Invalid Semantic Version","reconciledResourceKind":"Installation","reconcileID":"3d131a57-391e-4bb8-988b-121ed687be5f"}
panic: v0.10.0-dev-0b0279793a6460903581187980406318bb427d9f... is no semver version: Invalid Semantic Version [recovered]
    panic: v0.10.0-dev-0b0279793a6460903581187980406318bb427d9f... is no semver version: Invalid Semantic Version [recovered]
    panic: v0.10.0-dev-0b0279793a6460903581187980406318bb427d9f... is no semver version: Invalid Semantic Version

goroutine 279 [running]:
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile.func1()
    /root/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.3/pkg/internal/controller/controller.go:116 +0x1e5
panic({0x2c17580?, 0xc0009c1e80?})
    /usr/local/go/src/runtime/panic.go:770 +0x132
github.com/gardener/landscaper/pkg/utils.HandlePanics({0x3674738, 0xc000d383c0}, 0xc001119bf8, {0x3693a80, 0xc000672900})
    /tmp/build/d97a9d50/git-gardener.landscaper-master/pkg/utils/panic_handler.go:74 +0x4e5
panic({0x2c17580?, 0xc0009c1e80?})
    /usr/local/go/src/runtime/panic.go:770 +0x132
github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/genericocireg.toTag({0xc0002b3800, 0x37})
    /root/go/pkg/mod/github.com/open-component-model/ocm@v0.8.0/pkg/contexts/ocm/repositories/genericocireg/component.go:78 +0xc6
github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/genericocireg.(*componentAccessImpl).LookupVersion(0xc0008d3040, {0xc0002b3800, 0x37})
    /root/go/pkg/mod/github.com/open-component-model/ocm@v0.8.0/pkg/contexts/ocm/repositories/genericocireg/component.go:135 +0x3d
github.com/open-component-model/ocm/pkg/contexts/ocm/cpi/repocpi.(*componentAccessBridge).LookupVersion(0xc0008d3100, {0xc0002b3800, 0x37})
    /root/go/pkg/mod/github.com/open-component-model/ocm@v0.8.0/pkg/contexts/ocm/cpi/repocpi/bridge_c.go:106 +0x46
github.com/open-component-model/ocm/pkg/contexts/ocm/cpi/repocpi.(*componentAccessView).LookupVersion.func1()
    /root/go/pkg/mod/github.com/open-component-model/ocm@v0.8.0/pkg/contexts/ocm/cpi/repocpi/view_c.go:110 +0x3e
github.com/open-component-model/ocm/pkg/refmgmt.(*view).Execute(0x2eb2620?, 0xc001118801?)
    /root/go/pkg/mod/github.com/open-component-model/ocm@v0.8.0/pkg/refmgmt/refcloser.go:171 +0xc3
github.com/open-component-model/ocm/pkg/refmgmt/resource.(*resourceView[...]).Execute(...)
    /root/go/pkg/mod/github.com/open-component-model/ocm@v0.8.0/pkg/refmgmt/resource/resource.go:202
github.com/open-component-model/ocm/pkg/contexts/ocm/cpi/repocpi.(*componentAccessView).LookupVersion(0xc0009c1e40, {0xc0002b3800, 0x37})
    /root/go/pkg/mod/github.com/open-component-model/ocm@v0.8.0/pkg/contexts/ocm/cpi/repocpi/view_c.go:109 +0xcc
github.com/open-component-model/ocm/pkg/contexts/ocm.(*session).GetComponentVersion(0xc000c31d40, {0x7f5674018e38, 0xc0009c1e40}, {0xc0002b3800, 0x37})
    /root/go/pkg/mod/github.com/open-component-model/ocm@v0.8.0/pkg/contexts/ocm/session.go:196 +0x2ef
github.com/open-component-model/ocm/pkg/contexts/ocm.(*session).LookupComponentVersion(0xc000c31d40, {0x7f567400d0a8, 0xc000ef37e0}, {0xc000ce1020, 0x22}, {0xc0002b3800, 0x37})
    /root/go/pkg/mod/github.com/open-component-model/ocm@v0.8.0/pkg/contexts/ocm/session.go:154 +0x6c5
github.com/gardener/landscaper/pkg/components/ocmlib.(*RegistryAccess).GetComponentVersion(0xc00072cc30, {0xc001118c48?, 0x16f2899?}, 0xc00053fc80)
    /tmp/build/d97a9d50/git-gardener.landscaper-master/pkg/components/ocmlib/registryaccess.go:136 +0x1f6
github.com/gardener/landscaper/pkg/landscaper/blueprints.Resolve({0x3674738, 0xc000d383c0}, {0x36570a0, 0xc00072cc30}, 0xc00053fc50, {0xc0002aa1f0?, 0x0?})
    /tmp/build/d97a9d50/git-gardener.landscaper-master/pkg/landscaper/blueprints/resolve.go:132 +0x14f
github.com/gardener/landscaper/pkg/landscaper/controllers/installations.(*Controller).initPrerequisites(0xc0007bc2c0, {0x3674738, 0xc000d383c0}, 0xc000b42008, 0x1)
    /tmp/build/d97a9d50/git-gardener.landscaper-master/pkg/landscaper/controllers/installations/controller.go:388 +0x797
github.com/gardener/landscaper/pkg/landscaper/controllers/installations.(*Controller).init(0xc0007bc2c0, {0x3674738, 0xc000d383c0}, 0xc000b42008, 0x1)

It looks as if this method is responsible for this:

func toTag(v string) string {
    _, err := semver.NewVersion(v)
    if err != nil {
        panic(errors.Wrapf(err, "%s is no semver version", v))
    }
    return strings.ReplaceAll(v, "+", META_SEPARATOR)
}

What you expected to happen:

No panic thrown by a library function or method.

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know:

Environment:

morri-son commented 2 months ago

@hilmarf can you please take a look at this?