Skip to content

Validate Epic Work Item sync

Nicolas Dular requested to merge nd/epic-work-item-sync-validation into master

What does this MR do and why?

This publishes an EpicCreatedEvent and EpicUpdatedEvent which the ValidateEpicWorkItemSyncWorker subscribes to. As part of the validation we check if any attribute is different from the work item compared to the epic.

We then log the attributes that mismatch as a warning. We do explicitly not log the actual data to prevent leaking any sensitive information.

Issue: #438548 (closed)

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

In this recording I force a mismatch on title on creation, and force a mismatch on description on update. In the video you can see that on the creation of the epic, we have a mismatched title and updated_at. title is expected - updated_at is likely a bug already. After the update, the updated_at and title value gets fixed again because we sync them. However description is now a mismatch (as expected).

Screen_Recording_2024-02-13_at_17.48.45

Before After

How to set up and validate locally

  1. Restart rails-web and rails-background-job (background jobs often get stuck, and to register new events, rails needs to be restarted)
  2. Feature.enable(:validate_epic_work_item_sync)
  3. Feature.enable(:epic_creation_with_synced_work_item)
  4. Apply the diff to create a mismatch of data:
    diff --git a/ee/app/services/concerns/epics/sync_as_work_item.rb b/ee/app/services/concerns/epics/sync_as_work_item.rb
    index f9822034f2f2..c92193419293 100644
    --- a/ee/app/services/concerns/epics/sync_as_work_item.rb
    +++ b/ee/app/services/concerns/epics/sync_as_work_item.rb
    @@ -15,7 +15,7 @@ def create_work_item_for!(epic)
           service_response = ::WorkItems::CreateService.new(
             container: epic.group,
             current_user: current_user,
    -        params: create_params(epic)
    +        params: create_params(epic).merge(title: "WRONG SYNCED TITLE")
           ).execute_without_rate_limiting
    
           handle_response!(:create, service_response, epic)
    @@ -31,7 +31,7 @@ def update_work_item_for!(epic)
           service_response = ::WorkItems::UpdateService.new(
             container: epic.group,
             current_user: current_user,
    -        params: update_params(epic)
    +        params: update_params(epic).merge(description: "WRONG SYNCED DESCRIPTION")
           ).execute(epic.work_item)
    
           handle_response!(:update, service_response, epic)
  5. Watch the log tail -f log/epic_work_item_sync.log
  6. Create an epic
  7. Update an epic
  8. Watch the log printing out the mismatched attributes
Edited by Nicolas Dular

Merge request reports