diff options
| author | Natan Yellin <aantn@users.noreply.github.com> | 2024-03-18 16:43:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-18 16:43:19 +0200 |
| commit | 4fe49d139de02a61c2ad979c3da8c6241e78fdc2 (patch) | |
| tree | 2a513ce5dcfd62c133d5cb12331a03dcb92b0afa /robusta_krr/strategies | |
| parent | 58be7a7f8c740eff2132bc527f33bfa927d7ef2d (diff) | |
Add --allow_hpa flag (#226)
Co-authored-by: Pavel Zhukov <33721692+LeaveMyYard@users.noreply.github.com>
Diffstat (limited to 'robusta_krr/strategies')
| -rw-r--r-- | robusta_krr/strategies/simple.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/robusta_krr/strategies/simple.py b/robusta_krr/strategies/simple.py index 6b343e2..8bbd08d 100644 --- a/robusta_krr/strategies/simple.py +++ b/robusta_krr/strategies/simple.py @@ -30,6 +30,7 @@ class SimpleStrategySettings(StrategySettings): points_required: int = pd.Field( 100, ge=1, description="The number of data points required to make a recommendation for a resource." ) + allow_hpa: bool = pd.Field(False, description="Whether to calculate recommendations even when there is an HPA scaler defined on that resource.") def calculate_memory_proposal(self, data: PodsTimeData) -> float: data_ = [np.max(values[:, 1]) for values in data.values()] @@ -65,6 +66,7 @@ class SimpleStrategy(BaseStrategy[SimpleStrategySettings]): This strategy does not work with objects with HPA defined (Horizontal Pod Autoscaler). If HPA is defined for CPU or Memory, the strategy will return "?" for that resource. + You can override this behaviour by passing the --allow_hpa flag Learn more: [underline]https://github.com/robusta-dev/krr#algorithm[/underline] """ @@ -90,7 +92,7 @@ class SimpleStrategy(BaseStrategy[SimpleStrategySettings]): if total_points_count < self.settings.points_required: return ResourceRecommendation.undefined(info="Not enough data") - if object_data.hpa is not None and object_data.hpa.target_cpu_utilization_percentage is not None: + if object_data.hpa is not None and object_data.hpa.target_cpu_utilization_percentage is not None and not self.settings.allow_hpa: return ResourceRecommendation.undefined(info="HPA detected") cpu_usage = self.settings.calculate_cpu_proposal(data) @@ -110,7 +112,7 @@ class SimpleStrategy(BaseStrategy[SimpleStrategySettings]): if total_points_count < self.settings.points_required: return ResourceRecommendation.undefined(info="Not enough data") - if object_data.hpa is not None and object_data.hpa.target_memory_utilization_percentage is not None: + if object_data.hpa is not None and object_data.hpa.target_memory_utilization_percentage is not None and not self.settings.allow_hpa: return ResourceRecommendation.undefined(info="HPA detected") memory_usage = self.settings.calculate_memory_proposal(data) |
