CRI: Make stats respect sandbox's platform
To further some ongoing work in containerd to make as much code as possible able to be used on any platform (to handle runtimes that can virtualize/emulate a variety of different OSes), this change makes stats able to be handled on any of the supported stat types (just linux and windows). To accomplish this, we use the platform the sandbox returns from its `Platform` rpc to decide what format the containers in a given sandbox are returning metrics in, then we can typecast/marshal accordingly. Signed-off-by: Danny Canter <danny@dcantah.dev>
This commit is contained in:
@@ -40,7 +40,12 @@ func (c *criService) ContainerStats(ctx context.Context, in *runtime.ContainerSt
|
||||
return nil, fmt.Errorf("unexpected metrics response: %+v", resp.Metrics)
|
||||
}
|
||||
|
||||
cs, err := c.containerMetrics(cntr.Metadata, resp.Metrics[0])
|
||||
handler, err := c.getMetricsHandler(ctx, cntr.SandboxID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cs, err := handler(cntr.Metadata, resp.Metrics[0])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decode container metrics: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user