Sam Word (de00087f) at 19 Mar 15:33
Updated GraphQL introspection json
@timmccarthy this looks good to me as well!
This MR adds missing belongs_to associations to the Geo Design Management Repository State model to support organization transfer functionality.
Models updated:
Geo::DesignManagementRepositoryStateThis is part of a series of MRs split from !227325 to add missing associations across ~70 models.
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
This MR is part of a series splitting !227325 into smaller domain-specific changes:
| Domain | MR |
|---|---|
| Geo models | !227739 |
| Compliance & Audit Events | !227789 |
| Merge Requests | !227790 |
| Alert Management | !227791 |
| Clusters | !227792 |
| Design Management | !227793 |
| Issues (Core) | !227794 |
| Issues (Related) | !227795 |
| Notes & Suggestions | !227796 |
| Deployments & Misc | !227797 |
| Analytics & Misc CE | !227798 |
| EE Approval Rules | !227799 |
| EE Boards & Epics | !227800 |
| EE On-call | !227801 |
| EE Misc | !227802 |
Reviewer note: I took a guess at what the rate limit should be, but here's my thinking: I figure there's not much value in requesting this endpoint in somewhat quick succession for the same source user because it just enqueues a background job to retry reassignment that will either succeed or fail. If it succeeds, then subsequent requests to this request fail as the source user is no longer failed. If it repeatedly fails, I don't want to put too much pressure on our background workers if it keeps failing.
This adds a GraphQL mutation to allow users to retry failed placeholder reassignments via the API using a new service implemented in !227954.
Follow the validation steps in !227954 to create a source user and make it fail, but use the new mutation to retry the failed reassignment instead of the console
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #589777
Hey @rodrigo.tomonari
This is what other source user action services like AcceptReassignmentService and ReassignService do so I'll leave this as-is for consistency
This service inherits from top-level
BaseService
If these come from
Import::SourceUsers::BaseService, this class should inherit from that class (or include the module) to avoid runtime failures.
???
They're assigned with attr_reader in Import::SourceUsers::BaseService, which is this service inherits from. Additionally, testing locally never raised a NameError at runtime
Sam Word (10f1fe14) at 18 Mar 21:09
GraphQL mutation to retry failed reassigments
... and 5 more commits
Reviewer note: The ability to manage source user reassignments was named admin_import_source_user before this check was implemented and it's out of this MR's scope to change
When a placeholder user reassignment fails after an import, the Import::SourceUser record gets stuck in a FAILED status with no way to retry or recover. This MR adds a new service that allows top-level group owners to retry failed placeholder reassignments as part of implementing a "retry" action.
A new GraphQL mutation to call this service will be implemented in a subsequent MR and no other components call the new service yet. This MR is part of the implementation of #589777
Because nothing calls this service, validate by checking that specs pass and the service performs as expected in the console:
Import::SourceUser in the console, but I recommend performing an import to simulate a real failure with user contributionsdiff --git a/app/services/import/reassign_placeholder_user_records_service.rb b/app/services/import/reassign_placeholder_user_records_service.rb
index bf7fdf2ca26669..7a2597b045e82c 100644
--- a/app/services/import/reassign_placeholder_user_records_service.rb
+++ b/app/services/import/reassign_placeholder_user_records_service.rb
@@ -31,6 +31,7 @@ def execute
reassign_placeholder_references
+ raise StandardError, 'Break before reassigning memberships'
delete_remaining_references
if placeholder_memberships.any?
diff --git a/app/workers/import/reassign_placeholder_user_records_worker.rb b/app/workers/import/reassign_placeholder_user_records_worker.rb
index b1294989ee8a73..df7bc18678cc2b 100644
--- a/app/workers/import/reassign_placeholder_user_records_worker.rb
+++ b/app/workers/import/reassign_placeholder_user_records_worker.rb
@@ -11,7 +11,7 @@ class ReassignPlaceholderUserRecordsWorker
data_consistency :sticky
feature_category :importers
deduplicate :until_executed
- sidekiq_options retry: 5, dead: false
+ sidekiq_options retry: 1, dead: false
sidekiq_options max_retries_after_interruption: 20
concurrency_limit -> { 4 }
reassignment_error on the failed source user to anything in the console if !227775 hasn't been merged (optional)ReassignPlaceholderUserRecordsWorker and/or ReassignPlaceholderUserRecordsService
Import::SourceUsers::RetryFailedReassignmentService with the failed source user and an owner on the source user's namespacereassignment_in_progress (2) statusAdditional validations on the service:
current_user must be able to admin_import_source_user, which is enabled when they can admin_namespace on the source user's namespaceEvaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #589777
- How we calculate strict success vs failure/timeout
FWIW, 3rd party project imports and project file imports don't have the exact same statuses as direct transfer. If I remember correctly, all project imports use ProjectImportState to track import status and last error. That would mean project import statuses don't line up exactly with direct transfer, and might impact whether we can include DT and project imports in the same visualizations:
| Direct transfer status | Does it map to project imports? |
|---|---|
| failed | Yes |
| timeout | Not well ProjectImportState does not have a :timeout status like direct transfer. It has a last_error attribute, and the error message there might be clear enough to parse as a timeout |
| success partially | Maybe? :success status and a last_error similar to DT, but I don't know if any importer sets last_error without setting status to failed
|
| success | Yes |
| canceled (not in list above) | Also present in project imports as long as the importer supports it |
I added this and the rollout issue for offline_transfer_exports to the beta epic: gitlab-org#21009
Hey @reza-marandi
Development update: I implemented nearly everything locally before realizing it was way too big to put into one MR. I'm breaking it up into smaller MRs instead. That also gives us an excuse to use a WIP/derisk feature flag that we can use in case my guess at rate limits is way off
cancel_placeholder_user_reassignment
Previously, when a source user failed reassignment, the failure's exception message was logged to importer.log but not persisted to the reassignment_error column on the source user record, even though the column exists and is already on ImportSourceUser GraphQL objects. This MR updates Import::ReassignPlaceholderUserRecordsWorker to truncate and save the failure exception so that it can be returned when querying for source users in the API. This change will support implementing retrying failed placeholder reassignments.
The UI was technically already displaying the error message on the placeholder user table, but it was never visible because we never persisted it:
Import::ReassignPlaceholderUserRecordsWorker to raise an error. Otherwise, you're unlikely to get the reassignment to fail. Something like:diff --git a/app/workers/import/reassign_placeholder_user_records_worker.rb b/app/workers/import/reassign_placeholder_user_records_worker.rb
index 0004fbc1c95e24..f6e64c64861b32 100644
--- a/app/workers/import/reassign_placeholder_user_records_worker.rb
+++ b/app/workers/import/reassign_placeholder_user_records_worker.rb
@@ -11,7 +11,7 @@ class ReassignPlaceholderUserRecordsWorker
data_consistency :sticky
feature_category :importers
deduplicate :until_executed
- sidekiq_options retry: 5, dead: false
+ sidekiq_options retry: 1, dead: false
sidekiq_options max_retries_after_interruption: 20
concurrency_limit -> { 4 }
@@ -20,6 +20,8 @@ class ReassignPlaceholderUserRecordsWorker
end
def perform(import_source_user_id, params = {})
+ raise StandardError, 'PG::QueryCanceled: ERROR: canceling statement due to statement timeout'
+
@import_source_user = Import::SourceUser.find_by_id(import_source_user_id)
return unless import_source_user_valid?
ImportSourceUser that just failed. Validate reassignmentError matches the message thrown in step 2.Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #589777
Sam Word (4143c72b) at 17 Mar 20:23
Persist reassignment error to source user on failure