Skip to content

Commit

Permalink
Merge pull request kubernetes#111645 from vinaykul/restart-free-pod-v…
Browse files Browse the repository at this point in the history
…ertical-scaling-cri

CRI changes to support in-place pod resize
  • Loading branch information
k8s-ci-robot committed Aug 3, 2022
2 parents 83c3c37 + 09fb5da commit aea9f98
Show file tree
Hide file tree
Showing 14 changed files with 1,552 additions and 877 deletions.
8 changes: 5 additions & 3 deletions pkg/kubelet/cm/cpumanager/cpu_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
},
})
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/cm/cpumanager/cpu_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/cm/memorymanager/memory_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/cm/memorymanager/memory_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/kubelet/cri/remote/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func v1alpha2LinuxContainerResources(from *runtimeapi.LinuxContainerResources) *
return (*v1alpha2.LinuxContainerResources)(unsafe.Pointer(from))
}

func v1alpha2WindowsContainerResources(from *runtimeapi.WindowsContainerResources) *v1alpha2.WindowsContainerResources {
return (*v1alpha2.WindowsContainerResources)(unsafe.Pointer(from))
}

func v1alpha2ExecRequest(from *runtimeapi.ExecRequest) *v1alpha2.ExecRequest {
// If this function changes, also adapt the corresponding Exec code in
// pkg/kubelet/cri/remote/remote_runtime.go
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/cri/remote/fake/fake_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/kubelet/cri/remote/remote_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,20 +641,22 @@ 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()

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()),
Windows: v1alpha2WindowsContainerResources(resources.GetWindows()),
})
}
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/kuberuntime/instrumented_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit aea9f98

Please sign in to comment.