qontract-reconcile 0.10.1rc928__py3-none-any.whl → 0.10.1rc929__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {qontract_reconcile-0.10.1rc928.dist-info → qontract_reconcile-0.10.1rc929.dist-info}/METADATA +1 -1
- {qontract_reconcile-0.10.1rc928.dist-info → qontract_reconcile-0.10.1rc929.dist-info}/RECORD +7 -7
- reconcile/gitlab_housekeeping.py +18 -0
- reconcile/utils/gitlab_api.py +4 -0
- {qontract_reconcile-0.10.1rc928.dist-info → qontract_reconcile-0.10.1rc929.dist-info}/WHEEL +0 -0
- {qontract_reconcile-0.10.1rc928.dist-info → qontract_reconcile-0.10.1rc929.dist-info}/entry_points.txt +0 -0
- {qontract_reconcile-0.10.1rc928.dist-info → qontract_reconcile-0.10.1rc929.dist-info}/top_level.txt +0 -0
{qontract_reconcile-0.10.1rc928.dist-info → qontract_reconcile-0.10.1rc929.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: qontract-reconcile
|
3
|
-
Version: 0.10.
|
3
|
+
Version: 0.10.1rc929
|
4
4
|
Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
|
5
5
|
Home-page: https://github.com/app-sre/qontract-reconcile
|
6
6
|
Author: Red Hat App-SRE Team
|
{qontract_reconcile-0.10.1rc928.dist-info → qontract_reconcile-0.10.1rc929.dist-info}/RECORD
RENAMED
@@ -30,7 +30,7 @@ reconcile/github_repo_permissions_validator.py,sha256=dcbXdUx6imjNchjp3pg9-z1i7l
|
|
30
30
|
reconcile/github_users.py,sha256=nfTq78QRONIfDVj-5O3bD6psllJjzWFnog-EJ1WqFPU,3672
|
31
31
|
reconcile/github_validator.py,sha256=cVTVxJIGR4a1Jz8wrdXEAb_CMpXUzvykVmUURX4cook,917
|
32
32
|
reconcile/gitlab_fork_compliance.py,sha256=EuF86CSUlzUQERu3CFjRujtX_dXAwSXBaWDl9Ij0LM8,4165
|
33
|
-
reconcile/gitlab_housekeeping.py,sha256=
|
33
|
+
reconcile/gitlab_housekeeping.py,sha256=5qIJPflQzwSg3iTSCw7ClEM4VHrn70WLXyYCX9vTZ7Y,22004
|
34
34
|
reconcile/gitlab_labeler.py,sha256=a7HToXqv4S72TBp6Dmu2OkjjO60k81kH3B0J4UXHs3A,4768
|
35
35
|
reconcile/gitlab_members.py,sha256=PrJE9OhDRdGG_gHM_77nQojLb4B18jtUu8DxgLsRS88,8417
|
36
36
|
reconcile/gitlab_mr_sqs_consumer.py,sha256=O46mdziPgGOndbU-0_UJKJVUaiEoVzJPEgKm4_UvYoI,2571
|
@@ -657,7 +657,7 @@ reconcile/utils/filtering.py,sha256=S4PbMHuFr3ED0P2Q_ea5CAaB7FimI62B-F5YTaKrphA,
|
|
657
657
|
reconcile/utils/git.py,sha256=actOWI2HiNpMIV6nHCzinhRa6b04Y9plWOCcPQa8lNA,1437
|
658
658
|
reconcile/utils/git_secrets.py,sha256=y1rEhwA8DyDpBSAEuhMS7Y2X3mpxT2zQ4zyDFkhLe_g,1936
|
659
659
|
reconcile/utils/github_api.py,sha256=R8OvqyPdnRqvP-Efnv9RvIcbBlb4M0KC4RlbnJMD0Tg,2426
|
660
|
-
reconcile/utils/gitlab_api.py,sha256=
|
660
|
+
reconcile/utils/gitlab_api.py,sha256=1hdcT6mnlWv3mj8JIdiKSx3_uxLy-UCt_uqwZTqLyW8,30344
|
661
661
|
reconcile/utils/gpg.py,sha256=EKG7_fdMv8BMlV5yUdPiqoTx-KrzmVSEAl2sLkaKwWI,1123
|
662
662
|
reconcile/utils/gql.py,sha256=IGhxzBcuebbapDKLseevEThSsxa_eDCPNpo3A4VnOS4,14066
|
663
663
|
reconcile/utils/grouping.py,sha256=vr9SFHZ7bqmHYrvYcEZt-Er3-yQYfAAdq5sHLZVmXPY,456
|
@@ -844,8 +844,8 @@ tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jr
|
|
844
844
|
tools/test/test_saas_promotion_state.py,sha256=dy4kkSSAQ7bC0Xp2CociETGN-2aABEfL6FU5D9Jl00Y,6056
|
845
845
|
tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
|
846
846
|
tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
|
847
|
-
qontract_reconcile-0.10.
|
848
|
-
qontract_reconcile-0.10.
|
849
|
-
qontract_reconcile-0.10.
|
850
|
-
qontract_reconcile-0.10.
|
851
|
-
qontract_reconcile-0.10.
|
847
|
+
qontract_reconcile-0.10.1rc929.dist-info/METADATA,sha256=f73mvCOMsE2ga7s23FBFZeqE8xtS7encuoWL-oL1HG8,2262
|
848
|
+
qontract_reconcile-0.10.1rc929.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
849
|
+
qontract_reconcile-0.10.1rc929.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
|
850
|
+
qontract_reconcile-0.10.1rc929.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
|
851
|
+
qontract_reconcile-0.10.1rc929.dist-info/RECORD,,
|
reconcile/gitlab_housekeeping.py
CHANGED
@@ -5,6 +5,7 @@ from collections.abc import (
|
|
5
5
|
)
|
6
6
|
from dataclasses import dataclass
|
7
7
|
from datetime import (
|
8
|
+
UTC,
|
8
9
|
datetime,
|
9
10
|
timedelta,
|
10
11
|
)
|
@@ -66,6 +67,7 @@ HOLD_LABELS = [
|
|
66
67
|
|
67
68
|
QONTRACT_INTEGRATION = "gitlab-housekeeping"
|
68
69
|
DATE_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
|
70
|
+
EXPIRATION_DATE_FORMAT = "%Y-%m-%d"
|
69
71
|
|
70
72
|
|
71
73
|
merged_merge_requests = Counter(
|
@@ -93,6 +95,12 @@ merge_requests_waiting = Gauge(
|
|
93
95
|
labelnames=["project_id"],
|
94
96
|
)
|
95
97
|
|
98
|
+
gitlab_token_expiration = Gauge(
|
99
|
+
name="qontract_reconcile_gitlab_token_expiration_days",
|
100
|
+
documentation="Time until personal access tokens expire",
|
101
|
+
labelnames=["name"],
|
102
|
+
)
|
103
|
+
|
96
104
|
|
97
105
|
class InsistOnPipelineError(Exception):
|
98
106
|
"""Exception used to retry a merge when the pipeline isn't yet complete."""
|
@@ -542,12 +550,22 @@ def get_app_sre_usernames(gl: GitLabApi) -> set[str]:
|
|
542
550
|
return {u.username for u in gl.get_app_sre_group_users()}
|
543
551
|
|
544
552
|
|
553
|
+
def publish_access_token_expiration_metrics(gl: GitLabApi) -> None:
|
554
|
+
pats = gl.get_personal_access_tokens()
|
555
|
+
for pat in pats:
|
556
|
+
expiration_date = datetime.strptime(pat.expires_at, EXPIRATION_DATE_FORMAT)
|
557
|
+
days_until_expiration = expiration_date.date() - datetime.now(UTC).date()
|
558
|
+
gitlab_token_expiration.labels(pat.name).set(days_until_expiration.days)
|
559
|
+
|
560
|
+
|
545
561
|
def run(dry_run, wait_for_pipeline):
|
546
562
|
default_days_interval = 15
|
547
563
|
default_limit = 8
|
548
564
|
default_enable_closing = False
|
549
565
|
instance = queries.get_gitlab_instance()
|
550
566
|
settings = queries.get_app_interface_settings()
|
567
|
+
with GitLabApi(instance, settings=settings) as gl:
|
568
|
+
publish_access_token_expiration_metrics(gl)
|
551
569
|
repos = queries.get_repos_gitlab_housekeeping(server=instance["url"])
|
552
570
|
app_sre_usernames: Set[str] = set()
|
553
571
|
|
reconcile/utils/gitlab_api.py
CHANGED
@@ -29,6 +29,7 @@ from gitlab.const import (
|
|
29
29
|
from gitlab.v4.objects import (
|
30
30
|
CurrentUser,
|
31
31
|
Group,
|
32
|
+
PersonalAccessToken,
|
32
33
|
Project,
|
33
34
|
ProjectIssue,
|
34
35
|
ProjectIssueManager,
|
@@ -862,3 +863,6 @@ class GitLabApi: # pylint: disable=too-many-public-methods
|
|
862
863
|
project = self.get_project(repo_url)
|
863
864
|
response: Any = project.repository_compare(ref_from, ref_to)
|
864
865
|
return response.get("commits", [])
|
866
|
+
|
867
|
+
def get_personal_access_tokens(self) -> list[PersonalAccessToken]:
|
868
|
+
return self.get_items(self.gl.personal_access_tokens.list)
|
File without changes
|
File without changes
|
{qontract_reconcile-0.10.1rc928.dist-info → qontract_reconcile-0.10.1rc929.dist-info}/top_level.txt
RENAMED
File without changes
|