Skip to content

Commit

Permalink
address reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
sanposhiho committed Mar 2, 2024
1 parent 07e0a80 commit b48b4eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/features/kube_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ const (
// kep: https://kep.k8s.io/1610
// alpha: v1.20
// beta: v1.27
// beta: v1.30
// GA: v1.30
//
// Add support for the HPA to scale based on metrics from individual containers
// in target pods
Expand Down Expand Up @@ -995,7 +995,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS

GracefulNodeShutdownBasedOnPodPriority: {Default: true, PreRelease: featuregate.Beta},

HPAContainerMetrics: {Default: true, PreRelease: featuregate.GA},
HPAContainerMetrics: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.32

HonorPVReclaimPolicy: {Default: false, PreRelease: featuregate.Alpha},

Expand Down
14 changes: 12 additions & 2 deletions pkg/registry/autoscaling/horizontalpodautoscaler/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ func (autoscalerStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.S
}

// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
func (autoscalerStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {}
func (autoscalerStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
newHPA := obj.(*autoscaling.HorizontalPodAutoscaler)

// create cannot set status
newHPA.Status = autoscaling.HorizontalPodAutoscalerStatus{}
}

// Validate validates a new autoscaler.
func (autoscalerStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
Expand All @@ -88,7 +93,12 @@ func (autoscalerStrategy) AllowCreateOnUpdate() bool {
}

// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (autoscalerStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {}
func (autoscalerStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newHPA := obj.(*autoscaling.HorizontalPodAutoscaler)
oldHPA := old.(*autoscaling.HorizontalPodAutoscaler)
// Update is not allowed to set status
newHPA.Status = oldHPA.Status
}

// ValidateUpdate is the default update validation for an end user.
func (autoscalerStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
Expand Down

0 comments on commit b48b4eb

Please sign in to comment.