Remove enforce_audit_streaming_destination_limits feature flag

What does this MR do and why?

Removes the enforce_audit_streaming_destination_limits feature flag. It is on for all groups on GitLab.com, so the two limits it gated now always block: 50 audit streaming destinations per group (inactive ones included, checked on create only), and 10 calls per user per minute shared by the group destination create and update GraphQL mutations.

On self-managed and Dedicated, both limits start blocking in 19.7. Before, they only logged there.

  • Removes the flag check in ee/app/models/concerns/audit_events/activatable.rb. The log-only line "Audit streaming destination total limit exceeded" is gone.
  • Removes the flag check in ee/app/graphql/mutations/concerns/mutations/audit_events/destination_rate_limitable.rb. Throttled calls are blocked and still logged to auth_json.log.
  • Drops the group argument from destination_rate_limited? (it was only used for the flag check) and updates the 8 mutations that call it.
  • Deletes the flag YAML definition.
  • Updates doc/administration/instance_limits.md.

References

  • !267270 (merged) ("Cap audit streaming destinations and rate limit their mutations")
  • #638126 ("[FF] enforce_audit_streaming_destination_limits -- Enforce the audit streaming destination cap and mutation rate limit")

Screenshots or screen recordings

No UI change.

How to set up and validate locally

You need a GDK with an Ultimate license. The snippet uses the seed group flightjs and root, and cleans up after itself.

  1. On master, open bin/rails console.
  2. Paste the snippet below and note the output.
  3. Switch to this branch, restart the console, paste the snippet again, and compare.
group = Group.find_by_full_path('flightjs')
user = User.find_by_username('root')
model = AuditEvents::Group::ExternalStreamingDestination

puts "Flag defined: #{Feature::Definition.get(:enforce_audit_streaming_destination_limits).present?}"
puts "Flag enabled for group: #{Feature.enabled?(:enforce_audit_streaming_destination_limits, group)}" if Feature::Definition.get(:enforce_audit_streaming_destination_limits)

begin
# 1. Total cap: fill the group to 50 inactive destinations, then try one more.
created = []
while model.where(group: group).count < 50
  created << model.create!(group: group, category: 'http', active: false, name: "cap-check-#{SecureRandom.hex(4)}",
    config: { 'url' => "https://example.com/#{SecureRandom.hex(4)}" }, secret_token: SecureRandom.hex(10))
end
extra = model.new(group: group, category: 'http', active: false, name: 'cap-check-51',
  config: { 'url' => 'https://example.com/51' }, secret_token: SecureRandom.hex(10))
puts "51st destination valid?: #{extra.valid?} #{extra.errors.full_messages}"

# 2. Rate limit: 11 updates in a row as the same user.
query = <<~GQL
  mutation($id: AuditEventsGroupExternalStreamingDestinationID!, $name: String) {
    groupAuditEventStreamingDestinationsUpdate(input: { id: $id, name: $name }) { errors }
  }
GQL
target = created.first || model.where(group: group).first
results = (1..11).map do |i|
  GitlabSchema.execute(query, context: { current_user: user },
    variables: { 'id' => target.to_global_id.to_s, 'name' => "cap-check-rename-#{i}" })
    .dig('data', 'groupAuditEventStreamingDestinationsUpdate', 'errors')
end
puts "Update errors per call: #{results.inspect}"
ensure
  created&.each(&:destroy)
end

Wait a minute between runs, because the rate limit counter is per user per minute.

Expected on master (flag off):

51st destination valid?: true []

followed by 11 empty error arrays.

Expected on this branch:

51st destination valid?: false ["Maximum number of external audit event destinations (50) exceeded, including inactive ones. Delete unused destinations to add more."]

and the 11th call returns:

["This endpoint has been requested too many times. Try again later."]

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Merge request reports

Loading
Loading