mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Make in-place resize exclusion conditions (such as static pods) very obvious
This commit is contained in:
parent
1c7850c355
commit
5b2682ac04
@ -524,6 +524,16 @@ func containerSucceeded(c *v1.Container, podStatus *kubecontainer.PodStatus) boo
|
||||
return cStatus.ExitCode == 0
|
||||
}
|
||||
|
||||
func isInPlacePodVerticalScalingAllowed(pod *v1.Pod) bool {
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) {
|
||||
return false
|
||||
}
|
||||
if types.IsStaticPod(pod) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (m *kubeGenericRuntimeManager) computePodResizeAction(pod *v1.Pod, containerIdx int, kubeContainerStatus *kubecontainer.Status, changes *podActions) bool {
|
||||
container := pod.Spec.Containers[containerIdx]
|
||||
if container.Resources.Limits == nil || len(pod.Status.ContainerStatuses) == 0 {
|
||||
@ -885,7 +895,7 @@ func (m *kubeGenericRuntimeManager) computePodActions(ctx context.Context, pod *
|
||||
return changes
|
||||
}
|
||||
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) {
|
||||
if isInPlacePodVerticalScalingAllowed(pod) {
|
||||
changes.ContainersToUpdate = make(map[v1.ResourceName][]containerToUpdateInfo)
|
||||
latestPodStatus, err := m.GetPodStatus(ctx, podStatus.ID, pod.Name, pod.Namespace)
|
||||
if err == nil {
|
||||
@ -950,9 +960,7 @@ func (m *kubeGenericRuntimeManager) computePodActions(ctx context.Context, pod *
|
||||
// If the container failed the startup probe, we should kill it.
|
||||
message = fmt.Sprintf("Container %s failed startup probe", container.Name)
|
||||
reason = reasonStartupProbe
|
||||
} else if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) &&
|
||||
!types.IsStaticPod(pod) &&
|
||||
!m.computePodResizeAction(pod, idx, containerStatus, &changes) {
|
||||
} else if isInPlacePodVerticalScalingAllowed(pod) && !m.computePodResizeAction(pod, idx, containerStatus, &changes) {
|
||||
// computePodResizeAction updates 'changes' if resize policy requires restarting this container
|
||||
continue
|
||||
} else {
|
||||
@ -1224,7 +1232,7 @@ func (m *kubeGenericRuntimeManager) SyncPod(ctx context.Context, pod *v1.Pod, po
|
||||
}
|
||||
|
||||
// Step 7: For containers in podContainerChanges.ContainersToUpdate[CPU,Memory] list, invoke UpdateContainerResources
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) && !types.IsStaticPod(pod) {
|
||||
if isInPlacePodVerticalScalingAllowed(pod) {
|
||||
if len(podContainerChanges.ContainersToUpdate) > 0 || podContainerChanges.UpdatePodResources {
|
||||
m.doPodResizeAction(pod, podStatus, podContainerChanges, result)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user