qontract-reconcile 0.10.1rc775__py3-none-any.whl → 0.10.1rc777__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.1rc775
3
+ Version: 0.10.1rc777
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
@@ -77,7 +77,7 @@ reconcile/openshift_rolebindings.py,sha256=LlImloBisEqzc36jaatic-TeM3hzqMEfxogF-
77
77
  reconcile/openshift_routes.py,sha256=fXvuPSjcjVw1X3j2EQvUAdbOepmIFdKk-M3qP8QzPiw,1075
78
78
  reconcile/openshift_saas_deploy.py,sha256=fmhopPEbyZsGQHRPzyzpKEvoBXEGN3aPxFi7Utq0emU,12788
79
79
  reconcile/openshift_saas_deploy_change_tester.py,sha256=fMmPDz-ZRO-WH8OIiDo4e4sBK4-zzpvFXmVCKGY1l-I,8837
80
- reconcile/openshift_saas_deploy_trigger_base.py,sha256=p1Mv7dbw_K7TVFv-M-DDq6r1ltuW9VAF6PCNnEng_zM,14291
80
+ reconcile/openshift_saas_deploy_trigger_base.py,sha256=-XsLbN1FRIbrBwdUyE3Xa4cIHu72imG1GNsMFH9jCTs,14040
81
81
  reconcile/openshift_saas_deploy_trigger_cleaner.py,sha256=gU226N1JUvgEbTgDf7ouJ6QzZGMI_BLwXdS67UCukRk,3554
82
82
  reconcile/openshift_saas_deploy_trigger_configs.py,sha256=uWzUV5D5CW0frdi1ys7BObNg-rA-VZKlefd4TD_Z-pY,959
83
83
  reconcile/openshift_saas_deploy_trigger_images.py,sha256=Yl4lMtxqab-c04I2Ju8isAJuYuNTbHN01Bk3dF9nTos,967
@@ -112,7 +112,7 @@ reconcile/terraform_aws_route53.py,sha256=R8eZHlvP368nvtmLd_cMSK3RGxD7jso9qE7NP9
112
112
  reconcile/terraform_cloudflare_dns.py,sha256=MZO3_2Hb0BhNkOTWIm2UHvR-SPKvLsk2l_fHNk4WOrk,13471
113
113
  reconcile/terraform_cloudflare_resources.py,sha256=EbQQaoDnZ7brvRCpbFtwlD7KLk2hDVNcjhrJGaAywEk,15023
114
114
  reconcile/terraform_cloudflare_users.py,sha256=1EbTHwJgiPkJpMP-Ag340QNgGK3mXn3dcC3DpLakudM,13987
115
- reconcile/terraform_repo.py,sha256=tQkMUEDEB6QfuWYwiW7H-NnX4SHxYK7mLZYZffKj-hE,16301
115
+ reconcile/terraform_repo.py,sha256=xkp5EiRQ7cz-IquXiBq5plvBQLf910tqywKK0B_QlPM,16271
116
116
  reconcile/terraform_resources.py,sha256=BN8XuJwjOt1ztruEAHydkd0YiBlb3fHZ7n0snZtRhck,19356
117
117
  reconcile/terraform_tgw_attachments.py,sha256=k9Lf0ST65gmI6aUV6HnvxSGcKL7MGx_lN22OXuRGH9Y,16224
118
118
  reconcile/terraform_users.py,sha256=9rgbM572LfmOSnV3uCP20G_Cw6T7due94g8rhhiz904,10225
@@ -497,7 +497,7 @@ reconcile/test/test_openshift_namespace_labels.py,sha256=P1hqi6P88NijNrurdXG_QR2
497
497
  reconcile/test/test_openshift_namespaces.py,sha256=HmRnCE5EnFt3MYceVEFHmk8wWRtCrxu2AFGFkY9pdyA,9214
498
498
  reconcile/test/test_openshift_resource.py,sha256=lbTf48jX1q6rGnRiA5pPvfU0uPfY8zhNylMtryn0sLI,12995
499
499
  reconcile/test/test_openshift_resources_base.py,sha256=LtlR9x3o7KkSEw0JN0fZhinFeAAxBAQlB_9PpBnKwOM,14353
500
- reconcile/test/test_openshift_saas_deploy.py,sha256=YLJGkc--u5aP0UkQ-b9ZGEFGS2gw25jjcSgknQdI3Ic,5892
500
+ reconcile/test/test_openshift_saas_deploy.py,sha256=X0cv-f6YoAz-42UamPPFgZROirkzuBBJMiQEYZU_rKA,6001
501
501
  reconcile/test/test_openshift_saas_deploy_change_tester.py,sha256=1yVe54Hx9YdVjn6qdnKge5Sa_s732c-8uZqCnuT1gGI,12871
502
502
  reconcile/test/test_openshift_saas_deploy_trigger_cleaner.py,sha256=cha3bUiXAWPCwrp8XwVC3RNJtJHLcsGTE-F8Zn6XxsU,2852
503
503
  reconcile/test/test_openshift_tekton_resources.py,sha256=RtRWsdm51S13OSkENC9nY_rOH0QELSCaO5tjF0XqIDI,11222
@@ -635,12 +635,12 @@ reconcile/utils/make.py,sha256=QaEwucrzbl8-VHS66Wfdjfo0ubmAcvt_hZGpiGsKU50,231
635
635
  reconcile/utils/metrics.py,sha256=ot4dBO-KLZRowvNozm7jG0RWjcVsH1SL-lQ0jJgBBZM,18645
636
636
  reconcile/utils/models.py,sha256=It_Q1WNIvw_EDCsiSWzIgpSPr_X9jMgbJI-DR3N23xY,4677
637
637
  reconcile/utils/oauth2_backend_application_session.py,sha256=6W16sMpnWEPFDUX7qi5Cui2yOnmLfpgUxWtB3Ii35D0,4177
638
- reconcile/utils/oc.py,sha256=ILAlP-AZMtWeyAepLoMnYbDJfyyMs-Z0fOEo9JXQfkE,65490
638
+ reconcile/utils/oc.py,sha256=ZA2RwR7UcLzhvRKUoFt0knhizl7wm-4WpZyT4N48ntg,65564
639
639
  reconcile/utils/oc_connection_parameters.py,sha256=85slrnDigYwYmzhyceVkMElWzFArp4ge1d-fHXVqh0w,9729
640
640
  reconcile/utils/oc_filters.py,sha256=R2Lf3fo0jQCeE62Ygeo_KN24XbAosq0QbjimYG6qHI4,1402
641
641
  reconcile/utils/oc_map.py,sha256=nT69J5pdPeIDnIYjD9fwY6GkE3BMQCf-AF0rmHJuUNw,9068
642
642
  reconcile/utils/ocm_base_client.py,sha256=X8qkPXfpfJdBKBtFv7zyGD33HNAEBJL8owf-ykrt-Ts,6469
643
- reconcile/utils/openshift_resource.py,sha256=Ft1LpKrG71pU-gEA95Xp0G6a6Prmru0SzBSzxjaJ8no,24516
643
+ reconcile/utils/openshift_resource.py,sha256=Gxhc3oyYDCfMix7RDVvNAZX9O1bQII0KAjGsC5pu7oA,24831
644
644
  reconcile/utils/openssl.py,sha256=QVvhzhpChq_4Daf_5wE1qeZJr4thg3DDjJPn4bOPD4E,365
645
645
  reconcile/utils/output.py,sha256=4tObxIS_-EdJY_YCOOOmaYvHY40Q72IpYjWhjpJR1Ec,1856
646
646
  reconcile/utils/pagerduty_api.py,sha256=fcSAUez6w51woDvbm0plJW2qSw6_NXQs1Fit_KTNitc,7653
@@ -750,7 +750,7 @@ reconcile/utils/runtime/sharding.py,sha256=roCdbnBklhTK_g34zbgQYqzpKPaNQ8J6Xd9XL
750
750
  reconcile/utils/saasherder/__init__.py,sha256=J3MBZBFa5YmhqYm08QsjBXz8mFcVOCiOCkyIcw41t7E,343
751
751
  reconcile/utils/saasherder/interfaces.py,sha256=XXY35h8VWQ66z3LBPxaoUAMkIW50264DQiecrzyV6oA,9076
752
752
  reconcile/utils/saasherder/models.py,sha256=1DKXUmiTS_MejUfSpFCeuBLMTgR4ldv2N1tAz8qHAwc,5547
753
- reconcile/utils/saasherder/saasherder.py,sha256=4IQL-r2uo1iejv0krdaPXaW9CnqBKF6t9Skjs2m263I,86170
753
+ reconcile/utils/saasherder/saasherder.py,sha256=i15fDTccbSrOWlTPE35WAs8isnfeHYZf18vCMNc_794,86165
754
754
  reconcile/utils/terraform/__init__.py,sha256=zNbiyTWo35AT1sFTElL2j_AA0jJ_yWE_bfFn-nD2xik,250
755
755
  reconcile/utils/terraform/config.py,sha256=5UVrd563TMcvi4ooa5JvWVDW1I3bIWg484u79evfV_8,164
756
756
  reconcile/utils/terraform/config_client.py,sha256=py-Ree-QUYD6Hvng6bM40VgSuttteehIKNgwOSoJO1o,4706
@@ -785,8 +785,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
785
785
  tools/test/test_qontract_cli.py,sha256=w2l4BHB09k1d-BGJ1jBUNCqDv7zkqYrMHojQXg-21kQ,4155
786
786
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
787
787
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
788
- qontract_reconcile-0.10.1rc775.dist-info/METADATA,sha256=0RR3_Y0t9TLbpUkHYa4h7bAJ9e63UgmA91c_qqbBBYU,2382
789
- qontract_reconcile-0.10.1rc775.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
790
- qontract_reconcile-0.10.1rc775.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
791
- qontract_reconcile-0.10.1rc775.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
792
- qontract_reconcile-0.10.1rc775.dist-info/RECORD,,
788
+ qontract_reconcile-0.10.1rc777.dist-info/METADATA,sha256=y8s0XFcnoAsVoxo2TqjHkrGZJJEhyXPUrVg8_-Q8h-w,2382
789
+ qontract_reconcile-0.10.1rc777.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
790
+ qontract_reconcile-0.10.1rc777.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
791
+ qontract_reconcile-0.10.1rc777.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
792
+ qontract_reconcile-0.10.1rc777.dist-info/RECORD,,
@@ -1,4 +1,3 @@
1
- import datetime
2
1
  import logging
3
2
  from collections.abc import Callable
4
3
  from threading import Lock
@@ -356,11 +355,7 @@ def _construct_tekton_trigger_resource(
356
355
  tkn_name, tkn_long_name = SaasHerder.build_saas_file_env_combo(
357
356
  saas_file_name, env_name
358
357
  )
359
- # using a timestamp to make the resource name unique.
360
- # we may want to revisit traceability, but this is compatible
361
- # with what we currently have in Jenkins.
362
- ts = datetime.datetime.utcnow().strftime("%Y%m%d%H%M") # len 12
363
- name = f"{tkn_name.lower()}-{ts}"
358
+ name = tkn_name.lower()
364
359
 
365
360
  parameters = [
366
361
  {"name": "saas_file_name", "value": saas_file_name},
@@ -381,7 +376,7 @@ def _construct_tekton_trigger_resource(
381
376
  body: dict[str, Any] = {
382
377
  "apiVersion": "tekton.dev/v1",
383
378
  "kind": "PipelineRun",
384
- "metadata": {"name": name},
379
+ "metadata": {"generateName": f"{name}-"},
385
380
  "spec": {
386
381
  "pipelineRef": {"name": tkn_pipeline_name},
387
382
  "params": parameters,
@@ -112,7 +112,6 @@ class TerraformRepoIntegration(
112
112
  # when updating TerraformRepoV1 GQL schema, Pydantic does not gracefully handle these changes and fails to parse
113
113
  # the existing state stored in S3. This is due to a behavior in Pydantic V1 that has since been addressed in V2
114
114
  # https://docs.pydantic.dev/latest/blog/pydantic-v2/#required-vs-nullable-cleanup
115
- # so in this case, tf-repo will just recreate all of those state files in S3 and not actually do a plan or apply
116
115
  logging.error(err)
117
116
  logging.info(
118
117
  "Unable to parse existing Terraform-Repo state from S3. Note that this is separate from the actual .tfstate files. Terraform Repo will re-create its own state upon merge and will not update any infrastructure. This typically occurs with changes to the Terraform Repo schema files and is normally resolved once state is re-created."
@@ -125,6 +124,9 @@ class TerraformRepoIntegration(
125
124
  recreate_state=True,
126
125
  )
127
126
 
127
+ if repo_diff_result:
128
+ self.print_output(repo_diff_result, dry_run)
129
+
128
130
  def print_output(self, diff: list[TerraformRepoV1], dry_run: bool) -> OutputFile:
129
131
  """Parses and prints the output of a Terraform Repo diff for the executor
130
132
 
@@ -15,6 +15,7 @@ from reconcile.utils import (
15
15
  openshift_resource,
16
16
  slack_api,
17
17
  )
18
+ from reconcile.utils.saasherder.saasherder import UNIQUE_SAAS_FILE_ENV_COMBO_LEN
18
19
 
19
20
 
20
21
  @pytest.fixture
@@ -72,7 +73,7 @@ def test_compose_console_url_with_medium_saas_name(
72
73
 
73
74
  url = compose_console_url(saas_file, env_name)
74
75
 
75
- expected_run_name = f"{saas_name}-{env_name}"[:50]
76
+ expected_run_name = f"{saas_name}-{env_name}"[:UNIQUE_SAAS_FILE_ENV_COMBO_LEN]
76
77
  assert (
77
78
  url == "https://console.url/k8s/ns/namespace_name/tekton.dev~v1beta1~Pipeline/"
78
79
  "o-saas-deploy-saas-openshift-cert-manager-routes/"
reconcile/utils/oc.py CHANGED
@@ -51,6 +51,7 @@ from reconcile.utils.jump_host import (
51
51
  )
52
52
  from reconcile.utils.metrics import reconcile_time
53
53
  from reconcile.utils.oc_connection_parameters import OCConnectionParameters
54
+ from reconcile.utils.openshift_resource import OpenshiftResource as OR
54
55
  from reconcile.utils.secret_reader import (
55
56
  SecretNotFound,
56
57
  SecretReader,
@@ -162,10 +163,10 @@ class OCDecorators:
162
163
  time_spent = time.time() - commit_time
163
164
 
164
165
  try:
165
- resource_kind = msg.resource["kind"]
166
- resource_name = msg.resource["metadata"]["name"]
167
- annotations = msg.resource["metadata"].get("annotations", {})
168
- except KeyError as e:
166
+ resource_kind = msg.resource.kind
167
+ resource_name = msg.resource.name
168
+ annotations = msg.resource.annotations
169
+ except Exception as e:
169
170
  logging.warning(f"Error processing metric: {e}")
170
171
  return result
171
172
 
@@ -204,11 +205,11 @@ class OCDecorators:
204
205
  class OCProcessReconcileTimeDecoratorMsg:
205
206
  def __init__(
206
207
  self,
207
- namespace,
208
- resource,
209
- server,
210
- slow_oc_reconcile_threshold,
211
- is_log_slow_oc_reconcile,
208
+ namespace: str,
209
+ resource: OR,
210
+ server: Optional[str],
211
+ slow_oc_reconcile_threshold: float,
212
+ is_log_slow_oc_reconcile: bool,
212
213
  ):
213
214
  self.namespace = namespace
214
215
  self.resource = resource
@@ -523,7 +524,7 @@ class OCCli: # pylint: disable=too-many-public-methods
523
524
  ]
524
525
  self._run(cmd)
525
526
 
526
- def _msg_to_process_reconcile_time(self, namespace, resource):
527
+ def _msg_to_process_reconcile_time(self, namespace: str, resource: OR):
527
528
  return OCProcessReconcileTimeDecoratorMsg(
528
529
  namespace=namespace,
529
530
  resource=resource,
@@ -550,25 +551,25 @@ class OCCli: # pylint: disable=too-many-public-methods
550
551
  def apply(self, namespace, resource):
551
552
  cmd = ["apply", "-n", namespace, "-f", "-"]
552
553
  self._run(cmd, stdin=resource.toJSON(), apply=True)
553
- return self._msg_to_process_reconcile_time(namespace, resource.body)
554
+ return self._msg_to_process_reconcile_time(namespace, resource)
554
555
 
555
556
  @OCDecorators.process_reconcile_time
556
557
  def create(self, namespace, resource):
557
558
  cmd = ["create", "-n", namespace, "-f", "-"]
558
559
  self._run(cmd, stdin=resource.toJSON(), apply=True)
559
- return self._msg_to_process_reconcile_time(namespace, resource.body)
560
+ return self._msg_to_process_reconcile_time(namespace, resource)
560
561
 
561
562
  @OCDecorators.process_reconcile_time
562
563
  def replace(self, namespace, resource):
563
564
  cmd = ["replace", "-n", namespace, "-f", "-"]
564
565
  self._run(cmd, stdin=resource.toJSON(), apply=True)
565
- return self._msg_to_process_reconcile_time(namespace, resource.body)
566
+ return self._msg_to_process_reconcile_time(namespace, resource)
566
567
 
567
568
  @OCDecorators.process_reconcile_time
568
569
  def patch(self, namespace, kind, name, patch):
569
570
  cmd = ["patch", "-n", namespace, kind, name, "-p", json.dumps(patch)]
570
571
  self._run(cmd)
571
- resource = {"kind": kind, "metadata": {"name": name}}
572
+ resource = OR({"kind": kind, "metadata": {"name": name}}, "", "")
572
573
  return self._msg_to_process_reconcile_time(namespace, resource)
573
574
 
574
575
  @OCDecorators.process_reconcile_time
@@ -214,12 +214,20 @@ class OpenshiftResource:
214
214
 
215
215
  @property
216
216
  def name(self):
217
- return self.body["metadata"]["name"]
217
+ # PipelineRun name can be empty when creating
218
+ if self.kind == "PipelineRun" and "name" not in self.body["metadata"]:
219
+ return self.body["metadata"]["generateName"][:-1]
220
+ else:
221
+ return self.body["metadata"]["name"]
218
222
 
219
223
  @property
220
224
  def kind(self):
221
225
  return self.body["kind"]
222
226
 
227
+ @property
228
+ def annotations(self):
229
+ return self.body["metadata"].get("annotations", {})
230
+
223
231
  @property
224
232
  def kind_and_group(self):
225
233
  return fully_qualified_kind(self.kind, self.body["apiVersion"])
@@ -93,7 +93,7 @@ from reconcile.utils.state import State
93
93
  TARGET_CONFIG_HASH = "target_config_hash"
94
94
 
95
95
 
96
- UNIQUE_SAAS_FILE_ENV_COMBO_LEN = 50
96
+ UNIQUE_SAAS_FILE_ENV_COMBO_LEN = 56
97
97
 
98
98
 
99
99
  def is_commit_sha(ref: str) -> bool:
@@ -491,7 +491,7 @@ class SaasHerder: # pylint: disable=too-many-public-methods
491
491
  """
492
492
  Build a tuple of short and long names for a saas file and environment combo,
493
493
  max tekton pipelinerun name length can be 63,
494
- leaving 12 for the timestamp leaves us with 51 to create a unique pipelinerun name.
494
+ leaving 7 for the rerun leaves us with 56 to create a unique pipelinerun name.
495
495
 
496
496
  :param saas_file_name: name of the saas file
497
497
  :param env_name: name of the environment