Move HTTP calls for bitbucket server PR notes importer - Part 1

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA

What does this MR do and why?

See full context in !149302 (closed)

This is Part 1 from a series of MRs to handle issues: #451129 (closed).

  • Part 1 - Moving HTTP calls <-- This MR
  • Part 2 - Separate Importers Logic
  • Part 3 - Add Paging on HTTP Calls
  • This MR is under feature flag development, intended to be opened after the series of MRs are completed.
  • The main changes are moving API call (to Bitbucket Server) from Gitlab::BitbucketServerImport::Importers::PullRequestNotesImporter to Gitlab::BitbucketServerImport::Importers::NotesImporter
    • This will lessen the burden on the Bitbucket Server.
    • It makes the logic in PullRequestNotesImporter to process activities as a hash instead of an object. To make minimal changes as much as possible, this MR uses a hacky way in using OpenStruct. The proper way will be worked on Part 2. Other options that I can think of:
      1. Create a clone for import_merge_event, import_inline_comments, etc that supports hash instead of object
      2. Use another way to convert hash to object dynamically, probably using define_method recursively. It seems too much of an effort that will be removed, though.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
MR List:
Screenshot_2024-04-28_at_19.49.14
Approved Event:
Screenshot_2024-04-28_at_19.47.36
Standalone Comment:
Screenshot_2024-04-28_at_19.48.40
Inline Comment:
Screenshot_2024-04-28_at_01.06.35
Merge Event:
Screenshot_2024-04-28_at_19.52.04

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Initial environment setup can follow this
  2. Prepare some data in Bitbucket Server
  3. Patch the code to inject interruption:
diff --git a/gems/gitlab-http/lib/gitlab/http_v2/url_blocker.rb b/gems/gitlab-http/lib/gitlab/http_v2/url_blocker.rb
index 99876c779539..06bd0c6b92cd 100644
--- a/gems/gitlab-http/lib/gitlab/http_v2/url_blocker.rb
+++ b/gems/gitlab-http/lib/gitlab/http_v2/url_blocker.rb
@@ -64,6 +64,9 @@ def validate_url_with_proxy!(
         )
           # rubocop:enable Metrics/ParameterLists
 
+          allow_localhost = true
+          allow_local_network = true
+
           return Result.new(nil, nil, true) if url.nil?
 
           raise ArgumentError, 'The schemes is a required argument' if schemes.blank?
  1. Tail the log file: tail -f log/importer.log
  2. Go to http://127.0.0.1:3000/import/bitbucket_server/status
  3. Click Import
Edited by Ivan Sebastian

Merge request reports

Loading