qontract-reconcile 0.10.1rc349__py3-none-any.whl → 0.10.1rc351__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.
Files changed (23) hide show
  1. {qontract_reconcile-0.10.1rc349.dist-info → qontract_reconcile-0.10.1rc351.dist-info}/METADATA +1 -1
  2. {qontract_reconcile-0.10.1rc349.dist-info → qontract_reconcile-0.10.1rc351.dist-info}/RECORD +22 -18
  3. reconcile/aus/advanced_upgrade_service.py +50 -13
  4. reconcile/aus/aus_label_source.py +115 -0
  5. reconcile/cli.py +4 -4
  6. reconcile/gql_definitions/advanced_upgrade_service/aus_clusters.py +11 -1
  7. reconcile/gql_definitions/advanced_upgrade_service/aus_organization.py +9 -1
  8. reconcile/gql_definitions/fragments/aus_organization.py +9 -11
  9. reconcile/gql_definitions/fragments/minimal_ocm_organization.py +29 -0
  10. reconcile/gql_definitions/{ocm_subscription_labels → ocm_labels}/clusters.py +8 -0
  11. reconcile/gql_definitions/ocm_labels/organizations.py +72 -0
  12. reconcile/ocm_labels/integration.py +406 -0
  13. reconcile/ocm_labels/label_sources.py +76 -0
  14. reconcile/terraform_resources.py +2 -0
  15. reconcile/utils/external_resource_spec.py +20 -0
  16. reconcile/utils/external_resources.py +33 -2
  17. reconcile/utils/ocm/labels.py +61 -1
  18. reconcile/ocm_subscription_labels/integration.py +0 -250
  19. {qontract_reconcile-0.10.1rc349.dist-info → qontract_reconcile-0.10.1rc351.dist-info}/WHEEL +0 -0
  20. {qontract_reconcile-0.10.1rc349.dist-info → qontract_reconcile-0.10.1rc351.dist-info}/entry_points.txt +0 -0
  21. {qontract_reconcile-0.10.1rc349.dist-info → qontract_reconcile-0.10.1rc351.dist-info}/top_level.txt +0 -0
  22. /reconcile/gql_definitions/{ocm_subscription_labels → ocm_labels}/__init__.py +0 -0
  23. /reconcile/{ocm_subscription_labels → ocm_labels}/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qontract-reconcile
3
- Version: 0.10.1rc349
3
+ Version: 0.10.1rc351
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
@@ -7,7 +7,7 @@ reconcile/aws_iam_password_reset.py,sha256=NwErtrqgBiXr7eGCAHdtGGOx0S7-4JnSc29Ie
7
7
  reconcile/aws_support_cases_sos.py,sha256=i6bSWnlH9fh14P14PjVhFLwNl-q3fD733_rXKM_O51c,2992
8
8
  reconcile/blackbox_exporter_endpoint_monitoring.py,sha256=W_VJagnsJR1v5oqjlI3RJJE0_nhtJ0m81RS8zWA5u5c,3538
9
9
  reconcile/checkpoint.py,sha256=figtZRuWUvdpdSnkhAqeGvO5dI02TT6J3heyeFhlwqM,5016
10
- reconcile/cli.py,sha256=IJNdJ8lMJ6bSmrbsWol0s_LDr6beTfJFy7Ll5JVjWJg,78933
10
+ reconcile/cli.py,sha256=DtyfHbwInLcx_oa2IS9BjRAGUdTFpjunolG2aRqBs_g,78893
11
11
  reconcile/closedbox_endpoint_monitoring_base.py,sha256=3ttGqCBxyUANnizTVxf8R6zuleZ77YM4YGMW7qSSVl8,4865
12
12
  reconcile/cluster_deployment_mapper.py,sha256=2Ah-nu-Mdig0pjuiZl_XLrmVAjYzFjORR3dMlCgkmw0,2352
13
13
  reconcile/dashdotdb_base.py,sha256=13s9B8iIqSwu-rS-95QbIMPue_Gli3YMNBct5QjmrVo,4525
@@ -107,14 +107,15 @@ reconcile/terraform_cloudflare_dns.py,sha256=auU4bzeLwd4S8D8oqpqJbrCUoEdELXrgi7v
107
107
  reconcile/terraform_cloudflare_resources.py,sha256=0Xg_ISZViJtgj6cpYalANMHyPdNR6q19y60RXfa66Yw,14912
108
108
  reconcile/terraform_cloudflare_users.py,sha256=DfeSnYC9YQgXX6AbJh85tQbJUDv1e2FjiGXgcpVQlPg,13964
109
109
  reconcile/terraform_repo.py,sha256=fIVjcxqhG6DR6H8QtQM1RpE9ukanjkjp8iH0tQRhEl8,13042
110
- reconcile/terraform_resources.py,sha256=P93W2cdjrq97ffMfEgJPkoWp7E97S6AoOnooy0Z9LsU,17039
110
+ reconcile/terraform_resources.py,sha256=-VWkI-0EwNUovNcLksFBkYmAMZoB9GM_QG1pZa9ZMrg,17136
111
111
  reconcile/terraform_tgw_attachments.py,sha256=6PVhBYeIvNnz2PwBdPF0I222_83EzOWX6VKJnqz7UPo,13915
112
112
  reconcile/terraform_users.py,sha256=kXRUxCUchKCP2dbXXOzctynqMii4oyCP6bYZHQTrlTg,10202
113
113
  reconcile/terraform_vpc_peerings.py,sha256=LRW3GUaf8g9iZWILBWQukfv6YmEY_3fWpatC_op-66I,21611
114
114
  reconcile/vault_replication.py,sha256=Bg0pIj-s_1nKM2xWmD3vwnSZOxEYHCM3F6jWwXQMuYk,17259
115
115
  reconcile/vpc_peerings_validator.py,sha256=oiYwmQ2yYBobFhIixmHNUP1GxzUADocMPJnCBp3FRFw,7177
116
116
  reconcile/aus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
117
- reconcile/aus/advanced_upgrade_service.py,sha256=vI1XDgKReL0z3E2dpgbMxPBe9zagClS7tMjKeW3LiJw,20658
117
+ reconcile/aus/advanced_upgrade_service.py,sha256=08DtnQ7i30MZj_kd2aaGPCPuOOIVWDnP14pAUy5N-nw,21683
118
+ reconcile/aus/aus_label_source.py,sha256=X6FD4NYcX27llMUSmmBcCh-pG7U5FnBd0zl-0zwCj2U,4118
118
119
  reconcile/aus/base.py,sha256=ToS0WfaH_eX0qM_LcBQSpkBhXjKNWNa-2bKjAY6uz0s,32064
119
120
  reconcile/aus/cluster_version_data.py,sha256=j4UyEBi5mQuvPq5Lo7a_L_0blxvH790wJV07uAiikFU,7126
120
121
  reconcile/aus/metrics.py,sha256=L1kgPaDtNZQcA7b65-lbiXmQmNALZWB9Cp0ibToZrzM,2455
@@ -155,8 +156,8 @@ reconcile/glitchtip_project_dsn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm
155
156
  reconcile/glitchtip_project_dsn/integration.py,sha256=IvFlSYumDPhUw7gLfFX1P8tg-7Vns0ot2-Nqf2_sE18,7997
156
157
  reconcile/gql_definitions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
157
158
  reconcile/gql_definitions/advanced_upgrade_service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
158
- reconcile/gql_definitions/advanced_upgrade_service/aus_clusters.py,sha256=cGRVXc3tGiK9uCeT6-1ryU-7ykBUwdpZTW4JXAMHHiM,3870
159
- reconcile/gql_definitions/advanced_upgrade_service/aus_organization.py,sha256=s5r6dNRv69feeLF5NtH1V_caJYSlIxOgXnC79bjSF_w,2942
159
+ reconcile/gql_definitions/advanced_upgrade_service/aus_clusters.py,sha256=RSgN-BpYC1XG_4yaLdanUGsjBwh0RGLiEFX9T_Z_cvM,4091
160
+ reconcile/gql_definitions/advanced_upgrade_service/aus_organization.py,sha256=lBX4jCQzKBX32s_2-gprc8PF-vStS_dXIx-Zk38v1w0,3103
160
161
  reconcile/gql_definitions/aws_ami_cleanup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
161
162
  reconcile/gql_definitions/aws_ami_cleanup/asg_namespaces.py,sha256=hu0f4DQ5a6mP4L27DR9vbh01tuKYFS-vBE-PttOnFHE,3746
162
163
  reconcile/gql_definitions/change_owners/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -194,11 +195,12 @@ reconcile/gql_definitions/dashdotdb_slo/slo_documents_query.py,sha256=Ch938CdCbb
194
195
  reconcile/gql_definitions/dynatrace_token_provider/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
195
196
  reconcile/gql_definitions/dynatrace_token_provider/dynatrace_bootstrap_tokens.py,sha256=kcnF1mcwb5k8s1pxANBN92sqUcM5KDxOgFGNqHmlPP8,2063
196
197
  reconcile/gql_definitions/fragments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
197
- reconcile/gql_definitions/fragments/aus_organization.py,sha256=DKizEsoI0Gar4u3rlrr6ylxEJobYJurw8-817kVw3fE,4206
198
+ reconcile/gql_definitions/fragments/aus_organization.py,sha256=1-3gcqTZc2nRExWXvBgeaqsGmECJUKXuTj25soMq8oY,4196
198
199
  reconcile/gql_definitions/fragments/aws_account_common.py,sha256=o3bFpDv1edWfVSFPz051INs_Tiy9dovKNyLoEPJzNms,2352
199
200
  reconcile/gql_definitions/fragments/aws_infra_management_account.py,sha256=IuXBBDc0GHPvbw7TZcTM750L1gl8Rkqgf3Cco_YPe2w,1258
200
201
  reconcile/gql_definitions/fragments/deplopy_resources.py,sha256=QMBZvtAxwy5E7h7Du5QFwIqHbRhnGYV8Izl4b9aQY1s,1093
201
202
  reconcile/gql_definitions/fragments/jumphost_common_fields.py,sha256=yQYTbQs9yQDO9Vs-pv_99e_dSq48_SwUVpotRfFlihM,1038
203
+ reconcile/gql_definitions/fragments/minimal_ocm_organization.py,sha256=Pyf6Agvb6kxF8_BZAGojQF5WMiYT9V8R2D8hfLnCpsg,735
202
204
  reconcile/gql_definitions/fragments/oc_connection_cluster.py,sha256=L8v52wkcHpnFvDzjHi2FPRmBWa7BhDAIiCqk02nPaGc,1557
203
205
  reconcile/gql_definitions/fragments/ocm_environment.py,sha256=DOfBY4fb02UF5R3ZxtwHBTlxhPYOOBJaqGeENElX7oc,1037
204
206
  reconcile/gql_definitions/fragments/pipeline_provider_retention.py,sha256=aAFIPiaDNvVTnocIQ3SH8_1Itu0UXQi8XZ0yOrKfbRw,761
@@ -231,9 +233,10 @@ reconcile/gql_definitions/jumphosts/jumphosts.py,sha256=V0K6V9_O8LFztCcBtJfaZ9PM
231
233
  reconcile/gql_definitions/ldap_groups/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
232
234
  reconcile/gql_definitions/ldap_groups/roles.py,sha256=-mww5_wvNxknYQpx2xK9HHyvDvXSGKkEVaDapIp2YoE,1929
233
235
  reconcile/gql_definitions/ldap_groups/settings.py,sha256=Zq9moBWsL03RgoBEjkvLzz_eCimeD8ANxn3secqFOGw,2237
236
+ reconcile/gql_definitions/ocm_labels/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
237
+ reconcile/gql_definitions/ocm_labels/clusters.py,sha256=NARPaQjcF4iVkX_AF905CNQyjmyTohSktc8Kvp6aJRY,2909
238
+ reconcile/gql_definitions/ocm_labels/organizations.py,sha256=zCEiVUoVmaNOWUIYDh0yQDD9ov9mKGw1QhUXA89NZCg,2019
234
239
  reconcile/gql_definitions/ocm_oidc_idp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
235
- reconcile/gql_definitions/ocm_subscription_labels/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
236
- reconcile/gql_definitions/ocm_subscription_labels/clusters.py,sha256=rXniwpBJQJtQB8OVYU25YgFukf0ijH0O0wfJzHirHlM,2729
237
240
  reconcile/gql_definitions/openshift_groups/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
238
241
  reconcile/gql_definitions/openshift_groups/managed_groups.py,sha256=_Cr0z4BJlWF0MjMEphWIKqpvyfIXSW8MiEs86sAtyZQ,2017
239
242
  reconcile/gql_definitions/openshift_groups/managed_roles.py,sha256=Q9U2hRiAZiCBEHmT1ipHhS2z1Yn5VIXvpIxNJgNrw_Y,2607
@@ -284,8 +287,9 @@ reconcile/ldap_groups/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
284
287
  reconcile/ldap_groups/integration.py,sha256=SLcvBYQK2i7YONLxMQfjd3AdtfSSp4I_AvSIRGM8yXc,7830
285
288
  reconcile/ocm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
286
289
  reconcile/ocm/types.py,sha256=NOM_On4tEx2lwpZCbYrSwpysHcm6QvLfpdWpxiN_5KE,2183
287
- reconcile/ocm_subscription_labels/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
288
- reconcile/ocm_subscription_labels/integration.py,sha256=N7ZNmycIQUQtqCNTb1cx9rVFxv3q0OrFiG3JBCSup-4,8720
290
+ reconcile/ocm_labels/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
291
+ reconcile/ocm_labels/integration.py,sha256=1yi-hCagI2XqRxjIVVC6jiMJj7VN_Efk4IkqZKke5jI,15008
292
+ reconcile/ocm_labels/label_sources.py,sha256=z5Rg5uMTfRkTi3QbEQK1P82LLciWrSnp65XBEpZf2-o,1877
289
293
  reconcile/oum/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
290
294
  reconcile/oum/base.py,sha256=gw5qDx3VKtIk-VW_g0j5iPdM4qAweqy0YROHJhKHt0M,13596
291
295
  reconcile/oum/labelset.py,sha256=MTOMEyBMbge3JOq0mOKWja-kV3cs0ZId9Ozxv7FJ9Kw,2185
@@ -476,8 +480,8 @@ reconcile/utils/elasticsearch_exceptions.py,sha256=UY5Z3y2hw7T73sPJ6dHmUybegiIop
476
480
  reconcile/utils/environ.py,sha256=u3h1FlnIcZnaAk1POVaSYW_HIvcQG-W-n2DhfSCqwuE,536
477
481
  reconcile/utils/exceptions.py,sha256=DwfnWUpVOotpP79RWZ2pycmG6nKCL00RBIeZLYkQPW4,635
478
482
  reconcile/utils/expiration.py,sha256=BXwKE50sNIV-Lszke97fxitNkLxYszoOLW1LBgp_yqg,1246
479
- reconcile/utils/external_resource_spec.py,sha256=U6GGi0e7FxhDHPPvmYhlBIfEeIzV--VKueX3Rj6aJjQ,6180
480
- reconcile/utils/external_resources.py,sha256=301hqVVDt78i88VLFTkSc5mq1KvVP4OiHh_DQX-B1G8,6492
483
+ reconcile/utils/external_resource_spec.py,sha256=y2ulJUKD0z-zS2a_imegUWIDwFketOIINJY8tNxwOtc,6636
484
+ reconcile/utils/external_resources.py,sha256=ik6NOEP_6Tg1fjOpUXVQWW_ybwmR2ieAwO4AotMoqtg,7425
481
485
  reconcile/utils/filtering.py,sha256=dw7Ok7HXjZb0ruvCWHFh194rtunX1COLDTRnNfOpwQU,418
482
486
  reconcile/utils/git.py,sha256=kgjN93MMB5mnkuNb1n53f5kldGGf5u0pBHj9YJbiE_c,1455
483
487
  reconcile/utils/git_secrets.py,sha256=897nRs7tycA3m7YYeVEbzOhI8RFrI9IJT2E0di1eJhc,1956
@@ -558,7 +562,7 @@ reconcile/utils/ocm/base.py,sha256=VOoFEjRRjQ70zNDvlb6YJ8jnpsCZVU7T5yiztP9xjx0,1
558
562
  reconcile/utils/ocm/cluster_groups.py,sha256=F8oqVqN_4QUnGL0K61zZhoYIzJeP57EcmZpwmoV0mr4,1751
559
563
  reconcile/utils/ocm/clusters.py,sha256=BdYEHs83MB4yMNjilpoOWQ2J2zE0pmhCy3lsbUJnaKo,6550
560
564
  reconcile/utils/ocm/identity_providers.py,sha256=dKed09N8iWmn39tI_MpwgVe47x23eLsknGbjMUxtwr4,2175
561
- reconcile/utils/ocm/labels.py,sha256=68TT7ViGhUr2aGOkWpOjJrd2uORwCCSbzpVs3Vb4ucw,4126
565
+ reconcile/utils/ocm/labels.py,sha256=iAsykGGEwWNKAuvjtSRejVekTQ_urjFxc75PRTARWOY,5920
562
566
  reconcile/utils/ocm/ocm.py,sha256=AA9KRZqVRAsqwlLh-UDuH4Gh_w-r5rTSsdsIjakWsGQ,58338
563
567
  reconcile/utils/ocm/search_filters.py,sha256=zExZpYBh7_tucG-xKoPHUxz1b_6l9qwbEMpMihQg7nA,15043
564
568
  reconcile/utils/ocm/service_log.py,sha256=juMLO3iudrv0pn9sG68rs4HBfd5TgjOiK_TPdOnOa0w,1630
@@ -603,8 +607,8 @@ tools/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
603
607
  tools/test/test_qontract_cli.py,sha256=awwTHEc2DWlykuqGIYM0WOBoSL0KRnOraCLk3C7izis,1401
604
608
  tools/test/test_sd_app_sre_alert_report.py,sha256=JeLhgzpKCPgLvptwg_4ZvJHLVWKNG1T5845HXTkMBxA,1826
605
609
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
606
- qontract_reconcile-0.10.1rc349.dist-info/METADATA,sha256=C3XPRZT8oAilmzYuRb-59DtJ0lJqx4qA2-QW69RGCjc,2347
607
- qontract_reconcile-0.10.1rc349.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
608
- qontract_reconcile-0.10.1rc349.dist-info/entry_points.txt,sha256=ErVY2Jp-0Rtuq5KOtMlW5yvna4nIEuc_1YbEdEdcy9o,301
609
- qontract_reconcile-0.10.1rc349.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
610
- qontract_reconcile-0.10.1rc349.dist-info/RECORD,,
610
+ qontract_reconcile-0.10.1rc351.dist-info/METADATA,sha256=ODns-HsSTrrrk-z-CoQcRhP636UnedN65JArxgGDTSY,2347
611
+ qontract_reconcile-0.10.1rc351.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
612
+ qontract_reconcile-0.10.1rc351.dist-info/entry_points.txt,sha256=ErVY2Jp-0Rtuq5KOtMlW5yvna4nIEuc_1YbEdEdcy9o,301
613
+ qontract_reconcile-0.10.1rc351.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
614
+ qontract_reconcile-0.10.1rc351.dist-info/RECORD,,
@@ -24,7 +24,9 @@ from reconcile.gql_definitions.fragments.aus_organization import (
24
24
  OpenShiftClusterManagerSectorV1,
25
25
  OpenShiftClusterManagerV1_OpenShiftClusterManagerV1,
26
26
  OpenShiftClusterManagerV1_OpenShiftClusterManagerV1_OpenShiftClusterManagerEnvironmentV1,
27
- OpenShiftClusterManagerV1_OpenShiftClusterManagerV1_OpenShiftClusterManagerV1,
27
+ )
28
+ from reconcile.gql_definitions.fragments.minimal_ocm_organization import (
29
+ MinimalOCMOrganization,
28
30
  )
29
31
  from reconcile.gql_definitions.fragments.ocm_environment import OCMEnvironment
30
32
  from reconcile.gql_definitions.fragments.upgrade_policy import (
@@ -47,6 +49,7 @@ from reconcile.utils.ocm.clusters import (
47
49
  discover_clusters_by_labels,
48
50
  )
49
51
  from reconcile.utils.ocm.labels import (
52
+ get_org_labels,
50
53
  get_organization_labels,
51
54
  subscription_label_filter,
52
55
  )
@@ -211,15 +214,14 @@ def _get_org_labels(
211
214
  """
212
215
  Fetch all AUS OCM org labels from organizations. They hold config
213
216
  parameters like blocked versions etc.
217
+
218
+ The result is a dict with organization IDs as keys and label containers as values.
214
219
  """
215
- filter = Filter().like("key", aus_label_key("%")).is_in("organization_id", org_ids)
216
- labels_by_org: dict[str, list[OCMOrganizationLabel]] = defaultdict(list)
217
- for label in get_organization_labels(ocm_api, filter):
218
- labels_by_org[label.organization_id].append(label)
219
- return {
220
- org_id: build_label_container(labels)
221
- for org_id, labels in labels_by_org.items()
222
- }
220
+ return get_org_labels(
221
+ ocm_api=ocm_api,
222
+ org_ids=org_ids or set(),
223
+ label_filter=Filter().like("key", aus_label_key("%")),
224
+ )
223
225
 
224
226
 
225
227
  def _build_org_upgrade_specs_for_ocm_env(
@@ -245,7 +247,7 @@ def _build_org_upgrade_specs_for_ocm_env(
245
247
  }
246
248
 
247
249
 
248
- def aus_label_key(config_atom: str) -> str:
250
+ def aus_label_key(config_atom: Optional[str] = None) -> str:
249
251
  """
250
252
  Generates label keys for aus, compliant with the naming schema defined in
251
253
  https://service.pages.redhat.com/dev-guidelines/docs/sre-capabilities/framework/ocm-labels/
@@ -315,9 +317,7 @@ def _build_org_upgrade_spec(
315
317
  name=source_org_ref.env_name
316
318
  ),
317
319
  publishVersionData=[
318
- OpenShiftClusterManagerV1_OpenShiftClusterManagerV1_OpenShiftClusterManagerV1(
319
- orgId=org.id
320
- )
320
+ MinimalOCMOrganization(orgId=org.id, name=org.name)
321
321
  ],
322
322
  )
323
323
  for source_org_ref in version_data_inheritance.inherit_from_orgs
@@ -337,6 +337,7 @@ def _build_org_upgrade_spec(
337
337
  accessTokenUrl=None,
338
338
  addonUpgradeTests=None,
339
339
  inheritVersionData=inherit_version_data,
340
+ publishVersionData=None,
340
341
  upgradePolicyAllowedWorkloads=None,
341
342
  upgradePolicyClusters=None,
342
343
  )
@@ -390,6 +391,42 @@ class ClusterUpgradePolicyLabelSet(BaseModel):
390
391
  blocked_versions: Optional[CSV] = Field(alias=aus_label_key("blocked-versions"))
391
392
  _schedule_validator = validator("schedule", allow_reuse=True)(cron_validator)
392
393
 
394
+ def build_labels_dict(self) -> dict[str, str]:
395
+ """
396
+ Build a dictionary of all labels in this labelset.
397
+ """
398
+ labels = {}
399
+ for k, v in self.dict(by_alias=True).items():
400
+ if v is None:
401
+ continue
402
+ if isinstance(v, list):
403
+ labels[k] = ",".join(sorted(v))
404
+ else:
405
+ labels[k] = str(v)
406
+ return labels
407
+
408
+
409
+ def build_cluster_upgrade_policy_label_set(
410
+ workloads: list[str],
411
+ schedule: str,
412
+ soak_days: int,
413
+ mutexes: Optional[list[str]] = None,
414
+ sector: Optional[str] = None,
415
+ blocked_versions: Optional[list[str]] = None,
416
+ ) -> ClusterUpgradePolicyLabelSet:
417
+ return ClusterUpgradePolicyLabelSet(
418
+ **{
419
+ aus_label_key("workloads"): ",".join(workloads),
420
+ aus_label_key("schedule"): schedule,
421
+ aus_label_key("soak-days"): soak_days,
422
+ aus_label_key("mutexes"): ",".join(mutexes) if mutexes else None,
423
+ aus_label_key("sector"): sector,
424
+ aus_label_key("blocked-versions"): ",".join(blocked_versions)
425
+ if blocked_versions
426
+ else None,
427
+ }
428
+ )
429
+
393
430
 
394
431
  def _build_policy_from_labels(labels: LabelContainer) -> ClusterUpgradePolicyV1:
395
432
  """
@@ -0,0 +1,115 @@
1
+ from collections.abc import Iterable
2
+ from typing import Callable
3
+
4
+ from reconcile.aus.advanced_upgrade_service import (
5
+ aus_label_key,
6
+ build_cluster_upgrade_policy_label_set,
7
+ )
8
+ from reconcile.gql_definitions.advanced_upgrade_service.aus_clusters import (
9
+ ClusterUpgradePolicyV1,
10
+ ClusterV1,
11
+ )
12
+ from reconcile.gql_definitions.advanced_upgrade_service.aus_clusters import (
13
+ query as aus_clusters_query,
14
+ )
15
+ from reconcile.gql_definitions.advanced_upgrade_service.aus_organization import (
16
+ query as aus_organizations_query,
17
+ )
18
+ from reconcile.gql_definitions.fragments.aus_organization import AUSOCMOrganization
19
+ from reconcile.ocm_labels.label_sources import (
20
+ ClusterRef,
21
+ LabelSource,
22
+ LabelState,
23
+ OrgRef,
24
+ )
25
+
26
+
27
+ class AUSClusterUpgradePolicyLabelSource(LabelSource):
28
+ def __init__(self, clusters: Iterable[ClusterV1]) -> None:
29
+ self.clusters = clusters
30
+
31
+ def get_labels(self) -> LabelState:
32
+ return {
33
+ ClusterRef(
34
+ cluster_id=cluster.spec.q_id,
35
+ org_id=cluster.ocm.org_id,
36
+ ocm_env=cluster.ocm.environment.name,
37
+ name=cluster.name,
38
+ label_container_href=None,
39
+ ): self._cluster_to_labels(cluster.upgrade_policy)
40
+ for cluster in self.clusters
41
+ if cluster.ocm
42
+ and cluster.spec
43
+ and cluster.spec.q_id
44
+ and cluster.upgrade_policy
45
+ }
46
+
47
+ def _cluster_to_labels(self, policy: ClusterUpgradePolicyV1) -> dict[str, str]:
48
+ return build_cluster_upgrade_policy_label_set(
49
+ workloads=policy.workloads,
50
+ schedule=policy.schedule,
51
+ soak_days=policy.conditions.soak_days or 0,
52
+ mutexes=policy.conditions.mutexes,
53
+ sector=policy.conditions.sector,
54
+ blocked_versions=policy.conditions.blocked_versions,
55
+ ).build_labels_dict()
56
+
57
+
58
+ def init_aus_cluster_label_source(
59
+ query_fun: Callable,
60
+ ) -> LabelSource:
61
+ clusters = aus_clusters_query(query_func=query_fun).clusters or []
62
+ return AUSClusterUpgradePolicyLabelSource(clusters=clusters)
63
+
64
+
65
+ class AUSOrganizationLabelSource(LabelSource):
66
+ def __init__(self, organizations: Iterable[AUSOCMOrganization]) -> None:
67
+ self.organizations = organizations
68
+
69
+ def get_labels(self) -> LabelState:
70
+ return {
71
+ OrgRef(
72
+ org_id=organization.org_id,
73
+ ocm_env=organization.environment.name,
74
+ label_container_href=None,
75
+ name=organization.name,
76
+ ): self._organization_to_labels(organization)
77
+ for organization in self.organizations
78
+ }
79
+
80
+ def _organization_to_labels(
81
+ self, organization: AUSOCMOrganization
82
+ ) -> dict[str, str]:
83
+ labels: dict[str, str] = {}
84
+ # blocked versions
85
+ if organization.blocked_versions:
86
+ labels[aus_label_key("blocked-versions")] = ",".join(
87
+ organization.blocked_versions
88
+ )
89
+ # sector dependencies
90
+ for sector in organization.sectors or []:
91
+ if sector.dependencies:
92
+ labels[aus_label_key(f"sectors.{sector.name}")] = ",".join(
93
+ sorted([dep.name for dep in sector.dependencies])
94
+ )
95
+ # version-data sharing
96
+ if organization.inherit_version_data:
97
+ labels[aus_label_key("version-data.inherit")] = ",".join(
98
+ sorted(
99
+ inherit.org_id
100
+ for inherit in organization.inherit_version_data or []
101
+ )
102
+ )
103
+ if organization.publish_version_data:
104
+ labels[aus_label_key("version-data.publish")] = ",".join(
105
+ sorted(
106
+ publish.org_id
107
+ for publish in organization.publish_version_data or []
108
+ )
109
+ )
110
+ return labels
111
+
112
+
113
+ def init_aus_org_label_source(query_fun: Callable) -> LabelSource:
114
+ organizations = aus_organizations_query(query_func=query_fun).organizations or []
115
+ return AUSOrganizationLabelSource(organizations=organizations)
reconcile/cli.py CHANGED
@@ -2803,17 +2803,17 @@ def skupper_network(ctx, thread_pool_size, internal, use_jump_host):
2803
2803
  )
2804
2804
 
2805
2805
 
2806
- @integration.command(short_help="Manage cluster OCM subscription labels.")
2806
+ @integration.command(short_help="Manage cluster OCM labels.")
2807
2807
  @click.option(
2808
2808
  "--managed-label-prefixes",
2809
2809
  help="A comma list of label prefixes that are managed.",
2810
2810
  required=True,
2811
- envvar="OSL_MANAGED_LABEL_PREFIXES",
2811
+ envvar="OL_MANAGED_LABEL_PREFIXES",
2812
2812
  default="sre-capabilities",
2813
2813
  )
2814
2814
  @click.pass_context
2815
- def ocm_subscription_labels(ctx, managed_label_prefixes):
2816
- from reconcile.ocm_subscription_labels.integration import (
2815
+ def ocm_labels(ctx, managed_label_prefixes):
2816
+ from reconcile.ocm_labels.integration import (
2817
2817
  OcmLabelsIntegration,
2818
2818
  OcmLabelsIntegrationParams,
2819
2819
  )
@@ -54,9 +54,12 @@ fragment AUSOCMOrganization on OpenShiftClusterManager_v1 {
54
54
  name
55
55
  }
56
56
  publishVersionData {
57
- orgId
57
+ ... MinimalOCMOrganization
58
58
  }
59
59
  }
60
+ publishVersionData {
61
+ ... MinimalOCMOrganization
62
+ }
60
63
  sectors {
61
64
  name
62
65
  dependencies {
@@ -86,6 +89,11 @@ fragment ClusterUpgradePolicyV1 on ClusterUpgradePolicy_v1 {
86
89
  }
87
90
  }
88
91
 
92
+ fragment MinimalOCMOrganization on OpenShiftClusterManager_v1 {
93
+ name
94
+ orgId
95
+ }
96
+
89
97
  fragment OCMEnvironment on OpenShiftClusterManagerEnvironment_v1 {
90
98
  name
91
99
  url
@@ -114,6 +122,7 @@ query AUSClusters($name: String) {
114
122
  }
115
123
  spec {
116
124
  product
125
+ id
117
126
  external_id
118
127
  version
119
128
  }
@@ -133,6 +142,7 @@ class ConfiguredBaseModel(BaseModel):
133
142
 
134
143
  class ClusterSpecV1(ConfiguredBaseModel):
135
144
  product: str = Field(..., alias="product")
145
+ q_id: Optional[str] = Field(..., alias="id")
136
146
  external_id: Optional[str] = Field(..., alias="external_id")
137
147
  version: str = Field(..., alias="version")
138
148
 
@@ -53,9 +53,12 @@ fragment AUSOCMOrganization on OpenShiftClusterManager_v1 {
53
53
  name
54
54
  }
55
55
  publishVersionData {
56
- orgId
56
+ ... MinimalOCMOrganization
57
57
  }
58
58
  }
59
+ publishVersionData {
60
+ ... MinimalOCMOrganization
61
+ }
59
62
  sectors {
60
63
  name
61
64
  dependencies {
@@ -85,6 +88,11 @@ fragment ClusterUpgradePolicyV1 on ClusterUpgradePolicy_v1 {
85
88
  }
86
89
  }
87
90
 
91
+ fragment MinimalOCMOrganization on OpenShiftClusterManager_v1 {
92
+ name
93
+ orgId
94
+ }
95
+
88
96
  fragment OCMEnvironment on OpenShiftClusterManagerEnvironment_v1 {
89
97
  name
90
98
  url
@@ -18,6 +18,9 @@ from pydantic import ( # noqa: F401 # pylint: disable=W0611
18
18
  )
19
19
 
20
20
  from reconcile.gql_definitions.fragments.upgrade_policy import ClusterUpgradePolicyV1
21
+ from reconcile.gql_definitions.fragments.minimal_ocm_organization import (
22
+ MinimalOCMOrganization,
23
+ )
21
24
  from reconcile.gql_definitions.fragments.ocm_environment import OCMEnvironment
22
25
  from reconcile.gql_definitions.fragments.vault_secret import VaultSecret
23
26
 
@@ -49,23 +52,15 @@ class OpenShiftClusterManagerV1_OpenShiftClusterManagerV1_OpenShiftClusterManage
49
52
  name: str = Field(..., alias="name")
50
53
 
51
54
 
52
- class OpenShiftClusterManagerV1_OpenShiftClusterManagerV1_OpenShiftClusterManagerV1(
53
- ConfiguredBaseModel
54
- ):
55
- org_id: str = Field(..., alias="orgId")
56
-
57
-
58
55
  class OpenShiftClusterManagerV1_OpenShiftClusterManagerV1(ConfiguredBaseModel):
59
56
  name: str = Field(..., alias="name")
60
57
  org_id: str = Field(..., alias="orgId")
61
58
  environment: OpenShiftClusterManagerV1_OpenShiftClusterManagerV1_OpenShiftClusterManagerEnvironmentV1 = Field(
62
59
  ..., alias="environment"
63
60
  )
64
- publish_version_data: Optional[
65
- list[
66
- OpenShiftClusterManagerV1_OpenShiftClusterManagerV1_OpenShiftClusterManagerV1
67
- ]
68
- ] = Field(..., alias="publishVersionData")
61
+ publish_version_data: Optional[list[MinimalOCMOrganization]] = Field(
62
+ ..., alias="publishVersionData"
63
+ )
69
64
 
70
65
 
71
66
  class OpenShiftClusterManagerSectorDependenciesV1_OpenShiftClusterManagerV1(
@@ -110,6 +105,9 @@ class AUSOCMOrganization(ConfiguredBaseModel):
110
105
  inherit_version_data: Optional[
111
106
  list[OpenShiftClusterManagerV1_OpenShiftClusterManagerV1]
112
107
  ] = Field(..., alias="inheritVersionData")
108
+ publish_version_data: Optional[list[MinimalOCMOrganization]] = Field(
109
+ ..., alias="publishVersionData"
110
+ )
113
111
  sectors: Optional[list[OpenShiftClusterManagerSectorV1]] = Field(
114
112
  ..., alias="sectors"
115
113
  )
@@ -0,0 +1,29 @@
1
+ """
2
+ Generated by qenerate plugin=pydantic_v1. DO NOT MODIFY MANUALLY!
3
+ """
4
+ from collections.abc import Callable # noqa: F401 # pylint: disable=W0611
5
+ from datetime import datetime # noqa: F401 # pylint: disable=W0611
6
+ from enum import Enum # noqa: F401 # pylint: disable=W0611
7
+ from typing import ( # noqa: F401 # pylint: disable=W0611
8
+ Any,
9
+ Optional,
10
+ Union,
11
+ )
12
+
13
+ from pydantic import ( # noqa: F401 # pylint: disable=W0611
14
+ BaseModel,
15
+ Extra,
16
+ Field,
17
+ Json,
18
+ )
19
+
20
+
21
+ class ConfiguredBaseModel(BaseModel):
22
+ class Config:
23
+ smart_union = True
24
+ extra = Extra.forbid
25
+
26
+
27
+ class MinimalOCMOrganization(ConfiguredBaseModel):
28
+ name: str = Field(..., alias="name")
29
+ org_id: str = Field(..., alias="orgId")
@@ -41,6 +41,9 @@ fragment VaultSecret on VaultSecret_v1 {
41
41
  query OcmSubscriptionLabel {
42
42
  clusters: clusters_v1 {
43
43
  name
44
+ spec {
45
+ id
46
+ }
44
47
  ocm {
45
48
  environment {
46
49
  ...OCMEnvironment
@@ -63,6 +66,10 @@ class ConfiguredBaseModel(BaseModel):
63
66
  extra = Extra.forbid
64
67
 
65
68
 
69
+ class ClusterSpecV1(ConfiguredBaseModel):
70
+ q_id: Optional[str] = Field(..., alias="id")
71
+
72
+
66
73
  class OpenShiftClusterManagerV1(ConfiguredBaseModel):
67
74
  environment: OCMEnvironment = Field(..., alias="environment")
68
75
  org_id: str = Field(..., alias="orgId")
@@ -74,6 +81,7 @@ class DisableClusterAutomationsV1(ConfiguredBaseModel):
74
81
 
75
82
  class ClusterV1(ConfiguredBaseModel):
76
83
  name: str = Field(..., alias="name")
84
+ spec: Optional[ClusterSpecV1] = Field(..., alias="spec")
77
85
  ocm: Optional[OpenShiftClusterManagerV1] = Field(..., alias="ocm")
78
86
  disable: Optional[DisableClusterAutomationsV1] = Field(..., alias="disable")
79
87
  ocm_subscription_labels: Optional[Json] = Field(..., alias="ocmSubscriptionLabels")
@@ -0,0 +1,72 @@
1
+ """
2
+ Generated by qenerate plugin=pydantic_v1. DO NOT MODIFY MANUALLY!
3
+ """
4
+ from collections.abc import Callable # noqa: F401 # pylint: disable=W0611
5
+ from datetime import datetime # noqa: F401 # pylint: disable=W0611
6
+ from enum import Enum # noqa: F401 # pylint: disable=W0611
7
+ from typing import ( # noqa: F401 # pylint: disable=W0611
8
+ Any,
9
+ Optional,
10
+ Union,
11
+ )
12
+
13
+ from pydantic import ( # noqa: F401 # pylint: disable=W0611
14
+ BaseModel,
15
+ Extra,
16
+ Field,
17
+ Json,
18
+ )
19
+
20
+
21
+ DEFINITION = """
22
+ query OcmOrganizations {
23
+ organizations: ocm_instances_v1 {
24
+ orgId
25
+ name
26
+ environment {
27
+ name
28
+ }
29
+ }
30
+ }
31
+ """
32
+
33
+
34
+ class ConfiguredBaseModel(BaseModel):
35
+ class Config:
36
+ smart_union = True
37
+ extra = Extra.forbid
38
+
39
+
40
+ class OpenShiftClusterManagerEnvironmentV1(ConfiguredBaseModel):
41
+ name: str = Field(..., alias="name")
42
+
43
+
44
+ class OpenShiftClusterManagerV1(ConfiguredBaseModel):
45
+ org_id: str = Field(..., alias="orgId")
46
+ name: str = Field(..., alias="name")
47
+ environment: OpenShiftClusterManagerEnvironmentV1 = Field(..., alias="environment")
48
+
49
+
50
+ class OcmOrganizationsQueryData(ConfiguredBaseModel):
51
+ organizations: Optional[list[OpenShiftClusterManagerV1]] = Field(
52
+ ..., alias="organizations"
53
+ )
54
+
55
+
56
+ def query(query_func: Callable, **kwargs: Any) -> OcmOrganizationsQueryData:
57
+ """
58
+ This is a convenience function which queries and parses the data into
59
+ concrete types. It should be compatible with most GQL clients.
60
+ You do not have to use it to consume the generated data classes.
61
+ Alternatively, you can also mime and alternate the behavior
62
+ of this function in the caller.
63
+
64
+ Parameters:
65
+ query_func (Callable): Function which queries your GQL Server
66
+ kwargs: optional arguments that will be passed to the query function
67
+
68
+ Returns:
69
+ OcmOrganizationsQueryData: queried data parsed into generated classes
70
+ """
71
+ raw_data: dict[Any, Any] = query_func(DEFINITION, **kwargs)
72
+ return OcmOrganizationsQueryData(**raw_data)