grafana/pkg/services/ngalert/api/tooling/definitions
Matthew Jacobson e3787de470
Alerting: Fix Alertmanager change detection for receivers with secure settings (#71307)
* Alerting: Make ApplyAlertmanagerConfiguration only decrypt/encrypt new/changed secure settings

Previously, ApplyAlertmanagerConfiguration would decrypt and re-encrypt all secure settings. However, this caused re-encrypted secure settings to be included in the raw configuration when applied to the embedded alertmanager, resulting in changes to the hash. Consequently, even if no actual modifications were made, saving any alertmanager configuration triggered an apply/restart and created a new historical entry in the database.

To address the issue, this modifies ApplyAlertmanagerConfiguration, which is called by POST `api/alertmanager/grafana/config/api/v1/alerts`, to decrypt and re-encrypt only new and updated secure settings. Unchanged secure settings are loaded directly from the database without alteration.

We determine whether secure settings have changed based on the following (already in-use) assumption: Only new or updated secure settings are provided via the POST `api/alertmanager/grafana/config/api/v1/alerts` request, while existing unchanged settings are omitted.

* Ensure saving a grafana-managed contact point will only send new/changed secure settings

Previously, when saving a grafana-managed contact point, empty string values were transmitted for all unset secure settings. This led to potential backend issues, as it assumed that only newly added or updated secure settings would be provided.

To address this, we now exclude empty ('', null, undefined) secure settings, unless there was a pre-existing entry in secureFields for that specific setting. In essence, this means we only transmit an empty secure setting if a previously configured value was cleared.

* Fix linting

* refactor omitEmptyUnlessExisting

* fixup

---------

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
2023-07-11 08:23:07 +02:00
..
admin.go Alerting: hide "silence" button for external AM setups (#62133) 2023-02-01 15:51:05 +01:00
alertmanager_test_artifact.json Alerting: support mute timings configuration through the api for the embedded alertmanager (#41533) 2021-11-19 16:50:55 +01:00
alertmanager_test_artifact.yaml Alerting: support mute timings configuration through the api for the embedded alertmanager (#41533) 2021-11-19 16:50:55 +01:00
alertmanager_test.go Alerting: replace usage of simplejson to json.RawMessage in NotificationChannelConfig (#60423) 2022-12-16 13:01:06 -05:00
alertmanager_validation_test.go Alerting: Fix template validation in provisioning api (#62530) 2023-02-02 15:26:39 -05:00
alertmanager_validation.go Alerting: Fix template validation in provisioning api (#62530) 2023-02-02 15:26:39 -05:00
alertmanager.go Alerting: Fix Alertmanager change detection for receivers with secure settings (#71307) 2023-07-11 08:23:07 +02:00
api.go Chore: Upgrade Go to 1.19.1 (#54902) 2022-09-12 12:03:49 +02:00
cortex-ruler_test.go Alerting: Fix rule API to accept 0 duration of field For (#50992) 2022-06-30 11:46:26 -04:00
cortex-ruler.go Alerting: introduce AlertQuery in definitions package (#63825) 2023-03-27 11:55:13 -04:00
eval_condition.go Alerting: introduce AlertQuery in definitions package (#63825) 2023-03-27 11:55:13 -04:00
prom_test.go Alerting: Add limits and filters to Prometheus Rules API (#66627) 2023-04-17 17:45:06 +01:00
prom.go Alerting: Add totalsFiltered to RuleResponse for hidden by filters count (#66883) 2023-04-21 09:35:12 +01:00
provisioning_alert_rules.go Alerting: Remove dependency on alerting package in definitions (#65390) 2023-03-29 13:34:59 -04:00
provisioning_contactpoints.go Alerting: Remove dependency on alerting package in definitions (#65390) 2023-03-29 13:34:59 -04:00
provisioning_mute_timings.go Alerting: decouple api models from domain\dto models: separate Provenance status + converters (#63594) 2023-02-27 17:57:15 -05:00
provisioning_policies.go Alerting: Add method to reset notification policy tree back to the default (#51934) 2022-07-08 16:23:18 -05:00
provisioning_templates.go Alerting: decouple api models from domain\dto models: separate Provenance status + converters (#63594) 2023-02-27 17:57:15 -05:00
ruler_state_history.go Alerting: Repurpose rule testing endpoint to return potential alerts (#69755) 2023-06-08 18:59:54 -04:00
shared.go Alerting: Fix rendering issues in OpenAPI docs (#50630) 2022-06-13 12:51:07 -05:00
testing_test.go Alerting: introduce AlertQuery in definitions package (#63825) 2023-03-27 11:55:13 -04:00
testing.go Alerting: Repurpose rule testing endpoint to return potential alerts (#69755) 2023-06-08 18:59:54 -04:00