Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/linters/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ spec:

**Error:**
```
Error: VPA updateMode cannot be 'Auto'
Error: VPA updateMode cannot be 'Auto' as it is deprecated. Please use 'InPlaceOrRecreate' instead
```

**Why updateMode: Auto is no longer supported:**

The `updateMode: Auto` is no longer supported (considered deprecated) because in the upstream `Vertical Pod Autoscaler`, this mode has been deprecated since `VPA 1.4.0` and is now an alias for `Recreate` - that is, it always works through eviction/recreation of Pods and does not provide the advantages of in-place resizing.
The `updateMode: Auto` is no longer supported (considered deprecated) because in the upstream `Vertical Pod Autoscaler`, this mode has been deprecated since `VPA 1.5.1` and is now an alias for `Recreate` - that is, it always works through eviction/recreation of Pods and does not provide the advantages of in-place resizing.
In `Deckhouse`, this has been fixed with a change: all `Deckhouse-managed VPAs` have been switched from `Auto` to `InPlaceOrRecreate` so that, if Kubernetes support is available, in-place resource updates are performed, and if it is not available, a fallback to eviction is performed.

**Which mode to use instead of Auto**
Expand Down
5 changes: 5 additions & 0 deletions pkg/linters/templates/rules/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,16 @@ const (
// creation and additionally can update them during the lifetime of the
// pod by deleting and recreating the pod.
UpdateModeRecreate UpdateMode = "Recreate"
// DEPRECATED since vpa version 1.5.1. It is now recommended to use InPlaceOrRecreate instead.
// UpdateModeAuto means that autoscaler assigns resources on pod creation
// and additionally can update them during the lifetime of the pod,
// using any available update method. Currently this is equivalent to
// Recreate, which is the only available update method.
UpdateModeAuto UpdateMode = "Auto"
// UpdateModeInPlaceOrReacreate means that autoscaler assigns resources on pod creation
// if Kubernetes support is available, in-place resource updates are performed,
// and if it is not available, a fallback to eviction is performed.
UpdateModeInPlaceOrReacreate UpdateMode = "InPlaceOrRecreate"
)

// PodResourcePolicy controls how autoscaler computes the recommended resources
Expand Down
22 changes: 18 additions & 4 deletions pkg/linters/templates/rules/vpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ func fillVPAMaps(
vpaUpdateModes[target] = updateMode
}

// isValidUpdateMode checks if the updateMode is one of the allowed values
func isValidUpdateMode(updateMode UpdateMode) bool {
switch updateMode {
case UpdateModeOff, UpdateModeInitial, UpdateModeRecreate, UpdateModeInPlaceOrReacreate, UpdateModeAuto:
return true
default:
return false
}
}

// parseVPAResourcePolicyContainers parses VPA containers names in ResourcePolicy and check if minAllowed and maxAllowed for container is set
func parseVPAResourcePolicyContainers(vpaObject storage.StoreObject, errorList *errors.LintRuleErrorsList) (UpdateMode, set.Set, bool) {
errorListObj := errorList.WithObjectID(vpaObject.Identity()).WithFilePath(vpaObject.ShortPath())
Expand All @@ -145,10 +155,6 @@ func parseVPAResourcePolicyContainers(vpaObject storage.StoreObject, errorList *
}

updateMode := *v.Spec.UpdatePolicy.UpdateMode
if updateMode == UpdateModeAuto {
errorListObj.Errorf("VPA updateMode cannot be 'Auto'")
return updateMode, containers, false
}
if updateMode == UpdateModeOff {
return updateMode, containers, true
}
Expand All @@ -159,6 +165,14 @@ func parseVPAResourcePolicyContainers(vpaObject storage.StoreObject, errorList *
return updateMode, containers, false
}

if updateMode == UpdateModeAuto {
errorListObj.Errorf("VPA updateMode cannot be 'Auto' as it is deprecated. Please use 'InPlaceOrRecreate' instead")
}

if !isValidUpdateMode(updateMode) {
errorListObj.Errorf("Invalid updateMode '%s'. Allowed values are: Off, Initial, Recreate, InPlaceOrRecreate", updateMode)
}

for _, cp := range v.Spec.ResourcePolicy.ContainerPolicies {
if cp.MinAllowed.Cpu().IsZero() {
errorListObj.Errorf("No VPA specs minAllowed.cpu is found for container %s", cp.ContainerName)
Expand Down