qontract-reconcile 0.10.1rc825__py3-none-any.whl → 0.10.1rc826__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qontract-reconcile
3
- Version: 0.10.1rc825
3
+ Version: 0.10.1rc826
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
@@ -445,7 +445,7 @@ reconcile/statuspage/state.py,sha256=HD9EOoKm_nEqCMLIwW809En3cq5VhyzKJPUbsh-bae8
445
445
  reconcile/statuspage/status.py,sha256=mfRJ_tW7jM4_Vy_1cc8C0fKJEoA2GwrA3gJeV1KImAw,2834
446
446
  reconcile/statuspage/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
447
447
  reconcile/statuspage/integrations/components.py,sha256=49KHd_E9AdRvcEA6n75q1McZv2LfN-hRsW-WA7dgw9g,2651
448
- reconcile/statuspage/integrations/maintenances.py,sha256=7gmMS9HwORMWMMBtib6pNGLXR6sAH2aW-HXKHJn6BN4,3083
448
+ reconcile/statuspage/integrations/maintenances.py,sha256=nG45b8A_ir9Ivtr4zH_VpHMahq8wev_M5igqK6T0hP0,4225
449
449
  reconcile/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
450
450
  reconcile/templates/aws_access_key_email.j2,sha256=2MUr1ERmyISzKgHqsWYLd-1Wbl-peUa-FsGUS-JLUFc,238
451
451
  reconcile/templates/email.yml.j2,sha256=OZgczNRgXPj2gVYTgwQyHAQrMGu7xp-e4W1rX19GcrU,690
@@ -811,8 +811,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
811
811
  tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jrss,4941
812
812
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
813
813
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
814
- qontract_reconcile-0.10.1rc825.dist-info/METADATA,sha256=nGrMqUI3wHpzTSQEQryBhjGLr_ABZ4pd5zx0TOp4F_8,2314
815
- qontract_reconcile-0.10.1rc825.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
816
- qontract_reconcile-0.10.1rc825.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
817
- qontract_reconcile-0.10.1rc825.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
818
- qontract_reconcile-0.10.1rc825.dist-info/RECORD,,
814
+ qontract_reconcile-0.10.1rc826.dist-info/METADATA,sha256=bf-WVmAA-y5rqqFgz1O-fs_ZZJp46ypvmDu0EB2u8F8,2314
815
+ qontract_reconcile-0.10.1rc826.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
816
+ qontract_reconcile-0.10.1rc826.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
817
+ qontract_reconcile-0.10.1rc826.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
818
+ qontract_reconcile-0.10.1rc826.dist-info/RECORD,,
@@ -1,10 +1,12 @@
1
1
  import logging
2
2
  import sys
3
- from datetime import datetime, timezone
3
+ from datetime import datetime, timedelta, timezone
4
4
 
5
+ from reconcile.slack_base import slackapi_from_queries
5
6
  from reconcile.statuspage.atlassian import AtlassianStatusPageProvider
6
7
  from reconcile.statuspage.integration import get_binding_state, get_status_pages
7
8
  from reconcile.statuspage.page import StatusMaintenance
9
+ from reconcile.statuspage.state import S3ComponentBindingState
8
10
  from reconcile.utils.differ import diff_iterables
9
11
  from reconcile.utils.runtime.integration import (
10
12
  NoParams,
@@ -44,6 +46,25 @@ class StatusPageMaintenancesIntegration(QontractReconcileIntegration[NoParams]):
44
46
  f"Delete StatusPage Maintenance is not supported at this time: {d.name}"
45
47
  )
46
48
 
49
+ def notify(
50
+ self,
51
+ dry_run: bool,
52
+ desired_state: list[StatusMaintenance],
53
+ binding_state: S3ComponentBindingState,
54
+ ) -> None:
55
+ now = datetime.now(timezone.utc)
56
+ slack = slackapi_from_queries(QONTRACT_INTEGRATION, init_usergroups=False)
57
+ for m in desired_state:
58
+ scheduled_start = datetime.fromisoformat(m.schedule_start)
59
+ if now <= scheduled_start <= now + timedelta(hours=1):
60
+ state_key = f"notifications/{m.name}"
61
+ if binding_state.state.exists(state_key):
62
+ continue
63
+ logging.info(f"Notify StatusPage Maintenance: {m.name}")
64
+ if not dry_run:
65
+ slack.chat_post_message(m.message)
66
+ binding_state.state.add(f"notifications/{m.name}")
67
+
47
68
  def run(self, dry_run: bool = False) -> None:
48
69
  binding_state = get_binding_state(self.name, self.secret_reader)
49
70
  pages = get_status_pages()
@@ -75,6 +96,11 @@ class StatusPageMaintenancesIntegration(QontractReconcileIntegration[NoParams]):
75
96
  current_state=current_state,
76
97
  provider=page_provider,
77
98
  )
99
+ self.notify(
100
+ dry_run=dry_run,
101
+ desired_state=desired_state,
102
+ binding_state=binding_state,
103
+ )
78
104
  except Exception:
79
105
  logging.exception(f"failed to reconcile statuspage {p.name}")
80
106
  error = True