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

Optimize Kebechet runs in a deployment #873

Open
6 tasks
fridex opened this issue Oct 18, 2021 · 12 comments
Open
6 tasks

Optimize Kebechet runs in a deployment #873

fridex opened this issue Oct 18, 2021 · 12 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/devsecops Categorizes an issue or PR as relevant to SIG DevSecOps. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@fridex
Copy link
Contributor

fridex commented Oct 18, 2021

Is your feature request related to a problem? Please describe.

It looks like we are not effectively utilizing cluster resources for Kebechet. Kebechet is run on each webhook received which might easily flood the whole namespace, especially with active repositories. Let's have a way to limit the number of Kebechet pods for a single repository in a deployment.

Describe the solution you'd like

One of the solutions would be to use messaging if Kafka provides a feature that would limit the number of specific messages (that is probably not possible based on our last tech talk discussion CC @KPostOffice).

Another way to limit the number of Kebechet runs for a single repository once a webhook is sent to user-api is to create a new database record stored in postgres (and associated with GitHub URL) that keeps null or a timestamp when user-api scheduled Kebechet last time.

  1. user-api receives a webhook
  2. user-api checks if there is already a pending request for the given repo in postgres (the timestamp is not null) and the timestamp is less than the specified number of minutes (a new configuration entry in user-api)
    a. if yes, the webhook handling is ignored (kebechet is not run)
    b. if no, continue to step 3
  3. add the current timestamp to the database for the specified repo
  4. schedule kebechet

On Kebechet side - once Kebechet is started, Kebechet marks the given timestamp as null for the repo it handles and starts handling the repository with Kebechet managers.

This way we will ignore any webhooks coming to the system while kebechet messages for repositories are already queued and we know Kebechet will handle repositories in the next run for the specified repos.

  • add timestamp to postgres and have it associated with GitHub URL (installations)
  • user-api is extended with the described logic above that manipulates with the timestamp
  • user-api's configuration is extended with a configuration option (configurable via env vars) that states timeout after which the timestamp stored in the database is invalid
  • user-api exposes the newly created configuration as a metric (and is available in the dashboard)
  • kebechet sets the given timestamp entry in the database to null on startup
    • this can be done as init container using workflow helpers or so (if we do not want thoth-storages in kebechet itself)

Describe alternatives you've considered

Keep the solution as is, but it is not optimal with respect to the resources allocated.

Additional context

The timestamp was chosen to avoid manually adjusting the database if there will be issues (ex. issues with Kafka). If we lose messages or kebechet fails to clear the database entry to null, we will still be able to handle requests after the specified time, configured on user-api.

@fridex fridex added kind/feature Categorizes issue or PR as related to a new feature. triage/needs-information Indicates an issue needs more information in order to work on it. labels Oct 18, 2021
@sesheta
Copy link
Member

sesheta commented Jan 16, 2022

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@sesheta sesheta added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 16, 2022
@KPostOffice
Copy link
Member

/remove-lifecycle stale
/priority important-longterm

@sesheta sesheta added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 17, 2022
@KPostOffice
Copy link
Member

Some Kebechet features rely on the content of the webhook (i.e. if a PR was merged). If we drop webhooks we may drop functionality.

@sesheta
Copy link
Member

sesheta commented May 5, 2022

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@sesheta sesheta added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 5, 2022
@KPostOffice
Copy link
Member

/remove-lifecycle stale

@sesheta sesheta removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 12, 2022
@sesheta
Copy link
Member

sesheta commented Aug 10, 2022

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@sesheta sesheta added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 10, 2022
@VannTen
Copy link
Member

VannTen commented Aug 30, 2022

This looks more like a job for a workqueue with a limited number of concurrent consumers.
Besides (emphasis mine) :

It looks like we are not effectively utilizing cluster resources for Kebechet. Kebechet is run on each webhook received which might easily flood the whole namespace, especially with active repositories

Do we actually have hard data on that, aka, is it a problem in practice ?

/sig devsecops

@sesheta sesheta added the sig/devsecops Categorizes an issue or PR as relevant to SIG DevSecOps. label Aug 30, 2022
@sesheta
Copy link
Member

sesheta commented Sep 29, 2022

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

/lifecycle rotten

@sesheta sesheta added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Sep 29, 2022
@harshad16
Copy link
Member

/remove-lifecycle rotten
/lifecycle frozen

@sesheta sesheta added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Oct 4, 2022
@goern
Copy link
Member

goern commented Oct 5, 2022

/remove-lifecycle frozen
/priority backlog

@sesheta sesheta added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. labels Oct 5, 2022
@codificat
Copy link
Member

/priority backlog

for consistency (as this does not happen automatically):
/remove-priority important-longterm

@sesheta sesheta removed the priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. label Oct 5, 2022
@sesheta
Copy link
Member

sesheta commented Apr 3, 2023

Issues needing reporter input close after 60d,

If there is new input, reopen with /reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/devsecops Categorizes an issue or PR as relevant to SIG DevSecOps. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
Status: 🆕 New
Development

No branches or pull requests

7 participants