Skip to content

Restrict type changes for legacy HTTP integrations

What does this MR do and why?

The URL for legacy alert integrations is determined by an integration's type. This MR prevents the ability to accidentally change the URL by changing the type.

This is not user-facing - yet (alert integration types will be modifyable via API in !120197).

Context

Users can't create non-default integration types yet. That'll be added in !120197 & a bunch of records will be backfilled in !123217 (merged). I want to get the logic ironed out before records start getting added to the database & we're stuck with it.

Related issue: #338838

How to set up and validate locally

This change can be tested via the rails console.

  1. Find/create existing integration
# find
integration = AlertManagement::HttpIntegration.where(endpoint_identifier: 'legacy').last
# create
integration = AlertManagement::HttpIntegration.create!(project_id: <PROJECT ID>, active: false, name: 'Name', endpoint_identifier: 'legacy')
  1. Update to a different type from the existing integration (:http or :prometheus)
AlertManagement::HttpIntegrations::UpdateService.new(integration, User.first, { type_identifier: :prometheus }).execute
  1. See error response
=> #<ServiceResponse:0x000000012f65dff8
 @http_status=nil,
 @message="Cannot change integration type for legacy integrations. Create a new integration instead",
 @payload={},
 @reason=nil,
 @status=:error>

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sarah Yasonik

Merge request reports