Auto stop environments after a certain period
### Problem Review apps are short lived by definition. Unfortunately, stale branches are ubiquitous (gitlab-ce has ~1,600). Keeping all as review apps would is a burden. ### Proposal Just like artifacts can expire, environments should be able to be configured to stop after a certain time, as defined in `job:environment:auto_stop_in`. And, just like artifacts can be "promoted" as non-expiring in the UI, so should be environments. The `auto_stop_in:` value for environment is renewed per deployment, this means if an environment is about to be stopped and got a new deployment, the `auto_stop_in:` is extended to the new value. Thus, active environments will never be expired and only inactive/stale environments will be stopped automatically. #### Environments - Add a column for Auto stops in - If an environment will auto stop, show button to prevent it from auto-stopping - Realign `No deployments` with deployments column - Do not display Auto stop in or button if the environment is not set to auto stop ![Environments](/uploads/56426f62188733f01e45320ff5bc746b/Environments.png) #### Environments Details - If an environment will auto stop, Add Auto stops in xx weeks next to the title - If an environment will auto stop, show button to prevent it ![Environment_Details](/uploads/d32b82e992995a8c7421c9924bd425a5/Environment_Details.png) #### Button tooltip ![Tooltip](/uploads/73bb00974ab632e0ada43c6f4e5553f9/Tooltip.png) ### Links / references ## PoC https://gitlab.com/gitlab-org/gitlab/merge_requests/18115 is complete. ## MRs to be merged into master ~backend - [x] Persist and control auto stop date. => https://gitlab.com/gitlab-org/gitlab/merge_requests/19931 - [x] Prepare background job to periodically cleanup expired environments. => https://gitlab.com/gitlab-org/gitlab/merge_requests/21476 - [x] Update GitLab omnibus's cron setting => https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/3927 - [x] Remove feature flag and update the documentation. => https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24850 ~frontend - [x] Create MR for persisting and controlling auto-stop branched off BE MR. => https://gitlab.com/gitlab-org/gitlab/merge_requests/20372 ## Feature Flag This feature is built behind `auto_stop_environments` feature flag and disabled by default until we make sure it's deemed stable. cc @markpundsack @bikebilly
issue