PoC: Auto stop environments after a certain period
What does this MR do?
This is PoC/Prototype for #20956 (closed). Not for merge.
Technical overview
- Users can define
environments:auto_stop_inin .gitlab-ci.yml. If it's1 day, the system stops the environment in one day. - When a new environment is created, initial
auto_stop_atis set. - When a new deployment has finished, the
auto_stop_atis renewed. -
AutoStopCronWorkerruns once per hour. It finds expired environments and stops them. It's basically same approach with Pipeline Schedule. It's not executed at the exact time due to the nature of the cron approach, however, since it's cleanup, the precision would not matter. - Users can manually cancel the auto-stop in UI.
TODOs
BE:
-
Allow to define environments:auto_stop_inin .gitlab-ci.yml (Has to validate withon_stoppresence) -
Add a database colomn environments.auto_stop_at(datetime_with_timezone) -
Renew environments.auto_stop_atinDeployments::SuccessWorker -
Introduce Deployments::AutoStopCronWorkerto stop environments whereauto_stop_at < Time.now -
Expose environments.auto_stop_atandcancel_auto_stop_urlin environments.json -
EnvironmentController#cancel_auto_stopfor stopping auto_stop (i.e. Nullfyiingauto_stop_at) -
Update app/views/projects/environments/show.html.hamlto show auto_stop_at -
Create ResetAutoStopServiceand returns status and error message. The message will be returned incancel_auto_stopendpoint.
FE:
-
Render "Auto stop in" and "Cancel auto stop" in app/assets/javascripts/environments/components/environments_table.vue - Should we refactor
app/views/projects/environments/show.html.hamlin vue.js?
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation created/updated or follow-up review issue created -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Performance and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec -
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Shinya Maeda
