mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Add CRI fake runtimes for RuntimeConfig rpc
Also update the CRI RuntimeService inteface to include the new RuntimeConfig rpc.
This commit is contained in:
parent
0f05a92ce6
commit
d2d5e2e27d
@ -356,3 +356,13 @@ func (f *RemoteRuntime) ListPodSandboxMetrics(ctx context.Context, req *kubeapi.
|
||||
|
||||
return &kubeapi.ListPodSandboxMetricsResponse{PodMetrics: podMetrics}, nil
|
||||
}
|
||||
|
||||
// RuntimeConfig returns the configuration information of the runtime.
|
||||
func (f *RemoteRuntime) RuntimeConfig(ctx context.Context, req *kubeapi.RuntimeConfigRequest) (*kubeapi.RuntimeConfigResponse, error) {
|
||||
resp, err := f.RuntimeService.RuntimeConfig(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
@ -865,3 +865,18 @@ func (r *remoteRuntimeService) ListPodSandboxMetrics(ctx context.Context) ([]*ru
|
||||
|
||||
return resp.GetPodMetrics(), nil
|
||||
}
|
||||
|
||||
// RuntimeConfig returns the configuration information of the runtime.
|
||||
func (r *remoteRuntimeService) RuntimeConfig(ctx context.Context) (*runtimeapi.RuntimeConfigResponse, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, r.timeout)
|
||||
defer cancel()
|
||||
|
||||
resp, err := r.runtimeClient.RuntimeConfig(ctx, &runtimeapi.RuntimeConfigRequest{})
|
||||
if err != nil {
|
||||
klog.ErrorS(err, "RuntimeConfig from runtime service failed")
|
||||
return nil, err
|
||||
}
|
||||
klog.V(10).InfoS("[RemoteRuntimeService] RuntimeConfigResponse", "linuxConfig", resp.GetLinux())
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
@ -361,3 +361,12 @@ func (in instrumentedRuntimeService) ListPodSandboxMetrics(ctx context.Context)
|
||||
recordError(operation, err)
|
||||
return out, err
|
||||
}
|
||||
|
||||
func (in instrumentedRuntimeService) RuntimeConfig(ctx context.Context) (*runtimeapi.RuntimeConfigResponse, error) {
|
||||
const operation = "runtime_config"
|
||||
defer recordOperation(operation, time.Now())
|
||||
|
||||
out, err := in.service.RuntimeConfig(ctx)
|
||||
recordError(operation, err)
|
||||
return out, err
|
||||
}
|
||||
|
@ -115,6 +115,8 @@ type RuntimeService interface {
|
||||
UpdateRuntimeConfig(ctx context.Context, runtimeConfig *runtimeapi.RuntimeConfig) error
|
||||
// Status returns the status of the runtime.
|
||||
Status(ctx context.Context, verbose bool) (*runtimeapi.StatusResponse, error)
|
||||
// RuntimeConfig returns the configuration information of the runtime.
|
||||
RuntimeConfig(ctx context.Context) (*runtimeapi.RuntimeConfigResponse, error)
|
||||
}
|
||||
|
||||
// ImageManagerService interface should be implemented by a container image
|
||||
|
@ -64,14 +64,15 @@ type FakeRuntimeService struct {
|
||||
Called []string
|
||||
Errors map[string][]error
|
||||
|
||||
FakeStatus *runtimeapi.RuntimeStatus
|
||||
Containers map[string]*FakeContainer
|
||||
Sandboxes map[string]*FakePodSandbox
|
||||
FakeContainerStats map[string]*runtimeapi.ContainerStats
|
||||
FakePodSandboxStats map[string]*runtimeapi.PodSandboxStats
|
||||
FakePodSandboxMetrics map[string]*runtimeapi.PodSandboxMetrics
|
||||
FakeMetricDescriptors map[string]*runtimeapi.MetricDescriptor
|
||||
FakeContainerMetrics map[string]*runtimeapi.ContainerMetrics
|
||||
FakeStatus *runtimeapi.RuntimeStatus
|
||||
Containers map[string]*FakeContainer
|
||||
Sandboxes map[string]*FakePodSandbox
|
||||
FakeContainerStats map[string]*runtimeapi.ContainerStats
|
||||
FakePodSandboxStats map[string]*runtimeapi.PodSandboxStats
|
||||
FakePodSandboxMetrics map[string]*runtimeapi.PodSandboxMetrics
|
||||
FakeMetricDescriptors map[string]*runtimeapi.MetricDescriptor
|
||||
FakeContainerMetrics map[string]*runtimeapi.ContainerMetrics
|
||||
FakeLinuxConfiguration *runtimeapi.LinuxRuntimeConfiguration
|
||||
|
||||
ErrorOnSandboxCreate bool
|
||||
}
|
||||
@ -780,3 +781,16 @@ func (r *FakeRuntimeService) ListPodSandboxMetrics(_ context.Context) ([]*runtim
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// RuntimeConfig returns runtime configuration of the FakeRuntimeService.
|
||||
func (r *FakeRuntimeService) RuntimeConfig(_ context.Context) (*runtimeapi.RuntimeConfigResponse, error) {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
|
||||
r.Called = append(r.Called, "RuntimeConfig")
|
||||
if err := r.popError("RuntimeConfig"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &runtimeapi.RuntimeConfigResponse{Linux: r.FakeLinuxConfiguration}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user