Skip to content

Commit

Permalink
Merge #2337
Browse files Browse the repository at this point in the history
2337: Add heartbeat check for Remote Settings config r=tiftran a=leplatrem



Co-authored-by: Mathieu Leplatre <mathieu@mozilla.com>
  • Loading branch information
bors[bot] and leplatrem committed Jan 24, 2022
2 parents 946a509 + 11b1169 commit 8cb1991
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
18 changes: 17 additions & 1 deletion normandy/recipes/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import requests.exceptions

from normandy.recipes import signing, geolocation
from normandy.recipes import exports, signing, geolocation


INFO_COULD_NOT_RETRIEVE_ACTIONS = "normandy.recipes.I001"
Expand All @@ -23,6 +23,7 @@
ERROR_COULD_NOT_VERIFY_CERTIFICATE = "normandy.recipes.E005"
ERROR_GEOIP_DB_NOT_AVAILABLE = "normandy.recipes.E006"
ERROR_GEOIP_DB_UNEXPECTED_RESULT = "normandy.recipes.E007"
ERROR_REMOTE_SETTINGS_INCORRECT_CONFIG = "normandy.recipes.E008"


def actions_have_consistent_hashes(app_configs, **kwargs):
Expand Down Expand Up @@ -187,9 +188,24 @@ def geoip_db_is_available(app_configs, **kwargs):
return errors


def remotesettings_config_is_correct(app_configs, **kwargs):
errors = []
try:
exports.RemoteSettings().check_config()
except ImproperlyConfigured as e:
errors.append(
Error(
f"Remote Settings config is incorrect: {e}",
id=ERROR_REMOTE_SETTINGS_INCORRECT_CONFIG,
)
)
return errors


def register():
register_check(actions_have_consistent_hashes)
register_check(recipe_signatures_are_correct)
register_check(action_signatures_are_correct)
register_check(signatures_use_good_certificates)
register_check(geoip_db_is_available)
register_check(remotesettings_config_is_correct)
10 changes: 10 additions & 0 deletions normandy/recipes/tests/test_checks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import timedelta

from django.core.exceptions import ImproperlyConfigured
from django.db.utils import ProgrammingError

import pytest
Expand Down Expand Up @@ -93,3 +94,12 @@ def test_it_warns_if_a_field_isnt_available(self, mocker):
errors = checks.action_signatures_are_correct(None)
assert len(errors) == 1
assert errors[0].id == checks.WARNING_COULD_NOT_CHECK_SIGNATURES


class TestRemoteSettingsConfigIsCorrect:
def test_it_warns_if_remote_settings_config_is_incorrect(self, mocker):
mock_check_config = mocker.patch("normandy.recipes.exports.RemoteSettings.check_config")
mock_check_config.side_effect = ImproperlyConfigured("error for testing")
errors = checks.remotesettings_config_is_correct(None)
assert len(errors) == 1
assert errors[0].id == checks.ERROR_REMOTE_SETTINGS_INCORRECT_CONFIG

0 comments on commit 8cb1991

Please sign in to comment.