diff --git a/PKG-INFO b/PKG-INFO index 025a1aa..479e3be 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,29 +1,25 @@ Metadata-Version: 2.1 Name: swh.icinga_plugins -Version: 0.5.1 +Version: 0.5.2 Summary: Icinga plugins for Software Heritage infrastructure monitoring Home-page: https://forge.softwareheritage.org/diffusion/swh-icinga-plugins Author: Software Heritage developers Author-email: swh-devel@inria.fr -License: UNKNOWN Project-URL: Bug Reports, https://forge.softwareheritage.org/maniphest Project-URL: Funding, https://www.softwareheritage.org/donate Project-URL: Source, https://forge.softwareheritage.org/source/swh-icinga-plugins -Platform: UNKNOWN Classifier: Programming Language :: Python :: 3 Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) Classifier: Operating System :: OS Independent Classifier: Development Status :: 3 - Alpha Requires-Python: >=3.7 Description-Content-Type: text/markdown Provides-Extra: testing License-File: LICENSE License-File: AUTHORS swh-icinga-plugins ================== Scripts for end-to-end monitoring of the SWH infrastructure - - diff --git a/debian/changelog b/debian/changelog index d8bda9a..e63db0c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,156 +1,159 @@ -swh.icingaplugins (0.5.1-1~swh1~bpo10+1) buster-swh; urgency=medium +swh.icingaplugins (0.5.2-1~swh1) unstable-swh; urgency=medium - * Rebuild for buster-swh + * New upstream release 0.5.2 - (tagged by Valentin Lorentz + on 2022-09-27 14:15:05 +0200) + * Upstream changes: - v0.5.2 - * SaveCodeNowCheck: Add support + for list of origins - -- Software Heritage autobuilder (on jenkins-debian1) Tue, 10 May 2022 16:16:24 +0000 + -- Software Heritage autobuilder (on jenkins-debian1) Tue, 27 Sep 2022 12:19:10 +0000 swh.icingaplugins (0.5.1-1~swh1) unstable-swh; urgency=medium * New upstream release 0.5.1 - (tagged by Vincent SELLIER on 2022-05-10 18:11:41 +0200) * Upstream changes: - v0.5.1 -- Software Heritage autobuilder (on jenkins-debian1) Tue, 10 May 2022 16:15:00 +0000 swh.icingaplugins (0.5.0-1~swh2) unstable-swh; urgency=medium * add a missing dependency -- Vincent Sellier Tue, 10 May 2022 14:14:10 +0200 swh.icingaplugins (0.5.0-1~swh1) unstable-swh; urgency=medium * New upstream release 0.5.0 - (tagged by Vincent SELLIER on 2022-05-10 09:16:08 +0200) * Upstream changes: - v0.5.0 - some changes in the tests - add prometheus metrics -- Software Heritage autobuilder (on jenkins-debian1) Tue, 10 May 2022 07:20:03 +0000 swh.icingaplugins (0.4.2-1~swh1) unstable-swh; urgency=medium * New upstream release 0.4.2 - (tagged by Valentin Lorentz on 2022-03-04 19:00:58 +0100) * Upstream changes: - v0.4.2 - * deposit: Properly escape URLs - * deposit: Check the status code of the REMD API. -- Software Heritage autobuilder (on jenkins-debian1) Fri, 04 Mar 2022 18:03:24 +0000 swh.icingaplugins (0.4.1-1~swh1) unstable-swh; urgency=medium * New upstream release 0.4.1 - (tagged by Valentin Lorentz on 2022-03-04 18:18:17 +0100) * Upstream changes: - v0.4.1 - * vault: Open tarballs in stream mode + add test for empty tar files - * deposit: Fetch only metadata created after the check started -- Software Heritage autobuilder (on jenkins-debian1) Fri, 04 Mar 2022 17:21:14 +0000 swh.icingaplugins (0.4.0-1~swh1) unstable-swh; urgency=medium * New upstream release 0.4.0 - (tagged by Nicolas Dandrimont on 2022-03-04 17:26:11 +0100) * Upstream changes: - Release swh-icinga-plugins 0.4.0 - more vault checks - cleaner deposit checks -- Software Heritage autobuilder (on jenkins-debian1) Fri, 04 Mar 2022 16:28:49 +0000 swh.icingaplugins (0.3.2-1~swh1) unstable-swh; urgency=medium * New upstream release 0.3.2 - (tagged by Nicolas Dandrimont on 2021-06-18 15:29:50 +0200) * Upstream changes: - Release swh.icinga_plugins 0.3.2 - Don't require type stub modules at runtime -- Software Heritage autobuilder (on jenkins-debian1) Fri, 18 Jun 2021 13:34:21 +0000 swh.icingaplugins (0.3.1-1~swh1) unstable-swh; urgency=medium * New upstream release 0.3.1 - (tagged by Nicolas Dandrimont on 2021-06-18 14:39:11 +0200) * Upstream changes: - Release swh.icinga.plugins v0.3.1 - Add missing f-string in assertion - CI related improvements -- Software Heritage autobuilder (on jenkins-debian1) Fri, 18 Jun 2021 12:43:49 +0000 swh.icingaplugins (0.3.0-1~swh1) unstable-swh; urgency=medium * New upstream release 0.3.0 - (tagged by Antoine R. Dumont (@ardumont) on 2021-04-16 15:56:31 +0200) * Upstream changes: - v0.3.0 - Add end to end save code now check -- Software Heritage autobuilder (on jenkins-debian1) Fri, 16 Apr 2021 13:58:24 +0000 swh.icingaplugins (0.2.3-1~swh1) unstable-swh; urgency=medium * New upstream release 0.2.3 - (tagged by Vincent SELLIER on 2021-01-19 10:58:01 +0100) * Upstream changes: - v0.2.3 - Remove the deprecated external_identifer from metadata -- Software Heritage autobuilder (on jenkins-debian1) Tue, 19 Jan 2021 10:00:42 +0000 swh.icingaplugins (0.2.2-1~swh1) unstable-swh; urgency=medium * New upstream release 0.2.2 - (tagged by Antoine R. Dumont (@ardumont) on 2021-01-14 13:17:42 +0100) * Upstream changes: - v0.2.2 - Fix test deposit -- Software Heritage autobuilder (on jenkins-debian1) Thu, 14 Jan 2021 12:19:05 +0000 swh.icingaplugins (0.2.1-1~swh1) unstable-swh; urgency=medium * New upstream release 0.2.1 - (tagged by Antoine R. Dumont (@ardumont) on 2020-10-20 19:43:22 +0200) * Upstream changes: - v0.2.1 - pytest.ini: Make django not load itself -- Software Heritage autobuilder (on jenkins-debian1) Tue, 20 Oct 2020 17:44:16 +0000 swh.icingaplugins (0.2.0-1~swh1) unstable-swh; urgency=medium * New upstream release 0.2.0 - (tagged by Antoine R. Dumont (@ardumont) on 2020-10-16 09:34:39 +0200) * Upstream changes: - v0.2.0 - Add deposit metadata update step in deposit icinga check - test_deposit: Refactor helper functions to improve maintenance - tox.ini: pin black to the pre- commit version (19.10b0) to avoid flip-flops -- Software Heritage autobuilder (on jenkins-debian1) Tue, 20 Oct 2020 16:41:57 +0000 swh.icingaplugins (0.1.0-1~swh1) unstable-swh; urgency=medium * New upstream release 0.1.0 - (tagged by David Douard on 2020-09-25 11:48:28 +0200) * Upstream changes: - v0.1.0 -- Software Heritage autobuilder (on jenkins-debian1) Tue, 20 Oct 2020 16:35:53 +0000 swh.icingaplugins (0.0.2-1+swh4) unstable-swh; urgency=medium * Add missing dependency -- Antoine R. Dumont (@ardumont) Tue, 22 Jan 2020 13:18:46 +0100 swh.icingaplugins (0.0.2-1+swh3) unstable-swh; urgency=medium * Bump to unstuck build -- Antoine R. Dumont (@ardumont) Tue, 21 Jan 2020 15:29:39 +0100 swh.icingaplugins (0.0.2-1+swh2) unstable-swh; urgency=medium * Bump to unstuck build -- Antoine R. Dumont (@ardumont) Tue, 21 Jan 2020 01:47:36 +0100 swh.icingaplugins (0.0.2-1+swh1) unstable-swh; urgency=medium * Initial packaging for swh.icingaplugins -- Antoine R. Dumont (@ardumont) Mon, 20 Jan 2020 18:48:41 +0100 diff --git a/swh.icinga_plugins.egg-info/PKG-INFO b/swh.icinga_plugins.egg-info/PKG-INFO index db964d0..0d4b582 100644 --- a/swh.icinga_plugins.egg-info/PKG-INFO +++ b/swh.icinga_plugins.egg-info/PKG-INFO @@ -1,29 +1,25 @@ Metadata-Version: 2.1 Name: swh.icinga-plugins -Version: 0.5.1 +Version: 0.5.2 Summary: Icinga plugins for Software Heritage infrastructure monitoring Home-page: https://forge.softwareheritage.org/diffusion/swh-icinga-plugins Author: Software Heritage developers Author-email: swh-devel@inria.fr -License: UNKNOWN Project-URL: Bug Reports, https://forge.softwareheritage.org/maniphest Project-URL: Funding, https://www.softwareheritage.org/donate Project-URL: Source, https://forge.softwareheritage.org/source/swh-icinga-plugins -Platform: UNKNOWN Classifier: Programming Language :: Python :: 3 Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) Classifier: Operating System :: OS Independent Classifier: Development Status :: 3 - Alpha Requires-Python: >=3.7 Description-Content-Type: text/markdown Provides-Extra: testing License-File: LICENSE License-File: AUTHORS swh-icinga-plugins ================== Scripts for end-to-end monitoring of the SWH infrastructure - - diff --git a/swh/icinga_plugins/save_code_now.py b/swh/icinga_plugins/save_code_now.py index 1922225..69c2d89 100644 --- a/swh/icinga_plugins/save_code_now.py +++ b/swh/icinga_plugins/save_code_now.py @@ -1,124 +1,129 @@ -# Copyright (C) 2021 The Software Heritage developers +# Copyright (C) 2021-2022 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +import random import time -from typing import Dict, List +from typing import Dict, List, Union import requests from .base_check import BaseCheck REPORT_MSG = "Save code now request for origin" WAITING_STATUSES = ("not yet scheduled", "running", "scheduled") class SaveCodeNowCheck(BaseCheck): TYPE = "SAVECODENOW" DEFAULT_WARNING_THRESHOLD = 60 DEFAULT_CRITICAL_THRESHOLD = 120 - def __init__(self, obj: Dict, origin: str, visit_type: str) -> None: + def __init__( + self, obj: Dict, origin: Union[str, List[str]], visit_type: str + ) -> None: super().__init__(obj, application="scn") + if isinstance(origin, list): + origin = random.choice(origin) self.api_url = obj["swh_web_url"].rstrip("/") self.poll_interval = obj["poll_interval"] self.origin = origin self.visit_type = visit_type self.register_prometheus_gauge("duration", "seconds", ["status"]) self.register_prometheus_gauge("status", "") @staticmethod def api_url_scn(root_api_url: str, origin: str, visit_type: str) -> str: """Compute the save code now api url for a given origin""" return f"{root_api_url}/api/1/origin/save/{visit_type}/url/{origin}/" def main(self) -> int: """Scenario description: - 1. Requests a save code now request via the api for origin self.origin with type - self.visit_type. + 1. Requests a save code now request via the api for the given origin (or + an origin picked at random in the list) with type self.visit_type. 2. Polling regularly at self.poll_interval seconds the completion status. 3. When either succeeded, failed or threshold exceeded, report approximate time of completion. This will warn if thresholds are exceeded. """ start_time: float = time.time() total_time: float = 0.0 scn_url = self.api_url_scn(self.api_url, self.origin, self.visit_type) response = requests.post(scn_url) assert response.status_code == 200, (response, response.text) result: Dict = response.json() status_key = "save_task_status" request_date = result["save_request_date"] origin_info = (self.visit_type, self.origin) while result[status_key] in WAITING_STATUSES: time.sleep(self.poll_interval) response = requests.get(scn_url) assert ( response.status_code == 200 ), f"Unexpected response: {response}, {response.text}" raw_result: List[Dict] = response.json() assert len(raw_result) > 0, f"Unexpected result: {raw_result}" if len(raw_result) > 1: # retrieve only the one status result we are interested in result = next( filter(lambda r: r["save_request_date"] == request_date, raw_result) ) else: result = raw_result[0] # this because the api can return multiple entries for the same origin assert result["save_request_date"] == request_date total_time = time.time() - start_time if total_time > self.critical_threshold: self.print_result( "CRITICAL", f"{REPORT_MSG} {origin_info} took more than {total_time:.2f}s " f'and has status: {result["save_task_status"]}.', total_time=total_time, ) self.collect_prometheus_metric("duration", total_time, ["timeout"]) self.collect_prometheus_metric("status", 2) return 2 if result[status_key] == "succeeded": (status_code, status) = self.get_status(total_time) self.print_result( status, f"{REPORT_MSG} {origin_info} took {total_time:.2f}s and succeeded.", total_time=total_time, ) self.collect_prometheus_metric("duration", total_time, ["succeeded"]) self.collect_prometheus_metric("status", status_code) return status_code elif result[status_key] == "failed": self.print_result( "CRITICAL", f"{REPORT_MSG} {origin_info} took {total_time:.2f}s and failed.", total_time=total_time, ) self.collect_prometheus_metric("duration", total_time, ["failed"]) self.collect_prometheus_metric("status", 2) return 2 else: self.print_result( "CRITICAL", f"{REPORT_MSG} {origin_info} took {total_time:.2f}s " "and resulted in unsupported status: " f"{result['save_request_status']} ; {result[status_key]}.", total_time=total_time, ) self.collect_prometheus_metric("duration", total_time, ["failed"]) self.collect_prometheus_metric("status", 2) return 2