mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
CRI changes to support implementation of in-place pod resize.
KEP: /enhancements/keps/sig-node/1287-in-place-update-pod-resources
This commit is contained in:
parent
90f9a52db6
commit
0ef263c3b0
@ -42,7 +42,7 @@ import (
|
||||
type ActivePodsFunc func() []*v1.Pod
|
||||
|
||||
type runtimeService interface {
|
||||
UpdateContainerResources(id string, resources *runtimeapi.LinuxContainerResources) error
|
||||
UpdateContainerResources(id string, resources *runtimeapi.ContainerResources) error
|
||||
}
|
||||
|
||||
type policyName string
|
||||
@ -515,8 +515,10 @@ func (m *manager) updateContainerCPUSet(containerID string, cpus cpuset.CPUSet)
|
||||
// this patch-like partial resources.
|
||||
return m.containerRuntime.UpdateContainerResources(
|
||||
containerID,
|
||||
&runtimeapi.LinuxContainerResources{
|
||||
CpusetCpus: cpus.String(),
|
||||
&runtimeapi.ContainerResources{
|
||||
Linux: &runtimeapi.LinuxContainerResources{
|
||||
CpusetCpus: cpus.String(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ type mockRuntimeService struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func (rt mockRuntimeService) UpdateContainerResources(id string, resources *runtimeapi.LinuxContainerResources) error {
|
||||
func (rt mockRuntimeService) UpdateContainerResources(id string, resources *runtimeapi.ContainerResources) error {
|
||||
return rt.err
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ const memoryManagerStateFileName = "memory_manager_state"
|
||||
type ActivePodsFunc func() []*v1.Pod
|
||||
|
||||
type runtimeService interface {
|
||||
UpdateContainerResources(id string, resources *runtimeapi.LinuxContainerResources) error
|
||||
UpdateContainerResources(id string, resources *runtimeapi.ContainerResources) error
|
||||
}
|
||||
|
||||
type sourcesReadyStub struct{}
|
||||
|
@ -122,7 +122,7 @@ type mockRuntimeService struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func (rt mockRuntimeService) UpdateContainerResources(id string, resources *runtimeapi.LinuxContainerResources) error {
|
||||
func (rt mockRuntimeService) UpdateContainerResources(id string, resources *runtimeapi.ContainerResources) error {
|
||||
return rt.err
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ func (f *RemoteRuntime) Status(ctx context.Context, req *kubeapi.StatusRequest)
|
||||
|
||||
// UpdateContainerResources updates ContainerConfig of the container.
|
||||
func (f *RemoteRuntime) UpdateContainerResources(ctx context.Context, req *kubeapi.UpdateContainerResourcesRequest) (*kubeapi.UpdateContainerResourcesResponse, error) {
|
||||
err := f.RuntimeService.UpdateContainerResources(req.ContainerId, req.Linux)
|
||||
err := f.RuntimeService.UpdateContainerResources(req.ContainerId, &kubeapi.ContainerResources{Linux: req.Linux})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -641,7 +641,7 @@ func (r *remoteRuntimeService) containerStatusV1(ctx context.Context, containerI
|
||||
}
|
||||
|
||||
// UpdateContainerResources updates a containers resource config
|
||||
func (r *remoteRuntimeService) UpdateContainerResources(containerID string, resources *runtimeapi.LinuxContainerResources) (err error) {
|
||||
func (r *remoteRuntimeService) UpdateContainerResources(containerID string, resources *runtimeapi.ContainerResources) (err error) {
|
||||
klog.V(10).InfoS("[RemoteRuntimeService] UpdateContainerResources", "containerID", containerID, "timeout", r.timeout)
|
||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||
defer cancel()
|
||||
@ -649,12 +649,13 @@ func (r *remoteRuntimeService) UpdateContainerResources(containerID string, reso
|
||||
if r.useV1API() {
|
||||
_, err = r.runtimeClient.UpdateContainerResources(ctx, &runtimeapi.UpdateContainerResourcesRequest{
|
||||
ContainerId: containerID,
|
||||
Linux: resources,
|
||||
Linux: resources.GetLinux(),
|
||||
Windows: resources.GetWindows(),
|
||||
})
|
||||
} else {
|
||||
_, err = r.runtimeClientV1alpha2.UpdateContainerResources(ctx, &runtimeapiV1alpha2.UpdateContainerResourcesRequest{
|
||||
ContainerId: containerID,
|
||||
Linux: v1alpha2LinuxContainerResources(resources),
|
||||
Linux: v1alpha2LinuxContainerResources(resources.GetLinux()),
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
|
@ -131,7 +131,7 @@ func (in instrumentedRuntimeService) ContainerStatus(containerID string, verbose
|
||||
return out, err
|
||||
}
|
||||
|
||||
func (in instrumentedRuntimeService) UpdateContainerResources(containerID string, resources *runtimeapi.LinuxContainerResources) error {
|
||||
func (in instrumentedRuntimeService) UpdateContainerResources(containerID string, resources *runtimeapi.ContainerResources) error {
|
||||
const operation = "update_container"
|
||||
defer recordOperation(operation, time.Now())
|
||||
|
||||
|
@ -79,7 +79,8 @@ service RuntimeService {
|
||||
// ContainerStatus returns status of the container. If the container is not
|
||||
// present, returns an error.
|
||||
rpc ContainerStatus(ContainerStatusRequest) returns (ContainerStatusResponse) {}
|
||||
// UpdateContainerResources updates ContainerConfig of the container.
|
||||
// UpdateContainerResources updates ContainerConfig of the container synchronously.
|
||||
// If runtime fails to transactionally update the requested resources, an error is returned.
|
||||
rpc UpdateContainerResources(UpdateContainerResourcesRequest) returns (UpdateContainerResourcesResponse) {}
|
||||
// ReopenContainerLog asks runtime to reopen the stdout/stderr log file
|
||||
// for the container. This is often called after the log file has been
|
||||
@ -1158,6 +1159,8 @@ message ContainerStatus {
|
||||
repeated Mount mounts = 14;
|
||||
// Log path of container.
|
||||
string log_path = 15;
|
||||
// Resource limits configuration of the container.
|
||||
ContainerResources resources = 16;
|
||||
}
|
||||
|
||||
message ContainerStatusResponse {
|
||||
@ -1170,6 +1173,14 @@ message ContainerStatusResponse {
|
||||
map<string, string> info = 2;
|
||||
}
|
||||
|
||||
// ContainerResources holds resource limits configuration for a container.
|
||||
message ContainerResources {
|
||||
// Resource limits configuration specific to Linux container.
|
||||
LinuxContainerResources linux = 1;
|
||||
// Resource limits configuration specific to Windows container.
|
||||
WindowsContainerResources windows = 2;
|
||||
}
|
||||
|
||||
message UpdateContainerResourcesRequest {
|
||||
// ID of the container to update.
|
||||
string container_id = 1;
|
||||
|
@ -79,7 +79,8 @@ service RuntimeService {
|
||||
// ContainerStatus returns status of the container. If the container is not
|
||||
// present, returns an error.
|
||||
rpc ContainerStatus(ContainerStatusRequest) returns (ContainerStatusResponse) {}
|
||||
// UpdateContainerResources updates ContainerConfig of the container.
|
||||
// UpdateContainerResources updates ContainerConfig of the container synchronously.
|
||||
// If runtime fails to transactionally update the requested resources, an error is returned.
|
||||
rpc UpdateContainerResources(UpdateContainerResourcesRequest) returns (UpdateContainerResourcesResponse) {}
|
||||
// ReopenContainerLog asks runtime to reopen the stdout/stderr log file
|
||||
// for the container. This is often called after the log file has been
|
||||
@ -1151,6 +1152,8 @@ message ContainerStatus {
|
||||
repeated Mount mounts = 14;
|
||||
// Log path of container.
|
||||
string log_path = 15;
|
||||
// Resource limits configuration of the container.
|
||||
ContainerResources resources = 16;
|
||||
}
|
||||
|
||||
message ContainerStatusResponse {
|
||||
@ -1163,6 +1166,14 @@ message ContainerStatusResponse {
|
||||
map<string, string> info = 2;
|
||||
}
|
||||
|
||||
// ContainerResources holds resource limits configuration for a container.
|
||||
message ContainerResources {
|
||||
// Resource limits configuration specific to Linux container.
|
||||
LinuxContainerResources linux = 1;
|
||||
// Resource limits configuration specific to Windows container.
|
||||
WindowsContainerResources windows = 2;
|
||||
}
|
||||
|
||||
message UpdateContainerResourcesRequest {
|
||||
// ID of the container to update.
|
||||
string container_id = 1;
|
||||
|
@ -43,8 +43,9 @@ type ContainerManager interface {
|
||||
ListContainers(filter *runtimeapi.ContainerFilter) ([]*runtimeapi.Container, error)
|
||||
// ContainerStatus returns the status of the container.
|
||||
ContainerStatus(containerID string, verbose bool) (*runtimeapi.ContainerStatusResponse, error)
|
||||
// UpdateContainerResources updates the cgroup resources for the container.
|
||||
UpdateContainerResources(containerID string, resources *runtimeapi.LinuxContainerResources) error
|
||||
// UpdateContainerResources updates ContainerConfig of the container synchronously.
|
||||
// If runtime fails to transactionally update the requested resources, an error is returned.
|
||||
UpdateContainerResources(containerID string, resources *runtimeapi.ContainerResources) error
|
||||
// ExecSync executes a command in the container, and returns the stdout output.
|
||||
// If command exits with a non-zero exit code, an error is returned.
|
||||
ExecSync(containerID string, cmd []string, timeout time.Duration) (stdout []byte, stderr []byte, err error)
|
||||
|
@ -509,7 +509,7 @@ func (r *FakeRuntimeService) ContainerStatus(containerID string, verbose bool) (
|
||||
}
|
||||
|
||||
// UpdateContainerResources returns the container resource in the FakeRuntimeService.
|
||||
func (r *FakeRuntimeService) UpdateContainerResources(string, *runtimeapi.LinuxContainerResources) error {
|
||||
func (r *FakeRuntimeService) UpdateContainerResources(string, *runtimeapi.ContainerResources) error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user