cmd/ctr/commands/tasks: build metrics with target platform#8234
cmd/ctr/commands/tasks: build metrics with target platform#8234fuweid wants to merge 1 commit intocontainerd:mainfrom
Conversation
e7852cf to
52ab6f8
Compare
52ab6f8 to
24097cd
Compare
The windows container is using containerd/cgroups@v1.1.0 for metrics while the linux container is using containerd/cgroups@v3.0.1. They are two different packages but the metric fields in proto share the same name. For instance, the `Metrics` type: * in cgroups@v1.1.0, it is named by io.containerd.cgroups.v1.Metrics[1]. * in cgroups@v3.0.1, it's also named by io.containerd.cgroups.v1.Metrics[2]. It's hard to tell the real type, even if both types are compatible. According to typeurl/v2@v2.1.0's behavior[3], it will check the type registed by the `RegisterType` first. Let's see a case. If the data is marshaled by containerd/cgroups@v3.0.1 and the typeurl is `io.containerd.cgroups.v1.Metrics`, ideally the receiver should use the same type to unmarshal it. However, if the receiver has a dependency using the cgroups@v1.1.0, the cgroups@v1.1.0 package will register the type with `io.containerd.cgroups.v1.Metrics` by `gogo.RegisterType`. And the receiver will cgroups@v1.1.0's type to unmarshal the data. It's compatible but it is unexpected because the receiver will use the `cgroups@v3.0.1` to do the type assertion, like what nerdctl pr[4] does. They will fail to do assertion. Currently, the windows container metrics is using containerd/cgroups@v1.1.0, which impacts nerdctl to do release. So I would like to file this pr to build metrics with target platform. REF: [1]: https://github.com/containerd/cgroups/blob/v1.1.0/stats/v1/metrics.pb.go#L705 [2]: https://github.com/containerd/cgroups/blob/v3.0.1/cgroup1/stats/metrics.pb.go#L1705 [3]: https://github.com/containerd/typeurl/blob/v2.1.0/types.go#L238-L264 [4]: containerd/nerdctl#1952 Signed-off-by: Wei Fu <fuweid89@gmail.com>
24097cd to
3f14890
Compare
|
Is this intended as a temporary fix until the Windows container metrics or cgroups package can be updated? Splitting apart the compiled Windows/Linux logic like this is the opposite direction we have been trying go in to unify our cross platform logic. |
@dmcgowan it is temporary fix for nerdctl release. No sure that when windows container can be updated... |
|
For nerdctl release I think we can just copy |
|
@AkihiroSuda sounds 👍. I close this. Thanks |
The windows container is using containerd/cgroups@v1.1.0 for metrics while the linux container is using containerd/cgroups@v3.0.1. They are two different packages but the metric fields in proto share the same name. For instance, the
Metricstype:It's hard to tell the real type, even if both types are compatible. According to typeurl/v2@v2.1.0's behavior[3], it will check the type registed by the
RegisterTypefirst. Let's see a case.If the data is marshaled by containerd/cgroups@v3.0.1 and the typeurl is
io.containerd.cgroups.v1.Metrics, ideally the receiver should use the same type to unmarshal it. However, if the receiver has a dependency using the cgroups@v1.1.0, the cgroups@v1.1.0 package will register the type withio.containerd.cgroups.v1.Metricsbygogo.RegisterType. And the receiver will cgroups@v1.1.0's type to unmarshal the data. It's compatible but it is unexpected because the receiver will use thecgroups@v3.0.1to do the type assertion, like what nerdctl pr[4] does. They will fail to do assertion.Currently, the windows container metrics is using
containerd/cgroups@v1.1.0, which impacts nerdctl to do release. So I would like to file this pr to build metrics with target platform.
REF:
[1]: https://github.com/containerd/cgroups/blob/v1.1.0/stats/v1/metrics.pb.go#L705
[2]: https://github.com/containerd/cgroups/blob/v3.0.1/cgroup1/stats/metrics.pb.go#L1705
[3]: https://github.com/containerd/typeurl/blob/v2.1.0/types.go#L238-L264
[4]: containerd/nerdctl#1952