mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
kubelet: update remote runtimes for cri stat changes
Signed-off-by: Peter Hunt <pehunt@redhat.com>
This commit is contained in:
parent
2dc2b1e239
commit
a9b7dcc8c2
@ -262,6 +262,27 @@ func (f *RemoteRuntime) ListContainerStats(ctx context.Context, req *kubeapi.Lis
|
|||||||
return &kubeapi.ListContainerStatsResponse{Stats: stats}, nil
|
return &kubeapi.ListContainerStatsResponse{Stats: stats}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PodSandboxStats returns stats of the pod. If the pod does not
|
||||||
|
// exist, the call returns an error.
|
||||||
|
func (f *RemoteRuntime) PodSandboxStats(ctx context.Context, req *kubeapi.PodSandboxStatsRequest) (*kubeapi.PodSandboxStatsResponse, error) {
|
||||||
|
stats, err := f.RuntimeService.PodSandboxStats(req.PodSandboxId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &kubeapi.PodSandboxStatsResponse{Stats: stats}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPodSandboxStats returns stats of all running pods.
|
||||||
|
func (f *RemoteRuntime) ListPodSandboxStats(ctx context.Context, req *kubeapi.ListPodSandboxStatsRequest) (*kubeapi.ListPodSandboxStatsResponse, error) {
|
||||||
|
stats, err := f.RuntimeService.ListPodSandboxStats(req.Filter)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &kubeapi.ListPodSandboxStatsResponse{Stats: stats}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// UpdateRuntimeConfig updates the runtime configuration based on the given request.
|
// UpdateRuntimeConfig updates the runtime configuration based on the given request.
|
||||||
func (f *RemoteRuntime) UpdateRuntimeConfig(ctx context.Context, req *kubeapi.UpdateRuntimeConfigRequest) (*kubeapi.UpdateRuntimeConfigResponse, error) {
|
func (f *RemoteRuntime) UpdateRuntimeConfig(ctx context.Context, req *kubeapi.UpdateRuntimeConfigRequest) (*kubeapi.UpdateRuntimeConfigResponse, error) {
|
||||||
err := f.RuntimeService.UpdateRuntimeConfig(req.RuntimeConfig)
|
err := f.RuntimeService.UpdateRuntimeConfig(req.RuntimeConfig)
|
||||||
|
@ -569,6 +569,46 @@ func (r *remoteRuntimeService) ListContainerStats(filter *runtimeapi.ContainerSt
|
|||||||
return resp.GetStats(), nil
|
return resp.GetStats(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PodSandboxStats returns the stats of the pod.
|
||||||
|
func (r *remoteRuntimeService) PodSandboxStats(podSandboxID string) (*runtimeapi.PodSandboxStats, error) {
|
||||||
|
klog.V(10).InfoS("[RemoteRuntimeService] PodSandboxStats", "podSandboxID", podSandboxID, "timeout", r.timeout)
|
||||||
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
resp, err := r.runtimeClient.PodSandboxStats(ctx, &runtimeapi.PodSandboxStatsRequest{
|
||||||
|
PodSandboxId: podSandboxID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
if r.logReduction.ShouldMessageBePrinted(err.Error(), podSandboxID) {
|
||||||
|
klog.ErrorS(err, "PodSandbox from runtime service failed", "podSandboxID", podSandboxID)
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
r.logReduction.ClearID(podSandboxID)
|
||||||
|
klog.V(10).InfoS("[RemoteRuntimeService] PodSandbox Response", "podSandboxID", podSandboxID, "stats", resp.GetStats())
|
||||||
|
|
||||||
|
return resp.GetStats(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPodSandboxStats returns the list of pod sandbox stats given the filter
|
||||||
|
func (r *remoteRuntimeService) ListPodSandboxStats(filter *runtimeapi.PodSandboxStatsFilter) ([]*runtimeapi.PodSandboxStats, error) {
|
||||||
|
klog.V(10).InfoS("[RemoteRuntimeService] ListPodSandboxStats", "filter", filter)
|
||||||
|
// Set timeout, because runtimes are able to cache disk stats results
|
||||||
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
resp, err := r.runtimeClient.ListPodSandboxStats(ctx, &runtimeapi.ListPodSandboxStatsRequest{
|
||||||
|
Filter: filter,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
klog.ErrorS(err, "ListPodSandboxStats with filter from runtime service failed", "filter", filter)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
klog.V(10).InfoS("[RemoteRuntimeService] ListPodSandboxStats Response", "filter", filter, "stats", resp.GetStats())
|
||||||
|
|
||||||
|
return resp.GetStats(), nil
|
||||||
|
}
|
||||||
|
|
||||||
// ReopenContainerLog reopens the container log file.
|
// ReopenContainerLog reopens the container log file.
|
||||||
func (r *remoteRuntimeService) ReopenContainerLog(containerID string) error {
|
func (r *remoteRuntimeService) ReopenContainerLog(containerID string) error {
|
||||||
klog.V(10).InfoS("[RemoteRuntimeService] ReopenContainerLog", "containerID", containerID, "timeout", r.timeout)
|
klog.V(10).InfoS("[RemoteRuntimeService] ReopenContainerLog", "containerID", containerID, "timeout", r.timeout)
|
||||||
|
@ -20,10 +20,13 @@ package dockershim
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ErrNotImplemented = errors.New("Not implemented")
|
||||||
|
|
||||||
// ContainerStats returns stats for a container stats request based on container id.
|
// ContainerStats returns stats for a container stats request based on container id.
|
||||||
func (ds *dockerService) ContainerStats(_ context.Context, r *runtimeapi.ContainerStatsRequest) (*runtimeapi.ContainerStatsResponse, error) {
|
func (ds *dockerService) ContainerStats(_ context.Context, r *runtimeapi.ContainerStatsRequest) (*runtimeapi.ContainerStatsResponse, error) {
|
||||||
stats, err := ds.getContainerStats(r.ContainerId)
|
stats, err := ds.getContainerStats(r.ContainerId)
|
||||||
@ -62,3 +65,15 @@ func (ds *dockerService) ListContainerStats(ctx context.Context, r *runtimeapi.L
|
|||||||
|
|
||||||
return &runtimeapi.ListContainerStatsResponse{Stats: stats}, nil
|
return &runtimeapi.ListContainerStatsResponse{Stats: stats}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PodSandboxStats returns stats for a pod sandbox based on pod sandbox id.
|
||||||
|
// This function is not implemented for the dockershim.
|
||||||
|
func (ds *dockerService) PodSandboxStats(_ context.Context, r *runtimeapi.PodSandboxStatsRequest) (*runtimeapi.PodSandboxStatsResponse, error) {
|
||||||
|
return nil, ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPodSandboxStats returns stats for a list of pod sandboxes based on a filter.
|
||||||
|
// This function is not implemented for the dockershim.
|
||||||
|
func (ds *dockerService) ListPodSandboxStats(ctx context.Context, r *runtimeapi.ListPodSandboxStatsRequest) (*runtimeapi.ListPodSandboxStatsResponse, error) {
|
||||||
|
return nil, ErrNotImplemented
|
||||||
|
}
|
||||||
|
@ -244,6 +244,24 @@ func (in instrumentedRuntimeService) ListContainerStats(filter *runtimeapi.Conta
|
|||||||
return out, err
|
return out, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (in instrumentedRuntimeService) PodSandboxStats(podSandboxID string) (*runtimeapi.PodSandboxStats, error) {
|
||||||
|
const operation = "podsandbox_stats"
|
||||||
|
defer recordOperation(operation, time.Now())
|
||||||
|
|
||||||
|
out, err := in.service.PodSandboxStats(podSandboxID)
|
||||||
|
recordError(operation, err)
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (in instrumentedRuntimeService) ListPodSandboxStats(filter *runtimeapi.PodSandboxStatsFilter) ([]*runtimeapi.PodSandboxStats, error) {
|
||||||
|
const operation = "list_podsandbox_stats"
|
||||||
|
defer recordOperation(operation, time.Now())
|
||||||
|
|
||||||
|
out, err := in.service.ListPodSandboxStats(filter)
|
||||||
|
recordError(operation, err)
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
func (in instrumentedRuntimeService) PortForward(req *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) {
|
func (in instrumentedRuntimeService) PortForward(req *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) {
|
||||||
const operation = "port_forward"
|
const operation = "port_forward"
|
||||||
defer recordOperation(operation, time.Now())
|
defer recordOperation(operation, time.Now())
|
||||||
|
Loading…
Reference in New Issue
Block a user