When a job got a structural integrity problem, the deployment record stuck in running state

Problem

Originally, found by https://gitlab.slack.com/archives/CBZGR90A2/p1652829557059579.

When a deployment job failed by There has been a structural integrity problem detected, please contact system administrator, the corresponding deployment record won't transition to the failed status, but stuck at running status. This is because Ci::Build#doom! doesn't trigger a regular state transition logic.

Example: https://gitlab.com/gitlab-com/www-gitlab-com/-/jobs/991132991

2022-05-18_10-55

2022-05-18_10-51

Proposal

We update the deployment record in the doom! event. Here is the proposed fix:

diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index eea8086d71d..2c6ae80f510 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -1056,6 +1056,8 @@ def doom!
         all_runtime_metadata.delete_all
       end
 
+      deployment&.sync_status_with(self)
+
       Gitlab::AppLogger.info(
         message: 'Build doomed',
         class: self.class.name,
Edited by Shinya Maeda