robusta-dev / krr

Prometheus-based Kubernetes Resource Recommendations
MIT License
2.81k stars 150 forks source link

Support for oom_memory_buffer_percentage=0 #305

Open lukasmrtvy opened 2 months ago

lukasmrtvy commented 2 months ago

krr ( krr:v1.11.0 ) job with args "--use_oomkill_data --oom_memory_buffer_percentage=0" fails to:

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /app/robusta_krr/main.py:294 in run_strategy                                 │
│                                                                              │
│   291 │   │   │   │   except ValidationError:                                │
│   292 │   │   │   │   │   logger.exception("Error occured while parsing argu │
│   293 │   │   │   │   else:                                                  │
│ ❱ 294 │   │   │   │   │   runner = Runner()                                  │
│   295 │   │   │   │   │   exit_code = asyncio.run(runner.run())              │
│   296 │   │   │   │   │   raise typer.Exit(code=exit_code)                   │
│   297                                                                        │
│                                                                              │
│ /app/robusta_krr/core/runner.py:47 in __init__                               │
│                                                                              │
│    44 │   │   self._k8s_loader = KubernetesLoader()                          │
│    45 │   │   self._metrics_service_loaders: dict[Optional[str], Union[Prome │
│    46 │   │   self._metrics_service_loaders_error_logged: set[Exception] = s │
│ ❱  47 │   │   self._strategy = settings.create_strategy()                    │
│    48 │   │                                                                  │
│    49 │   │   self.errors: list[dict] = []                                   │
│    50                                                                        │
│                                                                              │
│ /app/robusta_krr/core/models/config.py:118 in create_strategy                │
│                                                                              │
│   115 │   def create_strategy(self) -> AnyStrategy:                          │
│   116 │   │   StrategyType = AnyStrategy.find(self.strategy)                 │
│   117 │   │   StrategySettingsType = StrategyType.get_settings_type()        │
│ ❱ 118 │   │   return StrategyType(StrategySettingsType(**self.other_args))   │
│   119 │                                                                      │
│   120 │   @pd.validator("strategy")                                          │
│   121 │   def validate_strategy(cls, v: str) -> str:                         │
│                                                                              │
│ /usr/local/lib/python3.12/site-packages/pydantic/main.py:341 in __init__     │
│                                                                              │
│    338 │   │   # Uses something other than `self` the first arg to allow "se │
│    339 │   │   values, fields_set, validation_error = validate_model(__pydan │
│    340 │   │   if validation_error:                                          │
│ ❱  341 │   │   │   raise validation_error                                    │
│    342 │   │   try:                                                          │
│    343 │   │   │   object_setattr(__pydantic_self__, '__dict__', values)     │
│    344 │   │   except TypeError as e:                                        │
╰──────────────────────────────────────────────────────────────────────────────╯
ValidationError: 1 validation error for SimpleStrategySettings
oom_memory_buffer_percentage
  ensure this value is greater than 0 (type=value_error.number.not_gt; 
limit_value=0)
aantn commented 2 months ago

Please try #306