diff --git a/pkg/kubelet/cri/remote/fake/fake_runtime.go b/pkg/kubelet/cri/remote/fake/fake_runtime.go index b1480a56703..f49fc0066a4 100644 --- a/pkg/kubelet/cri/remote/fake/fake_runtime.go +++ b/pkg/kubelet/cri/remote/fake/fake_runtime.go @@ -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 +} diff --git a/pkg/kubelet/cri/remote/remote_runtime.go b/pkg/kubelet/cri/remote/remote_runtime.go index 22b1f34b224..64571069376 100644 --- a/pkg/kubelet/cri/remote/remote_runtime.go +++ b/pkg/kubelet/cri/remote/remote_runtime.go @@ -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 +} diff --git a/pkg/kubelet/kuberuntime/instrumented_services.go b/pkg/kubelet/kuberuntime/instrumented_services.go index a83565a9c96..cfa633a9983 100644 --- a/pkg/kubelet/kuberuntime/instrumented_services.go +++ b/pkg/kubelet/kuberuntime/instrumented_services.go @@ -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 +} diff --git a/staging/src/k8s.io/cri-api/pkg/apis/services.go b/staging/src/k8s.io/cri-api/pkg/apis/services.go index a3a7e7ed876..b21b11ba24c 100644 --- a/staging/src/k8s.io/cri-api/pkg/apis/services.go +++ b/staging/src/k8s.io/cri-api/pkg/apis/services.go @@ -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 diff --git a/staging/src/k8s.io/cri-api/pkg/apis/testing/fake_runtime_service.go b/staging/src/k8s.io/cri-api/pkg/apis/testing/fake_runtime_service.go index 33cf8438dbb..332aa71d52a 100644 --- a/staging/src/k8s.io/cri-api/pkg/apis/testing/fake_runtime_service.go +++ b/staging/src/k8s.io/cri-api/pkg/apis/testing/fake_runtime_service.go @@ -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 +}