Add fake runtimes and CRI changes for KEP-2371
Added new gRPC call 'ListPodSanboxMetrics' which would return additional container stats currently supported by cAdvisor, but outside the scope of /stats/summary api. Added new types to support metric exporting of prometheus, including Metric and other subfields. Added fake runtime changes associated with the CRI changes.
This commit is contained in:
@@ -336,3 +336,23 @@ func (f *RemoteRuntime) CheckpointContainer(ctx context.Context, req *kubeapi.Ch
|
||||
func (f *RemoteRuntime) GetContainerEvents(req *kubeapi.GetEventsRequest, ces kubeapi.RuntimeService_GetContainerEventsServer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListMetricDescriptors gets the descriptors for the metrics that will be returned in ListPodSandboxMetrics.
|
||||
func (f *RemoteRuntime) ListMetricDescriptors(ctx context.Context, req *kubeapi.ListMetricDescriptorsRequest) (*kubeapi.ListMetricDescriptorsResponse, error) {
|
||||
descs, err := f.RuntimeService.ListMetricDescriptors(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &kubeapi.ListMetricDescriptorsResponse{Descriptors: descs}, nil
|
||||
}
|
||||
|
||||
// ListPodSandboxMetrics retrieves the metrics for all pod sandboxes.
|
||||
func (f *RemoteRuntime) ListPodSandboxMetrics(ctx context.Context, req *kubeapi.ListPodSandboxMetricsRequest) (*kubeapi.ListPodSandboxMetricsResponse, error) {
|
||||
podMetrics, err := f.RuntimeService.ListPodSandboxMetrics(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &kubeapi.ListPodSandboxMetricsResponse{PodMetrics: podMetrics}, nil
|
||||
}
|
||||
|
@@ -815,3 +815,33 @@ func (r *remoteRuntimeService) GetContainerEvents(containerEventsCh chan *runtim
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ListMetricDescriptors gets the descriptors for the metrics that will be returned in ListPodSandboxMetrics.
|
||||
func (r *remoteRuntimeService) ListMetricDescriptors(ctx context.Context) ([]*runtimeapi.MetricDescriptor, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, r.timeout)
|
||||
defer cancel()
|
||||
|
||||
resp, err := r.runtimeClient.ListMetricDescriptors(ctx, &runtimeapi.ListMetricDescriptorsRequest{})
|
||||
if err != nil {
|
||||
klog.ErrorS(err, "ListMetricDescriptors from runtime service failed")
|
||||
return nil, err
|
||||
}
|
||||
klog.V(10).InfoS("[RemoteRuntimeService] ListMetricDescriptors Response", "stats", resp.GetDescriptors())
|
||||
|
||||
return resp.GetDescriptors(), nil
|
||||
}
|
||||
|
||||
// ListPodSandboxMetrics retrieves the metrics for all pod sandboxes.
|
||||
func (r *remoteRuntimeService) ListPodSandboxMetrics(ctx context.Context) ([]*runtimeapi.PodSandboxMetrics, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, r.timeout)
|
||||
defer cancel()
|
||||
|
||||
resp, err := r.runtimeClient.ListPodSandboxMetrics(ctx, &runtimeapi.ListPodSandboxMetricsRequest{})
|
||||
if err != nil {
|
||||
klog.ErrorS(err, "ListPodSandboxMetrics from runtime service failed")
|
||||
return nil, err
|
||||
}
|
||||
klog.V(10).InfoS("[RemoteRuntimeService] ListPodSandboxMetrics Response", "stats", resp.GetPodMetrics())
|
||||
|
||||
return resp.GetPodMetrics(), nil
|
||||
}
|
||||
|
@@ -343,3 +343,21 @@ func (in instrumentedRuntimeService) GetContainerEvents(containerEventsCh chan *
|
||||
recordError(operation, err)
|
||||
return err
|
||||
}
|
||||
|
||||
func (in instrumentedRuntimeService) ListMetricDescriptors(ctx context.Context) ([]*runtimeapi.MetricDescriptor, error) {
|
||||
const operation = "list_metric_descriptors"
|
||||
defer recordOperation(operation, time.Now())
|
||||
|
||||
out, err := in.service.ListMetricDescriptors(ctx)
|
||||
recordError(operation, err)
|
||||
return out, err
|
||||
}
|
||||
|
||||
func (in instrumentedRuntimeService) ListPodSandboxMetrics(ctx context.Context) ([]*runtimeapi.PodSandboxMetrics, error) {
|
||||
const operation = "list_podsandbox_metrics"
|
||||
defer recordOperation(operation, time.Now())
|
||||
|
||||
out, err := in.service.ListPodSandboxMetrics(ctx)
|
||||
recordError(operation, err)
|
||||
return out, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user