Skip to content

Group push rules: stop updating push_rules table

Implementation plan

We should stop updating the push_rules table when defined per group. Now, we should start updating the new group_push_rules table. For this purpose, we should apply the following changes:

  • In ee/app/controllers/groups/push_rules_controller.rb we should replace PushRules::CreateOrUpdateService by a new service GroupPushRules::CreateOrUpdateService.
  • In ee/lib/api/group_push_rule.rb we should replace PushRules::CreateOrUpdateService by the new service GroupPushRules::CreateOrUpdateService.
  • In the new service, use something like the following (adapt it as needed) to replicate PushRules::CreateOrUpdateService logic:
# frozen_string_literal: true

module GroupPushRules
  class CreateOrUpdateService < BaseContainerService
    def execute
      group_push_rule = container.group_push_rule || container.build_group_push_rule

      if push_rule.update(params)
        ::Repositories::GroupPushRulesChangesAuditor.new(current_user, push_rule).execute

        ServiceResponse.success(payload: { group_push_rule: group_push_rule })
      else
        error_message = group_push_rule.errors.full_messages.to_sentence
        ServiceResponse.error(message: error_message, payload: { group_push_rule: group_push_rule })
      end
    end
  end
end

Expectations

  • The output of Groups::PushRulesController#update should remain the same. We are changing the underlying logic to populate the group_push_rule table.
  • Introduce a new FF (i.e update_group_push_rules) to control the usage of the new GroupPushRules::CreateOrUpdateService service. If the FF is off then we should continue using the old implementation. Suggestion in #500481 (comment 2445218459).
  • Create the rollout and cleanup issues for the new FF (update_group_push_rules).
  • Provide enough tests to cover the new implementation and ensure there are no regressions introduced when the FF is off.
Edited by 🤖 GitLab Bot 🤖