Skip to content

krr simple fails with history-duration under 24h due to rounding bug in Prometheus query #452

@dmartzol

Description

@dmartzol

Describe the bug
When running krr simple with --history-duration set to a value less than 24 hours (e.g., 1), the tool fails with a Prometheus API error and does not generate recommendations. It appears that durations under 24 hours are being rounded to 0 days, leading to an invalid PromQL query.

To Reproduce
Steps to reproduce the behavior:

  1. Deploy Prometheus and run a workload in a namespace (e.g., default)
  2. Run:
    krr simple --namespace=default --history-duration=1 --prometheus-url=<your_prom_url>
  3. Observe the error:
   prometheus_api_client.exceptions.PrometheusApiClientException: HTTP Status Code 400
(b'{"status":"error","errorType":"bad_data","error":"invalid parameter \\"query\\": 8:27: parse error: duration must be greater than
0"}')

Expected behavior
krr should correctly interpret history durations shorter than 24 hours (e.g., 1, 6) and form valid Prometheus queries.

Screenshots
N/A

Are you interested in contributing a fix for this?
Maybe

Desktop (please complete the following information):

  • Prometheus version: 2.26.0
  • prometheus-community/prometheus helm chart version (14.6.0)
  • Version: krr v1.24.0

Smartphone (please complete the following information):

  • Device: N/A
  • OS: N/A
  • Browser: N/A
  • Version: N/A

Additional context

  • Using --history-duration=24 works fine.

Let me know if more logs or testing are needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions