Merge pull request #116119 from vinaykul/restart-free-pod-vertical-scaling-fixes

Restructure resize policy naming and set default resize policy values
This commit is contained in:
Kubernetes Prow Robot 2023-03-14 19:26:42 -07:00 committed by GitHub
commit 9053b5dc2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
78 changed files with 1253 additions and 1228 deletions

View File

@ -5007,20 +5007,20 @@
"type": "object"
},
"io.k8s.api.core.v1.ContainerResizePolicy": {
"description": "ContainerResizePolicy represents resource resize policy for a single container.",
"description": "ContainerResizePolicy represents resource resize policy for the container.",
"properties": {
"policy": {
"description": "Resource resize policy applicable to the specified resource name. If not specified, it defaults to RestartNotRequired.",
"resourceName": {
"description": "Name of the resource to which this resource resize policy applies. Supported values: cpu, memory.",
"type": "string"
},
"resourceName": {
"description": "Name of the resource type to which this resource resize policy applies. Supported values: cpu, memory.",
"restartPolicy": {
"description": "Restart policy to apply when specified resource is resized. If not specified, it defaults to NotRequired.",
"type": "string"
}
},
"required": [
"resourceName",
"policy"
"restartPolicy"
],
"type": "object"
},

View File

@ -1306,22 +1306,22 @@
"type": "object"
},
"io.k8s.api.core.v1.ContainerResizePolicy": {
"description": "ContainerResizePolicy represents resource resize policy for a single container.",
"description": "ContainerResizePolicy represents resource resize policy for the container.",
"properties": {
"policy": {
"default": "",
"description": "Resource resize policy applicable to the specified resource name. If not specified, it defaults to RestartNotRequired.",
"type": "string"
},
"resourceName": {
"default": "",
"description": "Name of the resource type to which this resource resize policy applies. Supported values: cpu, memory.",
"description": "Name of the resource to which this resource resize policy applies. Supported values: cpu, memory.",
"type": "string"
},
"restartPolicy": {
"default": "",
"description": "Restart policy to apply when specified resource is resized. If not specified, it defaults to NotRequired.",
"type": "string"
}
},
"required": [
"resourceName",
"policy"
"restartPolicy"
],
"type": "object"
},

View File

@ -1910,22 +1910,22 @@
"type": "object"
},
"io.k8s.api.core.v1.ContainerResizePolicy": {
"description": "ContainerResizePolicy represents resource resize policy for a single container.",
"description": "ContainerResizePolicy represents resource resize policy for the container.",
"properties": {
"policy": {
"default": "",
"description": "Resource resize policy applicable to the specified resource name. If not specified, it defaults to RestartNotRequired.",
"type": "string"
},
"resourceName": {
"default": "",
"description": "Name of the resource type to which this resource resize policy applies. Supported values: cpu, memory.",
"description": "Name of the resource to which this resource resize policy applies. Supported values: cpu, memory.",
"type": "string"
},
"restartPolicy": {
"default": "",
"description": "Restart policy to apply when specified resource is resized. If not specified, it defaults to NotRequired.",
"type": "string"
}
},
"required": [
"resourceName",
"policy"
"restartPolicy"
],
"type": "object"
},

View File

@ -1201,22 +1201,22 @@
"type": "object"
},
"io.k8s.api.core.v1.ContainerResizePolicy": {
"description": "ContainerResizePolicy represents resource resize policy for a single container.",
"description": "ContainerResizePolicy represents resource resize policy for the container.",
"properties": {
"policy": {
"default": "",
"description": "Resource resize policy applicable to the specified resource name. If not specified, it defaults to RestartNotRequired.",
"type": "string"
},
"resourceName": {
"default": "",
"description": "Name of the resource type to which this resource resize policy applies. Supported values: cpu, memory.",
"description": "Name of the resource to which this resource resize policy applies. Supported values: cpu, memory.",
"type": "string"
},
"restartPolicy": {
"default": "",
"description": "Restart policy to apply when specified resource is resized. If not specified, it defaults to NotRequired.",
"type": "string"
}
},
"required": [
"resourceName",
"policy"
"restartPolicy"
],
"type": "object"
},

View File

@ -2290,8 +2290,8 @@ func TestDropInPlacePodVerticalScaling(t *testing.T) {
Limits: api.ResourceList{api.ResourceCPU: resource.MustParse("200m")},
},
ResizePolicy: []api.ContainerResizePolicy{
{ResourceName: api.ResourceCPU, Policy: api.RestartNotRequired},
{ResourceName: api.ResourceMemory, Policy: api.RestartRequired},
{ResourceName: api.ResourceCPU, RestartPolicy: api.NotRequired},
{ResourceName: api.ResourceMemory, RestartPolicy: api.RestartContainer},
},
},
},

View File

@ -2139,31 +2139,31 @@ const (
PullIfNotPresent PullPolicy = "IfNotPresent"
)
// ResourceResizePolicy specifies how Kubernetes should handle resource resize.
type ResourceResizePolicy string
// ResourceResizeRestartPolicy specifies how to handle container resource resize.
type ResourceResizeRestartPolicy string
// These are the valid resource resize policy values:
// These are the valid resource resize restart policy values:
const (
// RestartNotRequired tells Kubernetes to resize the container in-place
// 'NotRequired' means Kubernetes will try to resize the container
// without restarting it, if possible. Kubernetes may however choose to
// restart the container if it is unable to actuate resize without a
// restart. For e.g. the runtime doesn't support restart-free resizing.
RestartNotRequired ResourceResizePolicy = "RestartNotRequired"
// 'RestartRequired' tells Kubernetes to resize the container in-place
NotRequired ResourceResizeRestartPolicy = "NotRequired"
// 'RestartContainer' means Kubernetes will resize the container in-place
// by stopping and starting the container when new resources are applied.
// This is needed for legacy applications. For e.g. java apps using the
// -xmxN flag which are unable to use resized memory without restarting.
RestartRequired ResourceResizePolicy = "RestartRequired"
RestartContainer ResourceResizeRestartPolicy = "RestartContainer"
)
// ContainerResizePolicy represents resource resize policy for a single container.
// ContainerResizePolicy represents resource resize policy for the container.
type ContainerResizePolicy struct {
// Name of the resource type to which this resource resize policy applies.
// Name of the resource to which this resource resize policy applies.
// Supported values: cpu, memory.
ResourceName ResourceName
// Resource resize policy applicable to the specified resource name.
// If not specified, it defaults to RestartNotRequired.
Policy ResourceResizePolicy
// Restart policy to apply when specified resource is resized.
// If not specified, it defaults to NotRequired.
RestartPolicy ResourceResizeRestartPolicy
}
// PreemptionPolicy describes a policy for if/when to preempt a pod.

View File

@ -22,6 +22,8 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/util/parsers"
"k8s.io/utils/pointer"
)
@ -157,6 +159,29 @@ func SetDefaults_Pod(obj *v1.Pod) {
}
}
}
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) &&
obj.Spec.Containers[i].Resources.Requests != nil {
// For normal containers, set resize restart policy to default value (NotRequired), if not specified.
resizePolicySpecified := make(map[v1.ResourceName]bool)
for _, p := range obj.Spec.Containers[i].ResizePolicy {
resizePolicySpecified[p.ResourceName] = true
}
setDefaultResizePolicy := func(resourceName v1.ResourceName) {
if _, found := resizePolicySpecified[resourceName]; !found {
obj.Spec.Containers[i].ResizePolicy = append(obj.Spec.Containers[i].ResizePolicy,
v1.ContainerResizePolicy{
ResourceName: resourceName,
RestartPolicy: v1.NotRequired,
})
}
}
if _, exists := obj.Spec.Containers[i].Resources.Requests[v1.ResourceCPU]; exists {
setDefaultResizePolicy(v1.ResourceCPU)
}
if _, exists := obj.Spec.Containers[i].Resources.Requests[v1.ResourceMemory]; exists {
setDefaultResizePolicy(v1.ResourceMemory)
}
}
}
for i := range obj.Spec.InitContainers {
if obj.Spec.InitContainers[i].Resources.Limits != nil {

View File

@ -3093,7 +3093,7 @@ func Convert_core_ContainerPort_To_v1_ContainerPort(in *core.ContainerPort, out
func autoConvert_v1_ContainerResizePolicy_To_core_ContainerResizePolicy(in *v1.ContainerResizePolicy, out *core.ContainerResizePolicy, s conversion.Scope) error {
out.ResourceName = core.ResourceName(in.ResourceName)
out.Policy = core.ResourceResizePolicy(in.Policy)
out.RestartPolicy = core.ResourceResizeRestartPolicy(in.RestartPolicy)
return nil
}
@ -3104,7 +3104,7 @@ func Convert_v1_ContainerResizePolicy_To_core_ContainerResizePolicy(in *v1.Conta
func autoConvert_core_ContainerResizePolicy_To_v1_ContainerResizePolicy(in *core.ContainerResizePolicy, out *v1.ContainerResizePolicy, s conversion.Scope) error {
out.ResourceName = v1.ResourceName(in.ResourceName)
out.Policy = v1.ResourceResizePolicy(in.Policy)
out.RestartPolicy = v1.ResourceResizeRestartPolicy(in.RestartPolicy)
return nil
}

View File

@ -3042,7 +3042,7 @@ func validatePullPolicy(policy core.PullPolicy, fldPath *field.Path) field.Error
}
var supportedResizeResources = sets.NewString(string(core.ResourceCPU), string(core.ResourceMemory))
var supportedResizePolicies = sets.NewString(string(core.RestartNotRequired), string(core.RestartRequired))
var supportedResizePolicies = sets.NewString(string(core.NotRequired), string(core.RestartContainer))
func validateResizePolicy(policyList []core.ContainerResizePolicy, fldPath *field.Path) field.ErrorList {
allErrors := field.ErrorList{}
@ -3061,12 +3061,12 @@ func validateResizePolicy(policyList []core.ContainerResizePolicy, fldPath *fiel
default:
allErrors = append(allErrors, field.NotSupported(fldPath, p.ResourceName, supportedResizeResources.List()))
}
switch p.Policy {
case core.RestartNotRequired, core.RestartRequired:
switch p.RestartPolicy {
case core.NotRequired, core.RestartContainer:
case "":
allErrors = append(allErrors, field.Required(fldPath, ""))
default:
allErrors = append(allErrors, field.NotSupported(fldPath, p.Policy, supportedResizePolicies.List()))
allErrors = append(allErrors, field.NotSupported(fldPath, p.RestartPolicy, supportedResizePolicies.List()))
}
}
return allErrors

View File

@ -7009,7 +7009,7 @@ func TestValidatePullPolicy(t *testing.T) {
func TestValidateResizePolicy(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.InPlacePodVerticalScaling, true)()
tSupportedResizeResources := sets.NewString(string(core.ResourceCPU), string(core.ResourceMemory))
tSupportedResizePolicies := sets.NewString(string(core.RestartNotRequired), string(core.RestartRequired))
tSupportedResizePolicies := sets.NewString(string(core.NotRequired), string(core.RestartContainer))
type T struct {
PolicyList []core.ContainerResizePolicy
ExpectError bool
@ -7018,22 +7018,22 @@ func TestValidateResizePolicy(t *testing.T) {
testCases := map[string]T{
"ValidCPUandMemoryPolicies": {
[]core.ContainerResizePolicy{
{ResourceName: "cpu", Policy: "RestartNotRequired"},
{ResourceName: "memory", Policy: "RestartRequired"},
{ResourceName: "cpu", RestartPolicy: "NotRequired"},
{ResourceName: "memory", RestartPolicy: "RestartContainer"},
},
false,
nil,
},
"ValidCPUPolicy": {
[]core.ContainerResizePolicy{
{ResourceName: "cpu", Policy: "RestartRequired"},
{ResourceName: "cpu", RestartPolicy: "RestartContainer"},
},
false,
nil,
},
"ValidMemoryPolicy": {
[]core.ContainerResizePolicy{
{ResourceName: "memory", Policy: "RestartNotRequired"},
{ResourceName: "memory", RestartPolicy: "NotRequired"},
},
false,
nil,
@ -7045,39 +7045,39 @@ func TestValidateResizePolicy(t *testing.T) {
},
"ValidCPUandInvalidMemoryPolicy": {
[]core.ContainerResizePolicy{
{ResourceName: "cpu", Policy: "RestartNotRequired"},
{ResourceName: "memory", Policy: "Restarrrt"},
{ResourceName: "cpu", RestartPolicy: "NotRequired"},
{ResourceName: "memory", RestartPolicy: "Restarrrt"},
},
true,
field.ErrorList{field.NotSupported(field.NewPath("field"), core.ResourceResizePolicy("Restarrrt"), tSupportedResizePolicies.List())},
field.ErrorList{field.NotSupported(field.NewPath("field"), core.ResourceResizeRestartPolicy("Restarrrt"), tSupportedResizePolicies.List())},
},
"ValidMemoryandInvalidCPUPolicy": {
[]core.ContainerResizePolicy{
{ResourceName: "cpu", Policy: "RestartNotRequirrred"},
{ResourceName: "memory", Policy: "RestartRequired"},
{ResourceName: "cpu", RestartPolicy: "RestartNotRequirrred"},
{ResourceName: "memory", RestartPolicy: "RestartContainer"},
},
true,
field.ErrorList{field.NotSupported(field.NewPath("field"), core.ResourceResizePolicy("RestartNotRequirrred"), tSupportedResizePolicies.List())},
field.ErrorList{field.NotSupported(field.NewPath("field"), core.ResourceResizeRestartPolicy("RestartNotRequirrred"), tSupportedResizePolicies.List())},
},
"InvalidResourceNameValidPolicy": {
[]core.ContainerResizePolicy{
{ResourceName: "cpuuu", Policy: "RestartNotRequired"},
{ResourceName: "cpuuu", RestartPolicy: "NotRequired"},
},
true,
field.ErrorList{field.NotSupported(field.NewPath("field"), core.ResourceName("cpuuu"), tSupportedResizeResources.List())},
},
"ValidResourceNameMissingPolicy": {
[]core.ContainerResizePolicy{
{ResourceName: "memory", Policy: ""},
{ResourceName: "memory", RestartPolicy: ""},
},
true,
field.ErrorList{field.Required(field.NewPath("field"), "")},
},
"RepeatedPolicies": {
[]core.ContainerResizePolicy{
{ResourceName: "cpu", Policy: "RestartNotRequired"},
{ResourceName: "memory", Policy: "RestartRequired"},
{ResourceName: "cpu", Policy: "RestartRequired"},
{ResourceName: "cpu", RestartPolicy: "NotRequired"},
{ResourceName: "memory", RestartPolicy: "RestartContainer"},
{ResourceName: "cpu", RestartPolicy: "RestartContainer"},
},
true,
field.ErrorList{field.Duplicate(field.NewPath("field").Index(2), core.ResourceCPU)},
@ -7475,7 +7475,7 @@ func TestValidateEphemeralContainers(t *testing.T) {
ImagePullPolicy: "IfNotPresent",
TerminationMessagePolicy: "File",
ResizePolicy: []core.ContainerResizePolicy{
{ResourceName: "cpu", Policy: "RestartNotRequired"},
{ResourceName: "cpu", RestartPolicy: "NotRequired"},
},
},
},
@ -7702,8 +7702,8 @@ func TestValidateContainers(t *testing.T) {
Name: "resources-resize-policy",
Image: "image",
ResizePolicy: []core.ContainerResizePolicy{
{ResourceName: "cpu", Policy: "RestartNotRequired"},
{ResourceName: "memory", Policy: "RestartRequired"},
{ResourceName: "cpu", RestartPolicy: "NotRequired"},
{ResourceName: "memory", RestartPolicy: "RestartContainer"},
},
ImagePullPolicy: "IfNotPresent",
TerminationMessagePolicy: "File",
@ -9477,7 +9477,7 @@ func TestValidatePodSpec(t *testing.T) {
Name: "initctr",
Image: "initimage",
ResizePolicy: []core.ContainerResizePolicy{
{ResourceName: "cpu", Policy: "RestartNotRequired"},
{ResourceName: "cpu", RestartPolicy: "NotRequired"},
},
ImagePullPolicy: "IfNotPresent",
TerminationMessagePolicy: "File",
@ -9488,7 +9488,7 @@ func TestValidatePodSpec(t *testing.T) {
Name: "ctr",
Image: "image",
ResizePolicy: []core.ContainerResizePolicy{
{ResourceName: "cpu", Policy: "RestartNotRequired"},
{ResourceName: "cpu", RestartPolicy: "NotRequired"},
},
ImagePullPolicy: "IfNotPresent",
TerminationMessagePolicy: "File",
@ -20473,7 +20473,7 @@ func TestValidateOSFields(t *testing.T) {
"Containers[*].Ports",
"Containers[*].ReadinessProbe",
"Containers[*].Resources",
"Containers[*].ResizePolicy[*].Policy",
"Containers[*].ResizePolicy[*].RestartPolicy",
"Containers[*].ResizePolicy[*].ResourceName",
"Containers[*].SecurityContext.RunAsNonRoot",
"Containers[*].Stdin",
@ -20499,7 +20499,7 @@ func TestValidateOSFields(t *testing.T) {
"EphemeralContainers[*].EphemeralContainerCommon.Ports",
"EphemeralContainers[*].EphemeralContainerCommon.ReadinessProbe",
"EphemeralContainers[*].EphemeralContainerCommon.Resources",
"EphemeralContainers[*].EphemeralContainerCommon.ResizePolicy[*].Policy",
"EphemeralContainers[*].EphemeralContainerCommon.ResizePolicy[*].RestartPolicy",
"EphemeralContainers[*].EphemeralContainerCommon.ResizePolicy[*].ResourceName",
"EphemeralContainers[*].EphemeralContainerCommon.Stdin",
"EphemeralContainers[*].EphemeralContainerCommon.StdinOnce",
@ -20527,7 +20527,7 @@ func TestValidateOSFields(t *testing.T) {
"InitContainers[*].Ports",
"InitContainers[*].ReadinessProbe",
"InitContainers[*].Resources",
"InitContainers[*].ResizePolicy[*].Policy",
"InitContainers[*].ResizePolicy[*].RestartPolicy",
"InitContainers[*].ResizePolicy[*].ResourceName",
"InitContainers[*].Stdin",
"InitContainers[*].StdinOnce",

View File

@ -17535,27 +17535,27 @@ func schema_k8sio_api_core_v1_ContainerResizePolicy(ref common.ReferenceCallback
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ContainerResizePolicy represents resource resize policy for a single container.",
Description: "ContainerResizePolicy represents resource resize policy for the container.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"resourceName": {
SchemaProps: spec.SchemaProps{
Description: "Name of the resource type to which this resource resize policy applies. Supported values: cpu, memory.",
Description: "Name of the resource to which this resource resize policy applies. Supported values: cpu, memory.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"policy": {
"restartPolicy": {
SchemaProps: spec.SchemaProps{
Description: "Resource resize policy applicable to the specified resource name. If not specified, it defaults to RestartNotRequired.",
Description: "Restart policy to apply when specified resource is resized. If not specified, it defaults to NotRequired.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"resourceName", "policy"},
Required: []string{"resourceName", "restartPolicy"},
},
},
}

View File

@ -915,10 +915,10 @@ func TestHashContainerWithoutResources(t *testing.T) {
cpu200m := resource.MustParse("200m")
mem100M := resource.MustParse("100Mi")
mem200M := resource.MustParse("200Mi")
cpuPolicyRestartNotRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceCPU, Policy: v1.RestartNotRequired}
memPolicyRestartNotRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceMemory, Policy: v1.RestartNotRequired}
cpuPolicyRestartRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceCPU, Policy: v1.RestartRequired}
memPolicyRestartRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceMemory, Policy: v1.RestartRequired}
cpuPolicyRestartNotRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceCPU, RestartPolicy: v1.NotRequired}
memPolicyRestartNotRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceMemory, RestartPolicy: v1.NotRequired}
cpuPolicyRestartRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceCPU, RestartPolicy: v1.RestartContainer}
memPolicyRestartRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceMemory, RestartPolicy: v1.RestartContainer}
type testCase struct {
name string
@ -938,7 +938,7 @@ func TestHashContainerWithoutResources(t *testing.T) {
},
ResizePolicy: []v1.ContainerResizePolicy{cpuPolicyRestartRequired, memPolicyRestartNotRequired},
},
0x86a4393c,
0x5f62cb4c,
},
{
"Burstable pod with memory policy restart required",
@ -951,7 +951,7 @@ func TestHashContainerWithoutResources(t *testing.T) {
},
ResizePolicy: []v1.ContainerResizePolicy{cpuPolicyRestartNotRequired, memPolicyRestartRequired},
},
0x73a18cce,
0xcdab9e00,
},
{
"Guaranteed pod with CPU policy restart required",
@ -964,7 +964,7 @@ func TestHashContainerWithoutResources(t *testing.T) {
},
ResizePolicy: []v1.ContainerResizePolicy{cpuPolicyRestartRequired, memPolicyRestartNotRequired},
},
0x86a4393c,
0x5f62cb4c,
},
{
"Guaranteed pod with memory policy restart required",
@ -977,7 +977,7 @@ func TestHashContainerWithoutResources(t *testing.T) {
},
ResizePolicy: []v1.ContainerResizePolicy{cpuPolicyRestartNotRequired, memPolicyRestartRequired},
},
0x73a18cce,
0xcdab9e00,
},
}
for _, tc := range tests {

View File

@ -585,15 +585,15 @@ func (m *kubeGenericRuntimeManager) computePodResizeAction(pod *v1.Pod, containe
cpuRequest: currentCPURequest,
}
resizePolicy := make(map[v1.ResourceName]v1.ResourceResizePolicy)
resizePolicy := make(map[v1.ResourceName]v1.ResourceResizeRestartPolicy)
for _, pol := range container.ResizePolicy {
resizePolicy[pol.ResourceName] = pol.Policy
resizePolicy[pol.ResourceName] = pol.RestartPolicy
}
determineContainerResize := func(rName v1.ResourceName, specValue, statusValue int64) (resize, restart bool) {
if specValue == statusValue {
return false, false
}
if resizePolicy[rName] == v1.RestartRequired {
if resizePolicy[rName] == v1.RestartContainer {
return true, true
}
return true, false

View File

@ -1655,10 +1655,10 @@ func TestComputePodActionsForPodResize(t *testing.T) {
cpu200m := resource.MustParse("200m")
mem100M := resource.MustParse("100Mi")
mem200M := resource.MustParse("200Mi")
cpuPolicyRestartNotRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceCPU, Policy: v1.RestartNotRequired}
memPolicyRestartNotRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceMemory, Policy: v1.RestartNotRequired}
cpuPolicyRestartRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceCPU, Policy: v1.RestartRequired}
memPolicyRestartRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceMemory, Policy: v1.RestartRequired}
cpuPolicyRestartNotRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceCPU, RestartPolicy: v1.NotRequired}
memPolicyRestartNotRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceMemory, RestartPolicy: v1.NotRequired}
cpuPolicyRestartRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceCPU, RestartPolicy: v1.RestartContainer}
memPolicyRestartRequired := v1.ContainerResizePolicy{ResourceName: v1.ResourceMemory, RestartPolicy: v1.RestartContainer}
for desc, test := range map[string]struct {
podResizePolicyFn func(*v1.Pod)

File diff suppressed because it is too large Load Diff

View File

@ -869,15 +869,15 @@ message ContainerPort {
optional string hostIP = 5;
}
// ContainerResizePolicy represents resource resize policy for a single container.
// ContainerResizePolicy represents resource resize policy for the container.
message ContainerResizePolicy {
// Name of the resource type to which this resource resize policy applies.
// Name of the resource to which this resource resize policy applies.
// Supported values: cpu, memory.
optional string resourceName = 1;
// Resource resize policy applicable to the specified resource name.
// If not specified, it defaults to RestartNotRequired.
optional string policy = 2;
// Restart policy to apply when specified resource is resized.
// If not specified, it defaults to NotRequired.
optional string restartPolicy = 2;
}
// ContainerState holds a possible state of container.

View File

@ -2264,31 +2264,31 @@ const (
PullIfNotPresent PullPolicy = "IfNotPresent"
)
// ResourceResizePolicy specifies how Kubernetes should handle resource resize.
type ResourceResizePolicy string
// ResourceResizeRestartPolicy specifies how to handle container resource resize.
type ResourceResizeRestartPolicy string
// These are the valid resource resize policy values:
// These are the valid resource resize restart policy values:
const (
// RestartNotRequired tells Kubernetes to resize the container in-place
// 'NotRequired' means Kubernetes will try to resize the container
// without restarting it, if possible. Kubernetes may however choose to
// restart the container if it is unable to actuate resize without a
// restart. For e.g. the runtime doesn't support restart-free resizing.
RestartNotRequired ResourceResizePolicy = "RestartNotRequired"
// 'RestartRequired' tells Kubernetes to resize the container in-place
NotRequired ResourceResizeRestartPolicy = "NotRequired"
// 'RestartContainer' means Kubernetes will resize the container in-place
// by stopping and starting the container when new resources are applied.
// This is needed for legacy applications. For e.g. java apps using the
// -xmxN flag which are unable to use resized memory without restarting.
RestartRequired ResourceResizePolicy = "RestartRequired"
RestartContainer ResourceResizeRestartPolicy = "RestartContainer"
)
// ContainerResizePolicy represents resource resize policy for a single container.
// ContainerResizePolicy represents resource resize policy for the container.
type ContainerResizePolicy struct {
// Name of the resource type to which this resource resize policy applies.
// Name of the resource to which this resource resize policy applies.
// Supported values: cpu, memory.
ResourceName ResourceName `json:"resourceName" protobuf:"bytes,1,opt,name=resourceName,casttype=ResourceName"`
// Resource resize policy applicable to the specified resource name.
// If not specified, it defaults to RestartNotRequired.
Policy ResourceResizePolicy `json:"policy" protobuf:"bytes,2,opt,name=policy,casttype=ResourceResizePolicy"`
// Restart policy to apply when specified resource is resized.
// If not specified, it defaults to NotRequired.
RestartPolicy ResourceResizeRestartPolicy `json:"restartPolicy" protobuf:"bytes,2,opt,name=restartPolicy,casttype=ResourceResizeRestartPolicy"`
}
// PreemptionPolicy describes a policy for if/when to preempt a pod.

View File

@ -390,9 +390,9 @@ func (ContainerPort) SwaggerDoc() map[string]string {
}
var map_ContainerResizePolicy = map[string]string{
"": "ContainerResizePolicy represents resource resize policy for a single container.",
"resourceName": "Name of the resource type to which this resource resize policy applies. Supported values: cpu, memory.",
"policy": "Resource resize policy applicable to the specified resource name. If not specified, it defaults to RestartNotRequired.",
"": "ContainerResizePolicy represents resource resize policy for the container.",
"resourceName": "Name of the resource to which this resource resize policy applies. Supported values: cpu, memory.",
"restartPolicy": "Restart policy to apply when specified resource is resized. If not specified, it defaults to NotRequired.",
}
func (ContainerResizePolicy) SwaggerDoc() map[string]string {

View File

@ -554,7 +554,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -837,7 +837,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1120,7 +1120,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -313,8 +313,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -519,8 +519,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -727,8 +727,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -555,7 +555,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -838,7 +838,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1121,7 +1121,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -321,8 +321,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -527,8 +527,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -735,8 +735,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -556,7 +556,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -839,7 +839,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1122,7 +1122,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -313,8 +313,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -519,8 +519,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -727,8 +727,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -555,7 +555,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -838,7 +838,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1121,7 +1121,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -321,8 +321,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -527,8 +527,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -735,8 +735,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -555,7 +555,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -838,7 +838,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1121,7 +1121,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -323,8 +323,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -529,8 +529,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -737,8 +737,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -555,7 +555,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -838,7 +838,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1121,7 +1121,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -321,8 +321,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -527,8 +527,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -735,8 +735,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -554,7 +554,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -837,7 +837,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1120,7 +1120,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -313,8 +313,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -519,8 +519,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -727,8 +727,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -555,7 +555,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -838,7 +838,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1121,7 +1121,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -321,8 +321,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -527,8 +527,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -735,8 +735,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -556,7 +556,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -839,7 +839,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1122,7 +1122,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -313,8 +313,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -519,8 +519,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -727,8 +727,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -555,7 +555,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -838,7 +838,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1121,7 +1121,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -321,8 +321,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -527,8 +527,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -735,8 +735,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -628,7 +628,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -911,7 +911,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1194,7 +1194,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -365,8 +365,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -571,8 +571,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -779,8 +779,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -579,7 +579,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -862,7 +862,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1145,7 +1145,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -329,8 +329,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -535,8 +535,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -743,8 +743,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -628,7 +628,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -911,7 +911,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1194,7 +1194,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -365,8 +365,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -571,8 +571,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -779,8 +779,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -496,7 +496,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -779,7 +779,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1062,7 +1062,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -269,8 +269,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -475,8 +475,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -683,8 +683,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -539,7 +539,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -822,7 +822,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1105,7 +1105,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -302,8 +302,8 @@ template:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -508,8 +508,8 @@ template:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -716,8 +716,8 @@ template:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -545,7 +545,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -828,7 +828,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1111,7 +1111,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -307,8 +307,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -513,8 +513,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -721,8 +721,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -554,7 +554,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -837,7 +837,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1120,7 +1120,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -313,8 +313,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -519,8 +519,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -727,8 +727,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -555,7 +555,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -838,7 +838,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1121,7 +1121,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -323,8 +323,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -529,8 +529,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -737,8 +737,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -556,7 +556,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -839,7 +839,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [
@ -1122,7 +1122,7 @@
"resizePolicy": [
{
"resourceName": "resourceNameValue",
"policy": "policyValue"
"restartPolicy": "restartPolicyValue"
}
],
"volumeMounts": [

View File

@ -313,8 +313,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -519,8 +519,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue
@ -727,8 +727,8 @@ spec:
terminationGracePeriodSeconds: 7
timeoutSeconds: 3
resizePolicy:
- policy: policyValue
resourceName: resourceNameValue
- resourceName: resourceNameValue
restartPolicy: restartPolicyValue
resources:
claims:
- name: nameValue

View File

@ -25,8 +25,8 @@ import (
// ContainerResizePolicyApplyConfiguration represents an declarative configuration of the ContainerResizePolicy type for use
// with apply.
type ContainerResizePolicyApplyConfiguration struct {
ResourceName *v1.ResourceName `json:"resourceName,omitempty"`
Policy *v1.ResourceResizePolicy `json:"policy,omitempty"`
ResourceName *v1.ResourceName `json:"resourceName,omitempty"`
RestartPolicy *v1.ResourceResizeRestartPolicy `json:"restartPolicy,omitempty"`
}
// ContainerResizePolicyApplyConfiguration constructs an declarative configuration of the ContainerResizePolicy type for use with
@ -43,10 +43,10 @@ func (b *ContainerResizePolicyApplyConfiguration) WithResourceName(value v1.Reso
return b
}
// WithPolicy sets the Policy field in the declarative configuration to the given value
// WithRestartPolicy sets the RestartPolicy field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Policy field is set to the value of the last call.
func (b *ContainerResizePolicyApplyConfiguration) WithPolicy(value v1.ResourceResizePolicy) *ContainerResizePolicyApplyConfiguration {
b.Policy = &value
// If called multiple times, the RestartPolicy field is set to the value of the last call.
func (b *ContainerResizePolicyApplyConfiguration) WithRestartPolicy(value v1.ResourceResizeRestartPolicy) *ContainerResizePolicyApplyConfiguration {
b.RestartPolicy = &value
return b
}

View File

@ -4281,11 +4281,11 @@ var schemaYAML = typed.YAMLObject(`types:
- name: io.k8s.api.core.v1.ContainerResizePolicy
map:
fields:
- name: policy
- name: resourceName
type:
scalar: string
default: ""
- name: resourceName
- name: restartPolicy
type:
scalar: string
default: ""

View File

@ -74,8 +74,8 @@ type TestContainerInfo struct {
Name string
Resources *ContainerResources
Allocations *ContainerAllocations
CPUPolicy *v1.ResourceResizePolicy
MemPolicy *v1.ResourceResizePolicy
CPUPolicy *v1.ResourceResizeRestartPolicy
MemPolicy *v1.ResourceResizeRestartPolicy
RestartCount int32
}
@ -146,18 +146,18 @@ func getTestResourceInfo(tcInfo TestContainerInfo) (v1.ResourceRequirements, v1.
}
if tcInfo.CPUPolicy != nil {
cpuPol := v1.ContainerResizePolicy{ResourceName: v1.ResourceCPU, Policy: *tcInfo.CPUPolicy}
cpuPol := v1.ContainerResizePolicy{ResourceName: v1.ResourceCPU, RestartPolicy: *tcInfo.CPUPolicy}
resizePol = append(resizePol, cpuPol)
}
if tcInfo.MemPolicy != nil {
memPol := v1.ContainerResizePolicy{ResourceName: v1.ResourceMemory, Policy: *tcInfo.MemPolicy}
memPol := v1.ContainerResizePolicy{ResourceName: v1.ResourceMemory, RestartPolicy: *tcInfo.MemPolicy}
resizePol = append(resizePol, memPol)
}
return res, alloc, resizePol
}
func initDefaultResizePolicy(containers []TestContainerInfo) {
noRestart := v1.RestartNotRequired
noRestart := v1.NotRequired
setDefaultPolicy := func(ci *TestContainerInfo) {
if ci.CPUPolicy == nil {
ci.CPUPolicy = &noRestart
@ -500,8 +500,8 @@ func doPodResizeTests() {
expected []TestContainerInfo
}
noRestart := v1.RestartNotRequired
doRestart := v1.RestartRequired
noRestart := v1.NotRequired
doRestart := v1.RestartContainer
tests := []testCase{
{
name: "Guaranteed QoS pod, one container - increase CPU & memory",
@ -1010,7 +1010,7 @@ func doPodResizeTests() {
},
},
{
name: "Guaranteed QoS pod, one container - increase CPU (RestartNotRequired) & memory (RestartRequired)",
name: "Guaranteed QoS pod, one container - increase CPU (NotRequired) & memory (RestartContainer)",
containers: []TestContainerInfo{
{
Name: "c1",
@ -1033,7 +1033,7 @@ func doPodResizeTests() {
},
},
{
name: "Burstable QoS pod, one container - decrease CPU (RestartRequired) & memory (RestartNotRequired)",
name: "Burstable QoS pod, one container - decrease CPU (RestartContainer) & memory (NotRequired)",
containers: []TestContainerInfo{
{
Name: "c1",