Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jitter window #87

Merged
merged 1 commit into from
Jun 12, 2024
Merged

Add jitter window #87

merged 1 commit into from
Jun 12, 2024

Conversation

gianlucam76
Copy link
Owner

Before this PR, if scheduled time was every hour, if a Cleaner instance was reconciled at 1:00:01, that Cleaner instance was not processed because reconciliation happened a second later than the scheduled one.

If multiple Cleaner instances are all scheduled to be processed at the same time, this was causing problem with some Cleaner instances never processed.

This PR introduces a window aroung the schedule time. By default this window is set to 15 seconds (though it is configurable using arg jitter-window). If reconciliation happens within jitter Window, a cleaner instance is still processed.

To test this PR I created 8 Cleaner instances all scheduled at the same time:

kubectl get cleaner -A
NAME                            AGE
completed-jobs                  6m47s
completed-pods                  6m47s
stale-persistent-volume-claim   6m47s
unbound-peristent-volumes       6m47s
unused-configmaps               6m47s
unused-roles                    6m47s
unused-secrets                  6m47s
unused-service-accounts         6m46s

A report instance for each one of them was created

kubectl get report -A
NAME                            AGE
completed-jobs                  4m57s
completed-pods                  4m58s
stale-persistent-volume-claim   4m58s
unbound-peristent-volumes       4m58s
unused-configmaps               4m57s
unused-roles                    4m57s
unused-secrets                  4m58s
unused-service-accounts         4m58s

Fixes #80

Before this PR, if scheduled time was every hour, if a Cleaner
instance was reconciled at 1:00:01, that Cleaner instance was
not processed because reconciliation happened a second later than
the scheduled one.

If multiple Cleaner instances are all scheduled to be processed at
the same time, this was causing problem with some Cleaner instances
never processed.

This PR introduces a window aroung the schedule time. By default this
window is set to 15 seconds (though it is configurable using arg `jitter-window`).
If reconciliation happens within jitter Window, a cleaner instance is still
processed.

To test this PR I created 8 Cleaner instances all scheduled at the same time:

```bash
kubectl get cleaner -A
NAME                            AGE
completed-jobs                  6m47s
completed-pods                  6m47s
stale-persistent-volume-claim   6m47s
unbound-peristent-volumes       6m47s
unused-configmaps               6m47s
unused-roles                    6m47s
unused-secrets                  6m47s
unused-service-accounts         6m46s
```

A report instance for each one of them was created

```bash
kubectl get report -A
NAME                            AGE
completed-jobs                  4m57s
completed-pods                  4m58s
stale-persistent-volume-claim   4m58s
unbound-peristent-volumes       4m58s
unused-configmaps               4m57s
unused-roles                    4m57s
unused-secrets                  4m58s
unused-service-accounts         4m58s
```
@gianlucam76 gianlucam76 merged commit c99a51b into main Jun 12, 2024
4 checks passed
@gianlucam76 gianlucam76 deleted the jitter-window branch June 12, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question about reports
1 participant