Skip to content

Commit

Permalink
Revert "safer update of HPA target utilization (#269)" (#290)
Browse files Browse the repository at this point in the history
* Revert "safer update of HPA target utilization (#269)"

This reverts commit ce81274.

* fix test
  • Loading branch information
sanposhiho authored Jan 19, 2024
1 parent a441deb commit 6f6cba3
Show file tree
Hide file tree
Showing 26 changed files with 138 additions and 407 deletions.
4 changes: 2 additions & 2 deletions api/v1beta3/tortoise_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ type TortoiseConditionType string

const (
// TortoiseConditionTypeFailedToReconcile means tortoise failed to reconcile due to some reasons.
TortoiseConditionTypeFailedToReconcile TortoiseConditionType = "FailedToReconcile"
TortoiseConditionTypeHPATargetUtilizationIncreased TortoiseConditionType = "HPATargetUtilizationIncreased"
TortoiseConditionTypeFailedToReconcile TortoiseConditionType = "FailedToReconcile"
TortoiseConditionTypeHPATargetUtilizationUpdated TortoiseConditionType = "HPATargetUtilizationUpdated"
)

type TortoiseCondition struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ status:
resource:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ status:
resource:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ status:
resource:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ status:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- message: "HPA target utilization is increased"
reason: HPATargetUtilizationIncreased
- message: "HPA target utilization is updated"
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationIncreased
type: HPATargetUtilizationUpdated
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
Expand Down
8 changes: 3 additions & 5 deletions docs/admin-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,8 @@ the target utilization is actually change from 50 to 55.

### TortoiseHPATargetUtilizationUpdateInterval

The interval of increasing target utilization of each HPA (default: 1h)
The interval of updating target utilization of each HPA (default: 1h)

So, similarily to TortoiseHPATargetUtilizationMaxIncrease, it's also a safety guard to prevent HPA target utilization from suddenly increased.
So, similarily to TortoiseHPATargetUtilizationMaxIncrease, it's also a safety guard to prevent HPA target utilization from suddenly changed.
If TortoiseHPATargetUtilizationMaxIncrease is 1h, TortoiseHPATargetUtilizationMaxIncrease is 5, and tortoise keep suggesting changing the HPA target resource utilization from 50 to 80,
the target resource utilization would be changing like 50 -(1h)-> 55 -(1h)-> 60 → ... → 80.

Note that the controller ignores this when decreasing the target utilization is suggested because ignoring such is another dangerous.
the target resource utilization would be changing like 50 -(1h)-> 55 -(1h)-> 60 → ... → 80.
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type Config struct {
TortoiseUpdateInterval time.Duration `yaml:"TortoiseUpdateInterval"`
// TortoiseHPATargetUtilizationMaxIncrease is the max increase of target utilization that tortoise can give to the HPA (default: 5)
TortoiseHPATargetUtilizationMaxIncrease int `yaml:"TortoiseHPATargetUtilizationMaxIncrease"`
// TortoiseHPATargetUtilizationUpdateInterval is the interval of increasing target utilization of each HPA. (default: 1h)
// TortoiseHPATargetUtilizationUpdateInterval is the interval of updating target utilization of each HPA (default: 24h)
TortoiseHPATargetUtilizationUpdateInterval time.Duration `yaml:"TortoiseHPATargetUtilizationUpdateInterval"`
// HPAExternalMetricExclusionRegex is the regex to exclude external metrics from HPA. (default: Not delete any external metrics)
// Basically, if HPA has external metrics, the tortoise keeps that external metric.
Expand Down Expand Up @@ -84,7 +84,7 @@ func defaultConfig() *Config {
TimeZone: "Asia/Tokyo",
TortoiseUpdateInterval: 15 * time.Second,
TortoiseHPATargetUtilizationMaxIncrease: 5,
TortoiseHPATargetUtilizationUpdateInterval: time.Hour,
TortoiseHPATargetUtilizationUpdateInterval: time.Hour * 24,
MaximumMinReplica: 10,
MaximumMaxReplica: 100,
IstioSidecarProxyDefaultCPU: "100m",
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestParseConfig(t *testing.T) {
TortoiseHPATargetUtilizationMaxIncrease: 5,
MaximumMinReplica: 10,
MaximumMaxReplica: 100,
TortoiseHPATargetUtilizationUpdateInterval: 1 * time.Hour,
TortoiseHPATargetUtilizationUpdateInterval: 24 * time.Hour,
IstioSidecarProxyDefaultCPU: "100m",
IstioSidecarProxyDefaultMemory: "200Mi",
},
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestParseConfig(t *testing.T) {
TortoiseHPATargetUtilizationMaxIncrease: 5,
MaximumMinReplica: 10,
MaximumMaxReplica: 100,
TortoiseHPATargetUtilizationUpdateInterval: time.Hour,
TortoiseHPATargetUtilizationUpdateInterval: 24 * time.Hour,
IstioSidecarProxyDefaultCPU: "100m",
IstioSidecarProxyDefaultMemory: "200Mi",
},
Expand Down
Loading

0 comments on commit 6f6cba3

Please sign in to comment.