Skip to content

Make the DeployBlogService to be idempotent

Mayra Cabrera requested to merge make-deploy-job-idempotent into master

What does this MR do and why?

Updates the DeployBlogService to consider approvals and a dedicated merge train strategy.

  • Given the handbook doesn't have approval rules, the approval information is based on the number of approvals, if the blog post has at least one approval, then our tooling considers it as "approved" and skips the approval.
  • The add_merge_train API method was updated to use 'sha' and 'when_pipeline_succeeds', this allows for merge requests with pending pipelines to be added to the train.

Related to gitlab-com/gl-infra/delivery#19743 (closed)

Testing

Scenario Before After Output
Regular merge request - No approvals, pipeline green Screenshot_2023-10-25_at_14.17.19 Screenshot_2023-10-25_at_14.30.31 MR approved and added to the merge train
Pending pipeline merge requests - Approved and pending pipeline Screenshot_2023-10-25_at_14.32.25 Screenshot_2023-10-25_at_14.44.03 Approval is skipped and MR added to the merge train
Recently created MR Screenshot_2023-10-25_at_14.50.36 Screenshot_2023-10-25_at_14.51.21 MR approved and added to the merge train

Logs:

Regular merge request
2023-10-25 14:49:02.992104 I ReleaseTools::Security::Publish::DeployBlogPost -- Assigning the blog post to the active release managers -- {:release_managers=>["dat.tang.gitlab", "rpereira2", "sabrams"]}
2023-10-25 14:49:02.992180 I ReleaseTools::Security::Publish::DeployBlogPost -- Approving the blog post -- {:blog_post=>"https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/130724"}
2023-10-25 14:49:02.992196 I ReleaseTools::Security::Publish::DeployBlogPost -- Fetching blog post approval information
2023-10-25 14:49:03.372965 D ReleaseTools::GitlabClient -- [HTTParty] [2023-10-25 14:49:03 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/merge_requests/130724/approvals" -
2023-10-25 14:49:03.373290 I ReleaseTools::Security::Publish::DeployBlogPost -- Blog post has not approvals, proceeding to approve
2023-10-25 14:49:03.916250 D ReleaseTools::GitlabClient -- [HTTParty] [2023-10-25 14:49:03 -0600] 201 "POST https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/merge_requests/130724/approve" 5742
2023-10-25 14:49:03.916453 I ReleaseTools::Security::Publish::DeployBlogPost -- Adding blog post to the merge train -- {:blog_post=>"https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/130724"}
2023-10-25 14:49:04.169075 D ReleaseTools::GitlabClient -- [HTTParty] [2023-10-25 14:49:04 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/merge_requests/130724/pipelines" -
2023-10-25 14:49:06.000770 D ReleaseTools::GitlabClient -- [HTTParty] [2023-10-25 14:49:06 -0600] 201 "POST https://gitlab.com/api/v4/projects/7764/merge_trains/merge_requests/130724" 31253
=> [#<Gitlab::ObjectifiedHash:217160
Pending pipeline merge request
2023-10-25 14:43:46.705567 I ReleaseTools::Security::Publish::DeployBlogPost -- Assigning the blog post to the active release managers -- {:release_managers=>["dat.tang.gitlab", "rpereira2", "sabrams"]}
2023-10-25 14:43:46.705647 I ReleaseTools::Security::Publish::DeployBlogPost -- Approving the blog post -- {:blog_post=>"https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/130719"}
2023-10-25 14:43:46.705663 I ReleaseTools::Security::Publish::DeployBlogPost -- Fetching blog post approval information
2023-10-25 14:43:47.211018 D ReleaseTools::GitlabClient -- [HTTParty] [2023-10-25 14:43:47 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/merge_requests/130719/approvals" -
2023-10-25 14:43:47.211363 I ReleaseTools::Security::Publish::DeployBlogPost -- Blog post has one approval, skipping approval
2023-10-25 14:43:47.211379 I ReleaseTools::Security::Publish::DeployBlogPost -- Adding blog post to the merge train -- {:blog_post=>"https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/130719"}
2023-10-25 14:43:47.450663 D ReleaseTools::GitlabClient -- [HTTParty] [2023-10-25 14:43:47 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/merge_requests/130719/pipelines" -
2023-10-25 14:43:52.706889 D ReleaseTools::GitlabClient -- [HTTParty] [2023-10-25 14:43:52 -0600] 202 "POST https://gitlab.com/api/v4/projects/7764/merge_trains/merge_requests/130719" 31253
=> [#<Gitlab::ObjectifiedHash:217140 {hash
Recently created MR
2023-10-25 14:51:06.478047 I ReleaseTools::Security::Publish::DeployBlogPost -- Assigning the blog post to the active release managers -- {:release_managers=>["dat.tang.gitlab", "rpereira2", "sabrams"]}
2023-10-25 14:51:06.478116 I ReleaseTools::Security::Publish::DeployBlogPost -- Approving the blog post -- {:blog_post=>"https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/130728"}
2023-10-25 14:51:06.478131 I ReleaseTools::Security::Publish::DeployBlogPost -- Fetching blog post approval information
2023-10-25 14:51:07.025799 D ReleaseTools::GitlabClient -- [HTTParty] [2023-10-25 14:51:07 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/merge_requests/130728/approvals" -
2023-10-25 14:51:07.026138 I ReleaseTools::Security::Publish::DeployBlogPost -- Blog post has not approvals, proceeding to approve
2023-10-25 14:51:07.616839 D ReleaseTools::GitlabClient -- [HTTParty] [2023-10-25 14:51:07 -0600] 201 "POST https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/merge_requests/130728/approve" 5742
2023-10-25 14:51:07.617103 I ReleaseTools::Security::Publish::DeployBlogPost -- Adding blog post to the merge train -- {:blog_post=>"https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/130728"}
2023-10-25 14:51:07.921595 D ReleaseTools::GitlabClient -- [HTTParty] [2023-10-25 14:51:07 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/merge_requests/130728/pipelines" -
2023-10-25 14:51:08.400892 D ReleaseTools::GitlabClient -- [HTTParty] [2023-10-25 14:51:08 -0600] 202 "POST https://gitlab.com/api/v4/projects/7764/merge_trains/merge_requests/130728" 31253
=> [#<Gitlab::ObjectifiedHash:217160 {hash:

Author Check-list

  • [-] Has documentation been updated?
Edited by Mayra Cabrera

Merge request reports