Environment detail page does not fetch the stop actions of a successfully deployed environment
This was discovered when working on Investigate solutions for `auto_stop_in` not en... (#429616 - closed)
Summary
Setup
-
Create a project
-
Setup a simple deploy pipeline for the project, with both a
deploy
andstop
job for an Environment.Example
.gitlab-ci.yml
file:deploy_review: stage: deploy script: - echo "Spinning up Review Environment for review/successful_deployment..." environment: name: review/successful_deployment action: start on_stop: stop_review stop_review: stage: deploy script: - echo "Tearing down Review Environment successful_deployment." when: manual environment: name: review/successful_deployment action: stop
-
Run the pipeline
Problem illustration
In the Environments list page (Operate -> Environments), when you click the "Stop" button for the Environment, a "Stop Environment" modal will pop-up without warnings:
However, when you navigate to the Environment detail page, then click the "Stop" button, the "Stop Environment" modal has warnings:
This is inconsistent. The correct modal should be the first one.
Problem cause
The warnings in the modal are shown through the hasStopAction
function in https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/environments/components/stop_environment_modal.vue#L91.
The hasStopAction
function is defined in https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/environments/components/stop_environment_modal.vue#L48:
hasStopAction() {
return this.graphql ? this.environment.hasStopAction : this.environment.has_stop_action;
},
In the Environments list page, the Environment data is fetched through the REST API.
In the Environment detail page, the Environment data is fetched through GraphQL. But the GraphQL query does not include a hasStopAction
field. (See https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/environments/graphql/queries/environment_details.query.graphql)
Implementation Guide
-
backend / GraphQL: Make sure that the Environment type has a
has_stop_action
field, and that this field is included when fetching the Environment through the resolver. -
frontend: Update the getEnvironmentDetails query to include the
hasStopAction
field.