qontract-reconcile 0.10.1rc1183__py3-none-any.whl → 0.10.1rc1185__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.1rc1183
3
+ Version: 0.10.1rc1185
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
@@ -43,7 +43,7 @@ reconcile/jenkins_job_builder.py,sha256=2aeOSS5pwKJgF4EzoHBWlOYNbzLj3qYzv6u55Qg6
43
43
  reconcile/jenkins_job_builds_cleaner.py,sha256=ksO5TXHxIMV_SF8kO86Wz7qGnYwbdt10wdhpb4aaEyQ,3851
44
44
  reconcile/jenkins_job_cleaner.py,sha256=dQGInds5RV-s9caec0212GveZ32xlCi2HiPyrIkVyFM,1761
45
45
  reconcile/jenkins_roles.py,sha256=pNNYcnmyDCTVytG2mi3BFhq9A7_3l301oFRQtY_q6S8,4452
46
- reconcile/jenkins_webhooks.py,sha256=K5h0OlCghoHlpot40IRq4BuezfKB1rj4Xk0dCUvqp3o,1952
46
+ reconcile/jenkins_webhooks.py,sha256=dzMT1ywXjeAo5sHj-ittW06Ed3beAUPjnc_oCAtD-Rg,2150
47
47
  reconcile/jenkins_webhooks_cleaner.py,sha256=JsN_NVPfZJwv1JtSzZXDIHUqGiefL-DRffFnDGau9aY,1539
48
48
  reconcile/jenkins_worker_fleets.py,sha256=PMNGOX0krubFjInPiFT0za0KCiWBLEcVDuXdKRd1BrE,5378
49
49
  reconcile/jira_permissions_validator.py,sha256=GSjLwHrstuO4dGb9Oxfmg_9PLLreFsbJJ8WHhUM8FSY,13144
@@ -655,7 +655,7 @@ reconcile/unleash_feature_toggles/integration.py,sha256=nx7BhtzCsTfPbOp60vI5MkNw
655
655
  reconcile/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
656
656
  reconcile/utils/aggregated_list.py,sha256=km0xadW0jO4G_CqZPsXmoBURQ8c90FaTu5x4X1K1cZs,3357
657
657
  reconcile/utils/amtool.py,sha256=ngtBuVPETH6oAy5RnKzvreVbjwQCaATS_PYYwBprzjQ,2288
658
- reconcile/utils/aws_api.py,sha256=Mp5-euZUfKfnVzgMZd3LoWbegm1OrNjzpP1A-n2EiF0,67640
658
+ reconcile/utils/aws_api.py,sha256=8LeEweWeydLJB9t-neYkYSN6EneDJontGwcglg0xmS0,67652
659
659
  reconcile/utils/aws_helper.py,sha256=MDbv5jrNdqqJ5pfBxniGdJXBBO_EYc2_Uf2w9ZzeMNs,2854
660
660
  reconcile/utils/batches.py,sha256=TtEm64a8lWhFuNbUVpFEmXVdU2Q0sTBrP_I0Cjbgh7g,320
661
661
  reconcile/utils/binary.py,sha256=7MaAFBpzuBUTJ_aA6G6-eult_BPMVyiXbBLD0Y6F-DM,2301
@@ -678,7 +678,7 @@ reconcile/utils/external_resources.py,sha256=y7Wz32cOAmCsUhQ6T-1N6lktnLikGkaHQ0S
678
678
  reconcile/utils/filtering.py,sha256=S4PbMHuFr3ED0P2Q_ea5CAaB7FimI62B-F5YTaKrphA,402
679
679
  reconcile/utils/git.py,sha256=wzVIYAeKlMGW538U1mkJWUI6h_mFRUY4lawh2AR8hw4,2345
680
680
  reconcile/utils/github_api.py,sha256=R8OvqyPdnRqvP-Efnv9RvIcbBlb4M0KC4RlbnJMD0Tg,2426
681
- reconcile/utils/gitlab_api.py,sha256=ar3D1gaPGm71ecQReMvbMbBzCa8TRs3Pn1ZZJP_lwSw,28453
681
+ reconcile/utils/gitlab_api.py,sha256=YokTr77DJVWl7nALjCJdJnPKgBJfUBETkE8FtrT7ckg,28455
682
682
  reconcile/utils/gpg.py,sha256=EKG7_fdMv8BMlV5yUdPiqoTx-KrzmVSEAl2sLkaKwWI,1123
683
683
  reconcile/utils/gql.py,sha256=C0thIm_k9MBldfqwHzyqtYZk9sIvMdm9IbbnXLGwjD8,14158
684
684
  reconcile/utils/grouping.py,sha256=vr9SFHZ7bqmHYrvYcEZt-Er3-yQYfAAdq5sHLZVmXPY,456
@@ -688,7 +688,7 @@ reconcile/utils/imap_client.py,sha256=h8YDiCSCvroErhpH_-KGYI7Y2WU2Q2oSpuxDFbOkSb
688
688
  reconcile/utils/instrumented_wrappers.py,sha256=eVwMoa6FCrYxLv3RML3WpZF9qKVfCTjMxphgVXG03OM,1073
689
689
  reconcile/utils/jenkins_api.py,sha256=RaKuZmO7_lbI-hE6c_Pq2a6CQdmBVj7BcP2jR68cIbI,7081
690
690
  reconcile/utils/jira_client.py,sha256=oWi7rcAP1C59oIBTPg6kRntI25Zm4e7FyvdVYvZ9RZ8,7881
691
- reconcile/utils/jjb_client.py,sha256=9Aw4SfV4pBNW5Kj7dGZwakUlwsWuqtAAiSD9o1F4AZA,14524
691
+ reconcile/utils/jjb_client.py,sha256=Tfphxxh70K12aq5WJ6aQ_0uhpDvlBRZLUN9-TKvjBuM,14996
692
692
  reconcile/utils/jsonpath.py,sha256=wdxOMqR-GMpQf5vRPWRMqAF7bCiXDBkkcFfY2U4j_tk,5536
693
693
  reconcile/utils/jump_host.py,sha256=svtWy64zZAx7XYY62vu580KgwdatmHjX4-BdxEl58Uw,5158
694
694
  reconcile/utils/keycloak.py,sha256=YWSEUGrOVqFaJUk055dKUWpLDPdDRvhcmvR-lfbmxdE,3388
@@ -882,8 +882,8 @@ tools/test/test_qontract_cli.py,sha256=iuzKbQ6ahinvjoQmQLBrG4shey0z-1rB6qCgS8T6d
882
882
  tools/test/test_saas_promotion_state.py,sha256=dy4kkSSAQ7bC0Xp2CociETGN-2aABEfL6FU5D9Jl00Y,6056
883
883
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
884
884
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
885
- qontract_reconcile-0.10.1rc1183.dist-info/METADATA,sha256=awLi7LWrtIKv-9-jSwBD1xyD2dU782uKtYHtKl89r4w,2213
886
- qontract_reconcile-0.10.1rc1183.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
887
- qontract_reconcile-0.10.1rc1183.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
888
- qontract_reconcile-0.10.1rc1183.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
889
- qontract_reconcile-0.10.1rc1183.dist-info/RECORD,,
885
+ qontract_reconcile-0.10.1rc1185.dist-info/METADATA,sha256=QatFHWfiRw29TrdKQtJhxXlwWCTa6pwrNTKTnxBMJtY,2213
886
+ qontract_reconcile-0.10.1rc1185.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
887
+ qontract_reconcile-0.10.1rc1185.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
888
+ qontract_reconcile-0.10.1rc1185.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
889
+ qontract_reconcile-0.10.1rc1185.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.45.0)
2
+ Generator: bdist_wheel (0.45.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -24,7 +24,13 @@ def get_hooks_to_add(desired_state, gl):
24
24
  current_hooks = gl.get_project_hooks(project_url)
25
25
  for h in current_hooks:
26
26
  job_url = h.url
27
- trigger = "mr" if h.merge_requests_events else "push"
27
+ trigger = []
28
+ if h.merge_requests_events:
29
+ trigger.append("mr")
30
+ if h.push_events:
31
+ trigger.append("push")
32
+ if h.note_events:
33
+ trigger.append("note")
28
34
  item = {
29
35
  "job_url": job_url.strip("/"),
30
36
  "trigger": trigger,
@@ -956,36 +956,43 @@ class AWSApi: # pylint: disable=too-many-public-methods
956
956
  for s in vpc_subnets
957
957
  ]
958
958
  if hcp_vpc_endpoint_sg:
959
- endpoints = AWSApi._get_vpc_endpoints(
960
- [
961
- {"Name": "vpc-id", "Values": [vpc_id]},
962
- {
963
- "Name": "tag:AWSEndpointService",
964
- "Values": ["private-router"],
965
- },
966
- ],
967
- assumed_ec2,
959
+ api_security_group_id = self._get_api_security_group_id(
960
+ assumed_ec2, vpc_id
968
961
  )
969
- if len(endpoints) > 1:
970
- raise ValueError(
971
- f"exactly one VPC endpoint for private API router in VPC {vpc_id} expected but {len(endpoints)} found"
972
- )
973
- vpc_endpoint_id = endpoints[0]["VpcEndpointId"]
974
- # https://github.com/openshift/hypershift/blob/c855f68e84e78924ccc9c2132b75dc7e30c4e1d8/control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go#L4243
975
- security_groups = [
976
- sg
977
- for sg in endpoints[0]["Groups"]
978
- if sg["GroupName"].endswith("-default-sg")
979
- ]
980
- if len(security_groups) != 1:
981
- raise ValueError(
982
- f"exactly one VPC endpoint default security group for private API router {vpc_endpoint_id} "
983
- f"in VPC {vpc_id} expected but {len(security_groups)} found"
984
- )
985
- api_security_group_id = security_groups[0]["GroupId"]
986
962
 
987
963
  return vpc_id, route_table_ids, subnets_id_az, api_security_group_id
988
964
 
965
+ def _get_api_security_group_id(self, assumed_ec2, vpc_id):
966
+ endpoints = AWSApi._get_vpc_endpoints(
967
+ [
968
+ {"Name": "vpc-id", "Values": [vpc_id]},
969
+ {
970
+ "Name": "tag:AWSEndpointService",
971
+ "Values": ["private-router"],
972
+ },
973
+ ],
974
+ assumed_ec2,
975
+ )
976
+ if not endpoints:
977
+ return None
978
+ if len(endpoints) > 1:
979
+ raise ValueError(
980
+ f"exactly one VPC endpoint for private API router in VPC {vpc_id} expected but {len(endpoints)} found"
981
+ )
982
+ vpc_endpoint_id = endpoints[0]["VpcEndpointId"]
983
+ # https://github.com/openshift/hypershift/blob/c855f68e84e78924ccc9c2132b75dc7e30c4e1d8/control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go#L4243
984
+ security_groups = [
985
+ sg
986
+ for sg in endpoints[0]["Groups"]
987
+ if sg["GroupName"].endswith("-default-sg")
988
+ ]
989
+ if len(security_groups) != 1:
990
+ raise ValueError(
991
+ f"exactly one VPC endpoint default security group for private API router {vpc_endpoint_id} "
992
+ f"in VPC {vpc_id} expected but {len(security_groups)} found"
993
+ )
994
+ return security_groups[0]["GroupId"]
995
+
989
996
  def get_cluster_nat_gateways_egress_ips(self, account: dict[str, Any], vpc_id: str):
990
997
  assumed_role_data = self._get_account_assume_data(account)
991
998
  assumed_ec2 = self._get_assumed_role_client(*assumed_role_data)
@@ -670,9 +670,9 @@ class GitLabApi: # pylint: disable=too-many-public-methods
670
670
  hook = {
671
671
  "url": url,
672
672
  "enable_ssl_verification": 1,
673
- "note_events": int(trigger == "mr"),
674
- "push_events": int(trigger == "push"),
675
- "merge_requests_events": int(trigger == "mr"),
673
+ "note_events": int("note" in trigger),
674
+ "push_events": int("push" in trigger),
675
+ "merge_requests_events": int("mr" in trigger),
676
676
  }
677
677
  gitlab_request.labels(integration=INTEGRATION_NAME).inc()
678
678
  p.hooks.create(hook)
@@ -294,11 +294,8 @@ class JJB: # pylint: disable=too-many-public-methods
294
294
  self.instance_urls[name], job["name"]
295
295
  )
296
296
  project_url = project_url_raw.strip("/").replace(".git", "")
297
- gitlab_triggers = job["triggers"][0]["gitlab"]
298
- mr_trigger = gitlab_triggers["trigger-merge-request"]
299
- push_trigger = gitlab_triggers["trigger-push"]
300
- trigger = "mr" if mr_trigger else "push" if push_trigger else None
301
- if trigger is None:
297
+ trigger = self.get_gitlab_webhook_trigger(job)
298
+ if not trigger:
302
299
  continue
303
300
  hook = {
304
301
  "job_url": job_url,
@@ -399,3 +396,19 @@ class JJB: # pylint: disable=too-many-public-methods
399
396
  if "github-pull-request" in trigger:
400
397
  return trigger["github-pull-request"].get("trigger-phrase")
401
398
  return None
399
+
400
+ @staticmethod
401
+ def get_gitlab_webhook_trigger(job: dict) -> list[str]:
402
+ gitlab_triggers = job["triggers"][0]["gitlab"]
403
+ # pr-check job should be triggered by merge request events
404
+ # and certain comments: [test]|/retest|/lgtm|/lgtm cancel|/hold|/hold cancel
405
+ if gitlab_triggers.get("trigger-merge-request"):
406
+ return ["mr", "note"]
407
+ # build main/master job should be triggered by push events
408
+ elif gitlab_triggers.get("trigger-push"):
409
+ return ["push"]
410
+ # On-demand test job should be triggered by special comment
411
+ elif gitlab_triggers.get("trigger-note"):
412
+ return ["note"]
413
+ else:
414
+ return []