From dcbd6b64162a492292bcb79d20c8580a322b5698 Mon Sep 17 00:00:00 2001 From: Bala Kumar Date: Tue, 12 Apr 2022 22:39:48 +0530 Subject: [PATCH 1/2] Documentation for multi on_stop actions for an environment --- doc/ci/environments/index.md | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/doc/ci/environments/index.md b/doc/ci/environments/index.md index c2612b6ff16ea7..3bf3d39b3151a9 100644 --- a/doc/ci/environments/index.md +++ b/doc/ci/environments/index.md @@ -558,6 +558,55 @@ Because `stop_review_app` is set to `auto_stop_in: 1 week`, if a merge request is inactive for more than a week, GitLab automatically triggers the `stop_review_app` job to stop the environment. +#### Multiple stop actions for an environment + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/22456) in GitLab 14.10 [with a flag](../../administration/feature_flags.md) named `environment_multiple_stop_actions`. Disabled by default. + +FLAG: +On self-managed GitLab, by default this feature is not available. To make it available, ask an administrator to [enable the feature flag](../../administration/feature_flags.md) named `environment_multiple_stop_actions`. +On GitLab.com, this feature is not available. We are enabling in phases and the status can be tracked in [issue](https://gitlab.com/gitlab-org/gitlab/-/issues/358911). + +This feature is useful when you need to perform multiple **parallel** stop actions on an environment. + +To configure multiple stop actions on an environment, specify the [`on_stop`](../yaml/index.md#environmenton_stop) +keyword across multiple [deployment jobs](../jobs/index.md#deployment-jobs) for the same `environment`, as defined in the `.gitlab-ci.yml` file. + +When an environment is stopped, the matching `on_stop` actions from *successful deployment jobs* alone are run in parallel in no particular order. + +In the following example, for the `test` environment there are two deployment jobs `deploy-to-cloud-a` +and `deploy-to-cloud-b`. + +```yaml +deploy-to-cloud-a: + script: echo "Deploy to cloud a" + environment: + name: test + on_stop: teardown-cloud-a + +deploy-to-cloud-b: + script: echo "Deploy to cloud b" + environment: + name: test + on_stop: teardown-cloud-b + +teardown-cloud-a: + script: echo "Delete the resources in cloud a" + environment: + name: test + action: stop + when: manual + +teardown-cloud-b: + script: echo "Delete the resources in cloud b" + environment: + name: test + action: stop + when: manual +``` + +When the environment is stopped, the system runs `on_stop` actions +`teardown-cloud-a` and `teardown-cloud-b` in parallel. + #### View a deployment's scheduled stop time You can view a deployment's expiration date in the GitLab UI. -- GitLab From ca054f2a69326981d5a4adf93ea1be1d3febfc11 Mon Sep 17 00:00:00 2001 From: Russell Dickenson Date: Thu, 14 Apr 2022 03:14:17 +0000 Subject: [PATCH 2/2] Apply 1 suggestion(s) to 1 file(s) --- doc/ci/environments/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ci/environments/index.md b/doc/ci/environments/index.md index 3bf3d39b3151a9..3822b32181f914 100644 --- a/doc/ci/environments/index.md +++ b/doc/ci/environments/index.md @@ -564,7 +564,7 @@ GitLab automatically triggers the `stop_review_app` job to stop the environment. FLAG: On self-managed GitLab, by default this feature is not available. To make it available, ask an administrator to [enable the feature flag](../../administration/feature_flags.md) named `environment_multiple_stop_actions`. -On GitLab.com, this feature is not available. We are enabling in phases and the status can be tracked in [issue](https://gitlab.com/gitlab-org/gitlab/-/issues/358911). +On GitLab.com, this feature is not available. We are enabling in phases and the status can be tracked in [issue 358911](https://gitlab.com/gitlab-org/gitlab/-/issues/358911). This feature is useful when you need to perform multiple **parallel** stop actions on an environment. -- GitLab