Skip to content

Commit df17896

Browse files
authored
GroupedJobs + Prometheus credentials auto refresh (#478)
Added support for job grouping, and refreshing prometheus credentials due to irsa token timeout. Currently testing credential refresh. <img width="1640" height="882" alt="Screenshot 2025-10-06 at 13 04 05" src="https://github.com/user-attachments/assets/a75b976d-7e68-40ae-8ba3-eb1a74f38cfe" />
1 parent f5d9744 commit df17896

File tree

11 files changed

+595
-20
lines changed

11 files changed

+595
-20
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,43 @@ python krr.py simple --selector 'app.kubernetes.io/instance in (robusta, ingress
352352
```
353353
</details>
354354

355+
<details>
356+
<summary>Group jobs by specific labels</summary>
357+
358+
Group jobs that have specific labels into GroupedJob objects for consolidated resource recommendations. This is useful for batch jobs, data processing pipelines, or any workload where you want to analyze resource usage across multiple related jobs.
359+
360+
```sh
361+
krr simple --job-grouping-labels app,team
362+
```
363+
364+
This will:
365+
- Group jobs that have either `app` or `team` labels (or both)
366+
- Create GroupedJob objects with names like `app=frontend`, `team=backend`, etc.
367+
- Provide resource recommendations for the entire group instead of individual jobs
368+
- Jobs with the specified labels will be excluded from regular Job listing
369+
370+
You can specify multiple labels separated by commas:
371+
372+
```sh
373+
krr simple --job-grouping-labels app,team,environment
374+
```
375+
376+
Each job will be grouped by each label it has, so a job with `app=api,team=backend` will appear in both `app=api` and `team=backend` groups.
377+
378+
### Limiting how many jobs are included per group
379+
380+
Use `--job-grouping-limit <N>` to cap how many jobs are included **per group** (useful when there are many historical jobs).
381+
382+
```sh
383+
krr simple --job-grouping-labels app,team --job-grouping-limit 3
384+
```
385+
386+
* Each label group will include at most **N** jobs (e.g., the first 3 returned by the API).
387+
* Other matching jobs beyond the limit are ignored for that group.
388+
* If not specified, the default limit is **500** jobs per group.
389+
390+
</details>
391+
355392
<details>
356393
<summary>Override the kubectl context</summary>
357394

conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Make sure pytest loads the asyncio plugin so `async def` tests run.
2+
pytest_plugins = ("pytest_asyncio",)

poetry.lock

Lines changed: 156 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ kubernetes = "^26.1.0"
3030
prometheus-api-client = "0.5.3"
3131
numpy = ">=1.26.4,<1.27.0"
3232
alive-progress = "^3.1.2"
33-
prometrix = "^0.2.7"
33+
prometrix = "0.2.5"
3434
slack-sdk = "^3.21.3"
3535
pandas = "2.2.2"
3636
requests = ">2.32.4"
@@ -41,6 +41,7 @@ urllib3 = "^1.26.20"
4141
setuptools = "^80.9.0"
4242
zipp = "^3.19.1"
4343
tenacity = "^9.0.0"
44+
pyinstaller = "^5.9.0"
4445

4546

4647

@@ -53,6 +54,8 @@ types-pyyaml = "^6.0.12.8"
5354
types-cachetools = "^5.3.0.4"
5455
types-requests = "^2.28.11.15"
5556
pytest = "^7.2.2"
57+
pytest-asyncio = ">=0.21,<0.24"
58+
pyinstaller = "^5.9.0"
5659

5760
[build-system]
5861
requires = ["poetry-core"]

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ packaging==24.0 ; python_version >= "3.9" and python_full_version < "3.13"
2727
pandas==2.2.2 ; python_version >= "3.9" and python_full_version < "3.13"
2828
pillow==10.3.0 ; python_version >= "3.9" and python_full_version < "3.13"
2929
prometheus-api-client==0.5.3 ; python_version >= "3.9" and python_full_version < "3.13"
30-
prometrix==0.2.7 ; python_version >= "3.9" and python_full_version < "3.13"
30+
prometrix==0.2.5 ; python_version >= "3.9" and python_full_version < "3.13"
3131
pyasn1-modules==0.3.0 ; python_version >= "3.9" and python_full_version < "3.13"
3232
pyasn1==0.5.1 ; python_version >= "3.9" and python_full_version < "3.13"
3333
pydantic==1.10.15 ; python_version >= "3.9" and python_full_version < "3.13"
@@ -54,3 +54,4 @@ tzlocal==5.2 ; python_version >= "3.9" and python_full_version < "3.13"
5454
urllib3==1.26.20 ; python_version >= "3.9" and python_full_version < "3.13"
5555
websocket-client==1.7.0 ; python_version >= "3.9" and python_full_version < "3.13"
5656
zipp==3.20.2 ; python_version >= "3.9" and python_full_version < "3.13"
57+
pytest-asyncio==0.23.7 ; python_version >= "3.9" and python_full_version < "3.13"

0 commit comments

Comments
 (0)