containerd / containerd

An open and reliable container runtime
https://containerd.io
Apache License 2.0
17.58k stars 3.48k forks source link

sandbox metadata is only registered in sbserver, resulting in unmarshal failures from sandbox store #8669

Open egernst opened 1 year ago

egernst commented 1 year ago

Description

I was utilizing sandbox store in order to get the resulting Linux pod sandbox config which is stored in Extensions["metadata"] as a typeUrl.Any.

When unmarshalling, I get the following error:

error="failed to unmarshal sandbox extension \"metadata\": type with url github.com/containerd/cri/pkg/store/sandbox/Metadata: not found"

The registration is done in sberver today from its' init function -- I think it needs to be done in a more central location so users of sandbox store can unmarshal as well.

Steps to reproduce the issue

1. 2. 3.

Describe the results you received and expected

I should be able to just do the following, where s is Sandbox from containers sandbox store: pkg/mod/github.com/containerd/containerd@v1.7.0/sandbox/store.go

        sb := &sandboxstore.Metadata{}
        s.GetExtension("metadata", sb)

What version of containerd are you using?

latest

Any other relevant information

n/a

Show configuration if it is related to CRI plugin.

n/a

dmcgowan commented 1 year ago

I think in this case it would make more sense to do the typeurl registration in the CRI sandbox store package rather than sbserver. The other alternative would be to move the Metadata type out of the CRI sandbox store to a more common package along with the typeurl registration.