Skip to content

Commit

Permalink
InPlace Pod Vertical Scaling feature - review fixes, initial e2e tests
Browse files Browse the repository at this point in the history
1. Add framework code for e2e testing, and example e2e tests.
2. Do container resource update based on difference between requests as well as limits.
KEP: /enhancements/keps/sig-node/20181106-in-place-update-of-pod-resources.md
  • Loading branch information
vinaykul committed Jun 30, 2020
1 parent 5daa103 commit 426d0bb
Show file tree
Hide file tree
Showing 6 changed files with 459 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/kubelet/cm/cgroup_manager_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"
"path"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
Expand Down
1 change: 1 addition & 0 deletions pkg/kubelet/cm/helpers_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
MilliCPUToCPU = 0

MinQuotaPeriod = 0
QuotaPeriod = 0
)

// MilliCPUToQuota converts milliCPU and period to CFS quota values.
Expand Down
6 changes: 5 additions & 1 deletion pkg/kubelet/kuberuntime/kuberuntime_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,12 +633,16 @@ func (m *kubeGenericRuntimeManager) computePodActions(pod *v1.Pod, podStatus *ku
if container.Resources.Limits == nil || len(pod.Status.ContainerStatuses) == 0 {
continue
}
// Determine if the *running* container needs resource update by comparing Spec.Resources (desired)
// with Status.Resources (last known actual). This check is done when kubelet has accepted the
// resize a.k.a Resources.Requests == ResourcesAllocated.
// Skip if runtime container ID does not match pod.Status containerID as container may be restarting
apiContainerStatus, exists := podutil.GetContainerStatus(pod.Status.ContainerStatuses, container.Name)
if !exists || apiContainerStatus.State.Running == nil ||
containerStatus.State != kubecontainer.ContainerStateRunning ||
containerStatus.ID.String() != apiContainerStatus.ContainerID ||
len(diff.ObjectDiff(container.Resources.Requests, container.ResourcesAllocated)) != 0 ||
len(diff.ObjectDiff(apiContainerStatus.Resources.Limits, container.Resources.Limits)) == 0 {
len(diff.ObjectDiff(apiContainerStatus.Resources, container.Resources)) == 0 {
continue
}
resizePolicy := make(map[v1.ResourceName]v1.ContainerResizePolicy)
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ go_library(
"lifecycle_hook.go",
"networking.go",
"node_lease.go",
"pod_resize.go",
"pods.go",
"podtemplates.go",
"privileged.go",
Expand All @@ -46,6 +47,7 @@ go_library(
"//pkg/api/v1/pod:go_default_library",
"//pkg/client/conditions:go_default_library",
"//pkg/kubelet:go_default_library",
"//pkg/kubelet/cm:go_default_library",
"//pkg/kubelet/events:go_default_library",
"//pkg/kubelet/images:go_default_library",
"//pkg/kubelet/runtimeclass/testing:go_default_library",
Expand All @@ -67,10 +69,12 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//staging/src/k8s.io/client-go/dynamic:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
"//staging/src/k8s.io/client-go/tools/watch:go_default_library",
"//staging/src/k8s.io/component-base/featuregate:go_default_library",
"//test/e2e/framework:go_default_library",
"//test/e2e/framework/events:go_default_library",
"//test/e2e/framework/network:go_default_library",
Expand Down
Loading

0 comments on commit 426d0bb

Please sign in to comment.