-
Couldn't load subscription status.
- Fork 1.2k
Description
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
- If you are interested in working on this issue or have submitted a pull request, please leave a comment.
- I'd be willing to implement this feature (contributing guide)
Describe the user story
Currently, Atlantis handles scheduled tasks through the ExecutorService, which manages two main use-cases:
- Publishing runtime stats every 10 seconds via RuntimeStatsCollector.
- Rotating GitHub tokens every 30 seconds via GithubTokenRotator.
While this works for current needs, the scheduling capabilities are quite basic and lack cron support. Enhancing this would make it easier to implement features like:
- Drift Detection #3245 (Drift Detection)
- [Feature] Plugin-Cache Clean Up #916 (Plugin Cache Clean-up)
For both of these features it would be beneficial to have a scheduler with cron support on the server.
Describe the solution you'd like
I suggest replacing the ExecutorService with a ScheduleManager singleton that uses gocron Scheduler. Jobs would be registered with the ScheduleManager but remain fully decoupled from it. The gocron package provides:
- Cron job support
- Various job types
- Built-in job queues, max concurrent jobs, and more useful features (see examples)
The gocron package supports a variety of Job types, including a CronJob. Also it supports built-in mechanisms for Job queues and a lot more beneficial features for scheduling server-side tasks.
I did some drafting at: ramonvermeulen/atlantis@main...f/refactor-scheduler to illustrate the direction (note: this is an early proof of concept, and far from a full implementation).
Describe the drawbacks of your solution
- Adds a new dependency:
github.com/go-co-op/gocron(a well-maintained and widely used package, but still it is a new dependency) - Requires refactoring
ExecutorServiceintoScheduleManager, which will need thorough testing to ensure GitHub token rotation and stats publishing continue working reliably.
Describe alternatives you've considered
I looked at making the scheduler completely separate from the Atlantis server (multi-container setup, similar to Airflow), but this would require significant changes and doesn't align with Atlantis's single-server approach.