qontract-reconcile 0.10.2.dev91__py3-none-any.whl → 0.10.2.dev92__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.4
2
2
  Name: qontract-reconcile
3
- Version: 0.10.2.dev91
3
+ Version: 0.10.2.dev92
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Project-URL: homepage, https://github.com/app-sre/qontract-reconcile
6
6
  Project-URL: repository, https://github.com/app-sre/qontract-reconcile
@@ -208,11 +208,11 @@ reconcile/external_resources/secrets_sync.py,sha256=ZDxzGZ6wC4zxLhA7-L39xDRH6rzU
208
208
  reconcile/external_resources/state.py,sha256=gF3ACdl7YiUlbQ4uEGrD6i_Txxqr6mT9f8IFlTQ-8dY,13176
209
209
  reconcile/fleet_labeler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
210
210
  reconcile/fleet_labeler/dependencies.py,sha256=ZOpmtwgxEPBWU2yHRc6rhPwlvqhwYSsNMJQ_jVq1dLI,2993
211
- reconcile/fleet_labeler/integration.py,sha256=x-vfUcWRCI8-_2O1mdEdSbqGM51IwEBgUUKQPlu5_TM,12849
211
+ reconcile/fleet_labeler/integration.py,sha256=IeDUDlIIZREQRbsODB9xsCMoNrMk5738OF_fP7lUGFs,13128
212
212
  reconcile/fleet_labeler/merge_request.py,sha256=SfGxXInxeJzVnsTtO0ZC9-PesUJMdpKxKY9eCB6ms-g,1538
213
213
  reconcile/fleet_labeler/meta.py,sha256=lWnpH2U0PHCPXu9Ok_CPmO494qQJQ5pOuqo28s0jzIQ,146
214
214
  reconcile/fleet_labeler/metrics.py,sha256=wx9BmXLsN67m-aSsf81iB7Ehj5SzUsS2WB75isUReZg,662
215
- reconcile/fleet_labeler/ocm.py,sha256=1VkUZtgcoqg-F9r--VtTg2LReumkOcRBIPhj-yTCKE0,3470
215
+ reconcile/fleet_labeler/ocm.py,sha256=qcg1_p7nKlZG7-MQeOZos3rz6YSPAPh-HKxE3OVJwe0,4165
216
216
  reconcile/fleet_labeler/validate.py,sha256=gzc2tt7h9F60h7dcyJfEmsnjnfuux5Jtc_WzrIqr-5k,2541
217
217
  reconcile/fleet_labeler/vcs.py,sha256=6UHUQ08AGAHXF7629I6X-T_E1pvx96LxjS66EeOzve4,1108
218
218
  reconcile/glitchtip/README.md,sha256=rfXT6jNP9khJW65jL7I2PgoxvxgcGGuJF8NpbzufEQ4,4335
@@ -786,7 +786,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
786
786
  tools/saas_promotion_state/saas_promotion_state.py,sha256=UfwwRLS5Ya4_Nh1w5n1dvoYtchQvYE9yj1VANt2IKqI,3925
787
787
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
788
788
  tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
789
- qontract_reconcile-0.10.2.dev91.dist-info/METADATA,sha256=Zb9JTF0crcCR37ioM_rENLPJWgXh1_1IyFQGxR8kqx8,24565
790
- qontract_reconcile-0.10.2.dev91.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
791
- qontract_reconcile-0.10.2.dev91.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
792
- qontract_reconcile-0.10.2.dev91.dist-info/RECORD,,
789
+ qontract_reconcile-0.10.2.dev92.dist-info/METADATA,sha256=jLJhRpJR82Z3TVBJRPKXiwDJF_rs9_Vz9L9aaajBipo,24565
790
+ qontract_reconcile-0.10.2.dev92.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
791
+ qontract_reconcile-0.10.2.dev92.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
792
+ qontract_reconcile-0.10.2.dev92.dist-info/RECORD,,
@@ -105,9 +105,13 @@ class FleetLabelerIntegration(QontractReconcileIntegration[NoParams]):
105
105
  for label_default in spec.label_defaults:
106
106
  match_subscription_labels = dict(label_default.match_subscription_labels)
107
107
  for cluster in ocm.discover_clusters_by_labels(
108
- labels=match_subscription_labels
108
+ labels=match_subscription_labels,
109
+ managed_prefix=spec.managed_subscription_label_prefix,
109
110
  ):
110
- # TODO: ideally we filter on server side - see TODO in ocm.py
111
+ # Note, due to the nature of how our label filtering works (see ocm.py), we
112
+ # also fetch clusters that do not match the filter label.
113
+ # Here, we filter the clusters on client side.
114
+ # TODO: move this into utils.ocm module
111
115
  if (
112
116
  match_subscription_labels.items()
113
117
  <= cluster.subscription_labels.items()
@@ -71,17 +71,32 @@ class OCMClient:
71
71
  def __init__(self, ocm_client: OCMBaseClient):
72
72
  self._ocm_client = ocm_client
73
73
 
74
- def discover_clusters_by_labels(self, labels: Mapping[str, str]) -> list[Cluster]:
74
+ def discover_clusters_by_labels(
75
+ self, labels: Mapping[str, str], managed_prefix: str
76
+ ) -> list[Cluster]:
75
77
  label_filter = Filter(mode=FilterMode.AND).eq("type", "Subscription")
76
78
  for key in labels:
77
79
  label_filter = label_filter.eq("Key", key)
78
- # TODO: This throws 400 bad request
79
- # for k, v in labels.items():
80
- # label_filter = label_filter.eq(k, v)
80
+ desired_labels_filter = (
81
+ Filter(mode=FilterMode.AND)
82
+ .eq("type", "Subscription")
83
+ .like(
84
+ "key",
85
+ f"{managed_prefix}.%",
86
+ )
87
+ )
88
+ # Note, that discover_clusters_by_labels() only fetches labels that are matching the filter!
89
+ # However, to understand current state, we also want to know the labels under managed_prefix.
90
+ # I.e., we need a fetch condition such as:
91
+ # ("{managed_prefix}.%") OR ("{key1_filter}" AND "{key2_filter}" ....)
92
+ # The above returns also clusters that do not fit the match label.
93
+ # I.e., we must filter the result on client side.
94
+ # TODO: do this in utils.ocm module
95
+ desired_filter = label_filter | desired_labels_filter
81
96
  return [
82
97
  Cluster.from_cluster_details(cluster)
83
98
  for cluster in discover_clusters_by_labels(
84
- ocm_api=self._ocm_client, label_filter=label_filter
99
+ ocm_api=self._ocm_client, label_filter=desired_filter
85
100
  )
86
101
  ]
87
102