| |
@@ -102,6 +102,48 @@
|
| |
|
| |
assert client[pdc_api][123].mock_calls == [call._.__iadd__({"koji_tag": "tag"})]
|
| |
|
| |
+ @patch("toddlers.plugins.pdc_modules.pdc_client_for_config")
|
| |
+ def test_process_failing_uid(self, pdc, caplog, toddler):
|
| |
+ caplog.set_level(logging.INFO)
|
| |
+
|
| |
+ client = MagicMock()
|
| |
+ pdc_api = "modules"
|
| |
+ pdc.return_value = client
|
| |
+
|
| |
+ msg = fedora_messaging.api.Message()
|
| |
+ msg.id = 123
|
| |
+ msg.topic = "org.fedoraproject.prod.mbs.module.state.change"
|
| |
+ msg.body = {
|
| |
+ "state_name": "build",
|
| |
+ "name": "module",
|
| |
+ "stream": 6,
|
| |
+ "version": 6.1,
|
| |
+ "koji_tag": "tag",
|
| |
+ }
|
| |
+ uid = "module:6:6.1:00000000"
|
| |
+
|
| |
+ res = Mock()
|
| |
+ res.status_code = 404
|
| |
+ client[pdc_api][uid]._.__iadd__.side_effect = beanbag.BeanBagException(
|
| |
+ res, "foo!"
|
| |
+ )
|
| |
+
|
| |
+ toddler.process({"config": "foobar"}, msg)
|
| |
+
|
| |
+ print(client[pdc_api]._.mock_calls)
|
| |
+
|
| |
+ assert call(page_size=1) in client[pdc_api]._.mock_calls
|
| |
+ assert call(page_size=-1, uid=uid) in client[pdc_api]._.mock_calls
|
| |
+
|
| |
+ assert client[pdc_api][123].mock_calls == [call._.__iadd__({"koji_tag": "tag"})]
|
| |
+
|
| |
+ assert len(caplog.records) == 2
|
| |
+ # the uid is a mock object, so I can't check it in the string of the exception
|
| |
+ assert caplog.records[-1].message.startswith(
|
| |
+ "Failed to update PDC (modules) for uid: "
|
| |
+ )
|
| |
+ assert caplog.records[-1].message.endswith("and koji_tag: tag")
|
| |
+
|
| |
@patch("toddlers.plugins.pdc_modules.koji")
|
| |
@patch("toddlers.plugins.pdc_modules.Modulemd")
|
| |
@patch("toddlers.plugins.pdc_modules.pdc_client_for_config")
|
| |
We have observed in production that the messages:
https://apps.fedoraproject.org/datagrepper/id?id=2020-dfeecf92-ebd8-4057-9758-f6ca86857b3b&is_raw=true&size=extra-large
and
https://apps.fedoraproject.org/datagrepper/id?id=2020-7b68144c-d96f-4dff-b52c-ca104f30ffef&is_raw=true&size=extra-large
do not pass the pdc_modules toddler.
They lead to the following backtrace:
So apparently, we fail to update PDC for some reason (no idea what
triggers the 404).
This commit allows to log that exception and discard the action since:
a) we don't know what triggered the 404
b) the old pdc-updater client would ignore these errors just like we will
do now and no-one seems to have complained about it
So here we go!
Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr