diff --git a/pkg/kubelet/container/runtime.go b/pkg/kubelet/container/runtime.go index 0810e938f26..ad59de4df1c 100644 --- a/pkg/kubelet/container/runtime.go +++ b/pkg/kubelet/container/runtime.go @@ -119,6 +119,9 @@ type Runtime interface { // This method just proxies a new runtimeConfig with the updated // CIDR value down to the runtime shim. UpdatePodCIDR(podCIDR string) error + // CheckpointContainer tells the runtime to checkpoint a container + // and store the resulting archive to the checkpoint directory. + CheckpointContainer(options *runtimeapi.CheckpointContainerRequest) error } // StreamingRuntime is the interface implemented by runtimes that handle the serving of the diff --git a/pkg/kubelet/container/testing/fake_runtime.go b/pkg/kubelet/container/testing/fake_runtime.go index 3765e87c8a6..c259a06cb13 100644 --- a/pkg/kubelet/container/testing/fake_runtime.go +++ b/pkg/kubelet/container/testing/fake_runtime.go @@ -362,6 +362,14 @@ func (f *FakeRuntime) DeleteContainer(containerID kubecontainer.ContainerID) err return f.Err } +func (f *FakeRuntime) CheckpointContainer(options *runtimeapi.CheckpointContainerRequest) error { + f.Lock() + defer f.Unlock() + + f.CalledFunctions = append(f.CalledFunctions, "CheckpointContainer") + return f.Err +} + func (f *FakeRuntime) ImageStats() (*kubecontainer.ImageStats, error) { f.Lock() defer f.Unlock() diff --git a/pkg/kubelet/container/testing/runtime_mock.go b/pkg/kubelet/container/testing/runtime_mock.go index b2633095912..1e68ee3f5f8 100644 --- a/pkg/kubelet/container/testing/runtime_mock.go +++ b/pkg/kubelet/container/testing/runtime_mock.go @@ -126,6 +126,20 @@ func (mr *MockRuntimeMockRecorder) APIVersion() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "APIVersion", reflect.TypeOf((*MockRuntime)(nil).APIVersion)) } +// CheckpointContainer mocks base method. +func (m *MockRuntime) CheckpointContainer(options *v10.CheckpointContainerRequest) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CheckpointContainer", options) + ret0, _ := ret[0].(error) + return ret0 +} + +// CheckpointContainer indicates an expected call of CheckpointContainer. +func (mr *MockRuntimeMockRecorder) CheckpointContainer(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckpointContainer", reflect.TypeOf((*MockRuntime)(nil).CheckpointContainer), options) +} + // DeleteContainer mocks base method. func (m *MockRuntime) DeleteContainer(containerID container.ContainerID) error { m.ctrl.T.Helper() diff --git a/pkg/kubelet/kuberuntime/kuberuntime_manager.go b/pkg/kubelet/kuberuntime/kuberuntime_manager.go index 8dee580344e..6b2761a38e1 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_manager.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_manager.go @@ -1100,3 +1100,7 @@ func (m *kubeGenericRuntimeManager) UpdatePodCIDR(podCIDR string) error { }, }) } + +func (m *kubeGenericRuntimeManager) CheckpointContainer(options *runtimeapi.CheckpointContainerRequest) error { + return m.runtimeService.CheckpointContainer(options) +}