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

fix: enforce only one instance of an in-pod cronjob running at once #192

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smlx
Copy link
Member

@smlx smlx commented Mar 7, 2023

This change enforces that in-pod cronjobs have only one instance of the job running at any one time.

Specifically, this change fixes the issue where minutely cronjobs which take longer than a minute to run result in dozens of instances of the job running at the same time. In some cases this can cause Lagoon users to DoS themselves or use excessive CPU or memory resources.

Closes: uselagoon/lagoon-images#172

@smlx
Copy link
Member Author

smlx commented Mar 7, 2023

Not sure how to run this through the Lagoon test suite to confirm functionality. Any tips?

@shreddedbacon
Copy link
Member

shreddedbacon commented Mar 7, 2023

Not sure how to run this through the Lagoon test suite to confirm functionality. Any tips?

We do have a cronjob features test in the test suite, you could extend that to include a cronjob that would experience the issue that flock would solve. Not sure if this is the best way to do this though?

@smlx
Copy link
Member Author

smlx commented Mar 8, 2023

What I mean is: how do I run this through the Lagoon test suite?

smlx added a commit to uselagoon/lagoon that referenced this pull request Mar 8, 2023
@shreddedbacon
Copy link
Member

I've updated this to use the service templates instead of bash. Will need to do some more testing, but seems to work well in the limited playing around I did.

@shreddedbacon shreddedbacon added this to the 2.24.0 milestone Jan 20, 2025
Copy link
Member Author

@smlx smlx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up and integrating it with the new Go build-deploy logic!

internal/generator/services.go Outdated Show resolved Hide resolved
This change enforces that in-pod cronjobs have only one instance of the
job running at any one time.

Specifically, this change fixes the issue where minutely cronjobs which
take longer than a minute to run result in dozens of instances of the
job running at the same time. In some cases this can cause Lagoon users
to DoS themselves or use excessive CPU or memory resources.
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.

Ensure only one copy of a cronjob can run at a time
2 participants