qontract-reconcile 0.10.1rc522__py3-none-any.whl → 0.10.1rc525__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.1rc522
3
+ Version: 0.10.1rc525
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
@@ -70,10 +70,10 @@ reconcile/openshift_namespaces.py,sha256=DboMc6t0vXD54lL9ZP9P9fQnCRo2g_0z5FWubtW
70
70
  reconcile/openshift_network_policies.py,sha256=_qqv7yj17OM1J8KJPsFmzFZ85gzESJeBocC672z4_WU,4231
71
71
  reconcile/openshift_resourcequotas.py,sha256=yUi56PiOn3inMMfq_x_FEHmaW-reGipzoorjdar372g,2415
72
72
  reconcile/openshift_resources.py,sha256=kwsY5cko7udEKNlhL2oKiKv_5wzEw9wmmwROE016ng8,1400
73
- reconcile/openshift_resources_base.py,sha256=ZhNVhotSbp2Ue3cMEqso-Cmug6vDV67lwX7pEvUpmbw,45787
73
+ reconcile/openshift_resources_base.py,sha256=XSctdE3pD4BI-91tlV5rdXIhvdtymZYeOKiCad8ZJl4,45839
74
74
  reconcile/openshift_rolebindings.py,sha256=0sEKajdqVuBSzlagyPbLxtNXQdI2vyabmbIRifs0des,6629
75
75
  reconcile/openshift_routes.py,sha256=fXvuPSjcjVw1X3j2EQvUAdbOepmIFdKk-M3qP8QzPiw,1075
76
- reconcile/openshift_saas_deploy.py,sha256=MySDWBQN2N3rv_B8ifWzRY5t2Afq3DEVkFECHMpW_Sk,11908
76
+ reconcile/openshift_saas_deploy.py,sha256=TEB58e1FcYymso4q_v8vRBCpa--wrhUHmA4xgM5qGpg,12163
77
77
  reconcile/openshift_saas_deploy_change_tester.py,sha256=fMmPDz-ZRO-WH8OIiDo4e4sBK4-zzpvFXmVCKGY1l-I,8837
78
78
  reconcile/openshift_saas_deploy_trigger_base.py,sha256=p1Mv7dbw_K7TVFv-M-DDq6r1ltuW9VAF6PCNnEng_zM,14291
79
79
  reconcile/openshift_saas_deploy_trigger_cleaner.py,sha256=aT8wqoXGyZEeXUA7Q6reaL9v5j5UnPLoYVe70D31HUg,2917
@@ -428,7 +428,7 @@ reconcile/test/test_quay_repos.py,sha256=TdkcRF_a8PLp01Kti9eZZN-vGup2yPBT4Iba3k0
428
428
  reconcile/test/test_queries.py,sha256=SpH3RmNpBjEr_ne3VjAMCgKK8RE1z1zo7bypkT5uoO4,1946
429
429
  reconcile/test/test_repo_owners.py,sha256=uRYMLbMmh-9usF0TerabZTZV-Z1CS4I6ybT-LQqCLe8,1423
430
430
  reconcile/test/test_requests_sender.py,sha256=7fd9C2kEFS0-CYtlsif66N1kO9c44pzuBPAJKR9igqU,5385
431
- reconcile/test/test_saasherder.py,sha256=_MblumyssujfLbxqLDizRp384NRIVmaduarlNQFI1iQ,41759
431
+ reconcile/test/test_saasherder.py,sha256=hCRwkmMSws8o-SCiaa68hdD2lDXzl21EZ_6v0CCG7vA,47064
432
432
  reconcile/test/test_saasherder_allowed_secret_paths.py,sha256=5NHQwNJO66at6HiyMZ5sVRTQDwxdvlOQo0KmkBWCw5Q,4853
433
433
  reconcile/test/test_secret_reader.py,sha256=kz7nzcPjvA08cytnvcA_PMA98AEyqJWsESkYeRn5xCk,4994
434
434
  reconcile/test/test_slack_base.py,sha256=gpbWOLNxMMX6fyAbs1JakhLTnwfedb3f7WpUae4tQZE,5060
@@ -640,7 +640,7 @@ reconcile/utils/runtime/sharding.py,sha256=roCdbnBklhTK_g34zbgQYqzpKPaNQ8J6Xd9XL
640
640
  reconcile/utils/saasherder/__init__.py,sha256=J3MBZBFa5YmhqYm08QsjBXz8mFcVOCiOCkyIcw41t7E,343
641
641
  reconcile/utils/saasherder/interfaces.py,sha256=XXY35h8VWQ66z3LBPxaoUAMkIW50264DQiecrzyV6oA,9076
642
642
  reconcile/utils/saasherder/models.py,sha256=a_cE_fHo_a8iZhkwFTYVrnRwjcYg1Ayx17WbAtpXV88,5033
643
- reconcile/utils/saasherder/saasherder.py,sha256=826zFeBvOmc-28V38weJolEe1Rcr9LU_fNW7-TrQ_nM,85570
643
+ reconcile/utils/saasherder/saasherder.py,sha256=BoqaDYGsGK0f6bPkP0Cbh8JSzZbnI7MsZLc7-2ScUCI,85666
644
644
  reconcile/utils/terraform/__init__.py,sha256=zNbiyTWo35AT1sFTElL2j_AA0jJ_yWE_bfFn-nD2xik,250
645
645
  reconcile/utils/terraform/config.py,sha256=5UVrd563TMcvi4ooa5JvWVDW1I3bIWg484u79evfV_8,164
646
646
  reconcile/utils/terraform/config_client.py,sha256=py-Ree-QUYD6Hvng6bM40VgSuttteehIKNgwOSoJO1o,4706
@@ -668,8 +668,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
668
668
  tools/test/test_qontract_cli.py,sha256=d18KrdhtUGqoC7_kWZU128U0-VJEj-0rjFkLVufcI6I,2755
669
669
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
670
670
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
671
- qontract_reconcile-0.10.1rc522.dist-info/METADATA,sha256=R2XzzcNUvBuX1bSzUrBBYUQqLDtSv6D6V5Xs-cAn3Rw,2349
672
- qontract_reconcile-0.10.1rc522.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
673
- qontract_reconcile-0.10.1rc522.dist-info/entry_points.txt,sha256=rTjAv28I_CHLM8ID3OPqMI_suoQ9s7tFbim4aYjn9kk,376
674
- qontract_reconcile-0.10.1rc522.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
675
- qontract_reconcile-0.10.1rc522.dist-info/RECORD,,
671
+ qontract_reconcile-0.10.1rc525.dist-info/METADATA,sha256=jLbqlSjobIeHU4kHMd9FRJtwsljLmh3VnL_gc0jga2A,2349
672
+ qontract_reconcile-0.10.1rc525.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
673
+ qontract_reconcile-0.10.1rc525.dist-info/entry_points.txt,sha256=rTjAv28I_CHLM8ID3OPqMI_suoQ9s7tFbim4aYjn9kk,376
674
+ qontract_reconcile-0.10.1rc525.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
675
+ qontract_reconcile-0.10.1rc525.dist-info/RECORD,,
@@ -169,6 +169,10 @@ NAMESPACES_QUERY = """
169
169
  openshiftResources {
170
170
  %s
171
171
  }
172
+ environment {
173
+ name
174
+ parameters
175
+ }
172
176
  cluster {
173
177
  name
174
178
  labels
@@ -7,6 +7,8 @@ from typing import Optional
7
7
  import reconcile.openshift_base as ob
8
8
  from reconcile import (
9
9
  jenkins_base,
10
+ openshift_saas_deploy_trigger_images,
11
+ openshift_saas_deploy_trigger_upstream_jobs,
10
12
  queries,
11
13
  )
12
14
  from reconcile.gql_definitions.common.saas_files import PipelinesProviderTektonV1
@@ -302,12 +304,16 @@ def run(
302
304
  # we only do this if:
303
305
  # - this is not a dry run
304
306
  # - there is a single saas file deployed
305
- # - saas-deploy triggered by upstream-job
307
+ # - saas-deploy triggered by upstream job or image build
308
+ allowed_integration = [
309
+ openshift_saas_deploy_trigger_upstream_jobs.QONTRACT_INTEGRATION,
310
+ openshift_saas_deploy_trigger_images.QONTRACT_INTEGRATION,
311
+ ]
306
312
  sast = (
307
313
  not dry_run
308
314
  and len(saas_files) == 1
309
315
  and trigger_integration
310
- and trigger_integration == "openshift-saas-deploy-trigger-upstream-jobs"
316
+ and trigger_integration in allowed_integration
311
317
  and trigger_reason
312
318
  )
313
319
  if sast:
@@ -35,6 +35,7 @@ from reconcile.utils.openshift_resource import ResourceInventory
35
35
  from reconcile.utils.saasherder import SaasHerder
36
36
  from reconcile.utils.saasherder.interfaces import SaasFile as SaasFileInterface
37
37
  from reconcile.utils.saasherder.models import (
38
+ TriggerSpecContainerImage,
38
39
  TriggerSpecMovingCommit,
39
40
  TriggerSpecUpstreamJob,
40
41
  )
@@ -431,7 +432,7 @@ class TestSaasFileValid(TestCase):
431
432
  class TestGetMovingCommitsDiffSaasFile(TestCase):
432
433
  def setUp(self) -> None:
433
434
  self.saas_file = self.gql_class_factory( # type: ignore[attr-defined] # it's set in the fixture
434
- SaasFile, Fixtures("saasherder").get_anymarkup("saas.gql.yml")
435
+ SaasFile, Fixtures("saasherder").get_anymarkup("saas-trigger.gql.yml")
435
436
  )
436
437
 
437
438
  self.initiate_gh_patcher = patch.object(
@@ -463,7 +464,7 @@ class TestGetMovingCommitsDiffSaasFile(TestCase):
463
464
  )
464
465
  saasherder.state = MagicMock()
465
466
  saasherder.state.get.return_value = "asha"
466
- self.get_commit_sha.side_effect = ("abcd4242",)
467
+ self.get_commit_sha.return_value = "abcd4242"
467
468
  # 2nd target is the one that will be promoted
468
469
  expected = [
469
470
  TriggerSpecMovingCommit(
@@ -473,9 +474,9 @@ class TestGetMovingCommitsDiffSaasFile(TestCase):
473
474
  pipelines_provider=self.saas_file.pipelines_provider,
474
475
  resource_template_name="test-saas-deployments",
475
476
  cluster_name="appsres03ue1",
476
- namespace_name="test-ns-subscriber",
477
+ namespace_name="test-moving-commit-trigger",
477
478
  state_content="abcd4242",
478
- ref="1234567890123456789012345678901234567890",
479
+ ref="main",
479
480
  reason=None,
480
481
  )
481
482
  ]
@@ -501,7 +502,7 @@ class TestGetMovingCommitsDiffSaasFile(TestCase):
501
502
 
502
503
  saasherder.state = MagicMock()
503
504
  saasherder.state.get.return_value = "asha"
504
- self.get_commit_sha.side_effect = ("abcd4242", "4242efg")
505
+ self.get_commit_sha.return_value = "abcd4242"
505
506
  expected = [
506
507
  TriggerSpecMovingCommit(
507
508
  saas_file_name=self.saas_file.name,
@@ -510,9 +511,9 @@ class TestGetMovingCommitsDiffSaasFile(TestCase):
510
511
  pipelines_provider=self.saas_file.pipelines_provider,
511
512
  resource_template_name="test-saas-deployments",
512
513
  cluster_name="appsres03ue1",
513
- namespace_name="test-ns-subscriber",
514
+ namespace_name="test-moving-commit-trigger",
514
515
  state_content="abcd4242",
515
- ref="1234567890123456789012345678901234567890",
516
+ ref="main",
516
517
  reason="https://github.com/app-sre/test-saas-deployments/commit/abcd4242",
517
518
  ),
518
519
  ]
@@ -547,7 +548,7 @@ class TestGetMovingCommitsDiffSaasFile(TestCase):
547
548
  class TestGetUpstreamJobsDiffSaasFile(TestCase):
548
549
  def setUp(self) -> None:
549
550
  self.saas_file = self.gql_class_factory( # type: ignore[attr-defined] # it's set in the fixture
550
- SaasFile, Fixtures("saasherder").get_anymarkup("saas.gql.yml")
551
+ SaasFile, Fixtures("saasherder").get_anymarkup("saas-trigger.gql.yml")
551
552
  )
552
553
  self.maxDiff = None
553
554
 
@@ -577,7 +578,7 @@ class TestGetUpstreamJobsDiffSaasFile(TestCase):
577
578
  pipelines_provider=self.saas_file.pipelines_provider,
578
579
  resource_template_name="test-saas-deployments",
579
580
  cluster_name="appsres03ue1",
580
- namespace_name="test-ns-publisher",
581
+ namespace_name="test-upstream-job-trigger",
581
582
  instance_name="ci",
582
583
  job_name="job",
583
584
  state_content=state_content,
@@ -621,7 +622,7 @@ class TestGetUpstreamJobsDiffSaasFile(TestCase):
621
622
  pipelines_provider=self.saas_file.pipelines_provider,
622
623
  resource_template_name="test-saas-deployments",
623
624
  cluster_name="appsres03ue1",
624
- namespace_name="test-ns-publisher",
625
+ namespace_name="test-upstream-job-trigger",
625
626
  instance_name="ci",
626
627
  job_name="job",
627
628
  state_content=state_content,
@@ -636,7 +637,125 @@ class TestGetUpstreamJobsDiffSaasFile(TestCase):
636
637
  expected,
637
638
  )
638
639
 
639
- def test_get_archive_info(self) -> None:
640
+
641
+ @pytest.mark.usefixtures("inject_gql_class_factory")
642
+ class TestGetContainerImagesDiffSaasFile(TestCase):
643
+ def setUp(self) -> None:
644
+ self.saas_file = self.gql_class_factory( # type: ignore[attr-defined] # it's set in the fixture
645
+ SaasFile, Fixtures("saasherder").get_anymarkup("saas-trigger.gql.yml")
646
+ )
647
+
648
+ self.initiate_gh_patcher = patch.object(
649
+ SaasHerder, "_initiate_github", autospec=True
650
+ )
651
+ self.get_commit_sha_patcher = patch.object(
652
+ SaasHerder, "_get_commit_sha", autospec=True
653
+ )
654
+ self.check_image_patcher = patch.object(
655
+ SaasHerder, "_check_image", autospec=True
656
+ )
657
+ self.initiate_gh = self.initiate_gh_patcher.start()
658
+ self.get_commit_sha = self.get_commit_sha_patcher.start()
659
+ self.check_image = self.check_image_patcher.start()
660
+ self.maxDiff = None
661
+
662
+ def tearDown(self) -> None:
663
+ for p in (
664
+ self.initiate_gh_patcher,
665
+ self.get_commit_sha_patcher,
666
+ self.check_image_patcher,
667
+ ):
668
+ p.stop()
669
+
670
+ def test_get_container_images_diff_saas_file_all_fine(self) -> None:
671
+ saasherder = SaasHerder(
672
+ [self.saas_file],
673
+ secret_reader=MockSecretReader(),
674
+ thread_pool_size=1,
675
+ integration="",
676
+ integration_version="",
677
+ hash_length=7,
678
+ repo_url="https://repo-url.com",
679
+ )
680
+ saasherder.state = MagicMock()
681
+ saasherder.state.get.return_value = "asha"
682
+ self.get_commit_sha.return_value = "abcd4242"
683
+ self.check_image.return_value = None
684
+ expected = [
685
+ TriggerSpecContainerImage(
686
+ saas_file_name=self.saas_file.name,
687
+ env_name="App-SRE-stage",
688
+ timeout=None,
689
+ pipelines_provider=self.saas_file.pipelines_provider,
690
+ resource_template_name="test-saas-deployments",
691
+ cluster_name="appsres03ue1",
692
+ namespace_name="test-image-trigger",
693
+ image="quay.io/centos/centos",
694
+ state_content="abcd424",
695
+ reason=None,
696
+ )
697
+ ]
698
+
699
+ self.assertEqual(
700
+ saasherder.get_container_images_diff_saas_file(self.saas_file, True),
701
+ expected,
702
+ )
703
+
704
+ def test_get_container_images_diff_saas_file_all_fine_include_trigger_trace(
705
+ self,
706
+ ) -> None:
707
+ saasherder = SaasHerder(
708
+ [self.saas_file],
709
+ secret_reader=MockSecretReader(),
710
+ thread_pool_size=1,
711
+ integration="",
712
+ integration_version="",
713
+ hash_length=7,
714
+ repo_url="https://repo-url.com",
715
+ include_trigger_trace=True,
716
+ )
717
+ saasherder.state = MagicMock()
718
+ saasherder.state.get.return_value = "asha"
719
+ self.get_commit_sha.return_value = "abcd4242"
720
+ self.check_image.return_value = None
721
+ expected = [
722
+ TriggerSpecContainerImage(
723
+ saas_file_name=self.saas_file.name,
724
+ env_name="App-SRE-stage",
725
+ timeout=None,
726
+ pipelines_provider=self.saas_file.pipelines_provider,
727
+ resource_template_name="test-saas-deployments",
728
+ cluster_name="appsres03ue1",
729
+ namespace_name="test-image-trigger",
730
+ image="quay.io/centos/centos",
731
+ state_content="abcd424",
732
+ reason="https://github.com/app-sre/test-saas-deployments/commit/abcd4242 build quay.io/centos/centos:abcd424",
733
+ )
734
+ ]
735
+
736
+ self.assertEqual(
737
+ saasherder.get_container_images_diff_saas_file(self.saas_file, True),
738
+ expected,
739
+ )
740
+
741
+
742
+ @pytest.mark.usefixtures("inject_gql_class_factory")
743
+ class TestGetArchiveInfo(TestCase):
744
+ def setUp(self) -> None:
745
+ self.saas_file = self.gql_class_factory( # type: ignore[attr-defined] # it's set in the fixture
746
+ SaasFile, Fixtures("saasherder").get_anymarkup("saas-trigger.gql.yml")
747
+ )
748
+ self.initiate_gh_patcher = patch.object(
749
+ SaasHerder, "_initiate_github", autospec=True
750
+ )
751
+ self.initiate_gh = self.initiate_gh_patcher.start()
752
+ self.maxDiff = None
753
+
754
+ def tearDown(self) -> None:
755
+ for p in (self.initiate_gh_patcher,):
756
+ p.stop()
757
+
758
+ def test_get_gitlab_archive_info(self) -> None:
640
759
  trigger_reason = "https://gitlab.com/app-sre/test-saas-deployments/commit/abcd4242 via https://jenkins.com/job/job/2"
641
760
  saasherder = SaasHerder(
642
761
  [self.saas_file],
@@ -655,6 +774,26 @@ class TestGetUpstreamJobsDiffSaasFile(TestCase):
655
774
  (file_name, archive_url),
656
775
  )
657
776
 
777
+ def test_get_github_archive_info(self) -> None:
778
+ trigger_reason = "https://github.com/app-sre/test-saas-deployments/commit/abcd4242 build quay.io/centos/centos:abcd424"
779
+ saasherder = SaasHerder(
780
+ [self.saas_file],
781
+ secret_reader=MockSecretReader(),
782
+ thread_pool_size=1,
783
+ integration="",
784
+ integration_version="",
785
+ hash_length=7,
786
+ repo_url="https://repo-url.com",
787
+ include_trigger_trace=True,
788
+ )
789
+ file_name = "app-sre-test-saas-deployments-abcd4242.tar.gz"
790
+ archive_url = "https://api.github.com/repos/app-sre/test-saas-deployments/tarball/abcd4242"
791
+ self.initiate_gh.return_value.get_repo.return_value.get_archive_link.return_value = archive_url
792
+ self.assertEqual(
793
+ saasherder.get_archive_info(self.saas_file, trigger_reason),
794
+ (file_name, archive_url),
795
+ )
796
+
658
797
 
659
798
  @pytest.mark.usefixtures("inject_gql_class_factory")
660
799
  class TestPopulateDesiredState(TestCase):
@@ -948,8 +1087,7 @@ class TestConfigHashPromotionsValidation(TestCase):
948
1087
  """Promotion is not valid if the parent target config hash set in
949
1088
  the state does not match with the one set in the subscriber target
950
1089
  promotion_data. This could happen if the parent target has run again
951
- with the same ref before before the subscriber target promotion MR is
952
- merged.
1090
+ with the same ref before the subscriber target promotion MR is merged.
953
1091
  """
954
1092
  publisher_state = {
955
1093
  "success": True,
@@ -1686,7 +1686,9 @@ class SaasHerder: # pylint: disable=too-many-public-methods
1686
1686
  state_content=desired_image_tag,
1687
1687
  )
1688
1688
  if self.include_trigger_trace:
1689
- trigger_spec.reason = image_uri
1689
+ trigger_spec.reason = (
1690
+ f"{rt.url}/commit/{commit_sha} build {image_uri}"
1691
+ )
1690
1692
  if not self.state:
1691
1693
  raise Exception("state is not initialized")
1692
1694
  current_image_tag = self.state.get(trigger_spec.state_key, None)