qontract-reconcile 0.10.1rc1011__py3-none-any.whl → 0.10.1rc1013__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.1rc1011
3
+ Version: 0.10.1rc1013
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
@@ -190,13 +190,13 @@ reconcile/external_resources/aws.py,sha256=JvjKaABy2Pg8u8Lq82Acv4zMvpE3_qGKes7OG
190
190
  reconcile/external_resources/factories.py,sha256=DXgaLxoO87zZ76VOpRpu2GeYGhsbfOnOx5mrzgo4Gf4,4767
191
191
  reconcile/external_resources/integration.py,sha256=y1gJ16woMBC3J9qniMmS5y3lCkAs7V_ETZRUwjKqaO0,6628
192
192
  reconcile/external_resources/integration_secrets_sync.py,sha256=cMEZhgCvABAMf-DWF051L6CRnJQdfbsISA_b1xuS940,1670
193
- reconcile/external_resources/manager.py,sha256=8lHOFyA_xF8thQXbmJp8zzA2-oJ0MUhfnCcFpkexwjU,15089
193
+ reconcile/external_resources/manager.py,sha256=xVwcFAPFG0HyMl_uzj8D6XXdH-Zmcw541DX0IHs57Jc,15278
194
194
  reconcile/external_resources/meta.py,sha256=cMT9OsKcUY26qwEjlQ02EkorvOBNqWj0JVMwfJa3Mg0,634
195
195
  reconcile/external_resources/metrics.py,sha256=m2TIOao2N7pD6k45driFbBGVCC_N7ai44m-lLPfa5qk,454
196
196
  reconcile/external_resources/model.py,sha256=oXxJkjhV53lwwAuxUCBrjJ8aCJmQdgcKWv68ugJPK4k,7229
197
197
  reconcile/external_resources/reconciler.py,sha256=E50X_lnOD0OWYXMzyZld1P6dCFJFYjHGyICWff9bxlc,9323
198
198
  reconcile/external_resources/secrets_sync.py,sha256=6n0oDPLjd9Ql0lf6zsr1AZw8A6EEe3yCzl20XodtgkE,16229
199
- reconcile/external_resources/state.py,sha256=bWq51xPK4-BHVXWsRu6Y-vn69yg9Dse4x1RNNF7qw84,9614
199
+ reconcile/external_resources/state.py,sha256=fKU6PLYOZ2ZTaIwvt1BNlNOnIqcewLijOyT3Lgcd1NE,9677
200
200
  reconcile/glitchtip/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
201
201
  reconcile/glitchtip/integration.py,sha256=XtewM9nfTPLnPSpYebP50GrveYOnhTvKNq3seSvL6u8,8343
202
202
  reconcile/glitchtip/reconciler.py,sha256=nUvDv7qG1ly0cA16MmlL6NV71yl1mJYLT2mui7lmi0Y,12402
@@ -765,7 +765,7 @@ reconcile/utils/membershipsources/resolver.py,sha256=meERrCZqeVJZR2lHdZEznaZDsCs
765
765
  reconcile/utils/merge_request_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
766
766
  reconcile/utils/merge_request_manager/merge_request_manager.py,sha256=3EP6Yw_zB7nY0OkU8D_32nDqta1TITgtRI0cSmOlNQg,3332
767
767
  reconcile/utils/merge_request_manager/parser.py,sha256=5pGoz8Q6EuYXlUc1z-D0FahdRP2YLO8CpACoa9HcgtQ,2098
768
- reconcile/utils/mr/__init__.py,sha256=uvqxcp-uSlJExaH00XNCX9DSvA57jHTlPTg5dbZ_xvk,2487
768
+ reconcile/utils/mr/__init__.py,sha256=IvDRx0x33ROPZ66DDkg3FCt8pLpcaVRGWyCJvZQ1SPE,2578
769
769
  reconcile/utils/mr/app_interface_reporter.py,sha256=6Kpg93V9FvcOke9Jimkva359MQ-ZyBIkUpf8QIA6-to,1793
770
770
  reconcile/utils/mr/aws_access.py,sha256=w-UJutB_OfBJOvr-gsPzhtBPkDfKcNZZWGGuI9cN3HI,2605
771
771
  reconcile/utils/mr/base.py,sha256=TP6xaxznxsF_v2KcC_D3ut1cX_4KCcx4pjIC1-4eZUY,7307
@@ -775,7 +775,7 @@ reconcile/utils/mr/labels.py,sha256=9QRTRjZAtq45zELd9SwavaraczMjwjn5no3RK1YxFTg,
775
775
  reconcile/utils/mr/notificator.py,sha256=cp80wFzu_ZzrJPye7L1pI0H6JRGb7hOGuNxJYUq4Yr8,2967
776
776
  reconcile/utils/mr/ocm_update_recommended_version.py,sha256=p_aVP0TGrlKk9WBwgQnYWqUDsED_Hg6G5Bqj0UvtRwA,1536
777
777
  reconcile/utils/mr/ocm_upgrade_scheduler_org_updates.py,sha256=ojnIjw-8vRnmCCxOGBOEgPZLH4nC1hcuef74LWw2Rpk,3004
778
- reconcile/utils/mr/promote_qontract.py,sha256=AgA7AXizYvUoycLMZb1zaa4BCLi4stsokWfEH4B0eWY,1266
778
+ reconcile/utils/mr/promote_qontract.py,sha256=6WWCSOU9B7P1VY8z7PCFWCnHA0LM0RuOwkZPWsFR700,6095
779
779
  reconcile/utils/mr/user_maintenance.py,sha256=cHPBn8zrReWLHalyk-EFdkFJe9zjVjRoZhT4t2zZfGE,3956
780
780
  reconcile/utils/ocm/__init__.py,sha256=xv7CJp7K9LCQfa4gL_W0MMCOD1P4qOy8t5aZj1xXNUE,808
781
781
  reconcile/utils/ocm/addons.py,sha256=_LDdJ-gapM3s5exKlIUt-MlXZTAUoHezbYBU0QmvfWQ,7335
@@ -828,7 +828,7 @@ tools/app_interface_metrics_exporter.py,sha256=zkwkxdAUAxjdc-pzx2_oJXG25fo0Fnyd5
828
828
  tools/app_interface_reporter.py,sha256=1ZP58LYV6ww3XOLVxgy8NKasMb1jQmp4BNqzTEB0VBE,17723
829
829
  tools/glitchtip_access_reporter.py,sha256=oPBnk_YoDuljU3v0FaChzOwwnk4vap1xEE67QEjzdqs,2948
830
830
  tools/glitchtip_access_revalidation.py,sha256=8kbBJk04mkq28kWoRDDkfCGIF3GRg3pJrFAh1sW0dbk,2821
831
- tools/qontract_cli.py,sha256=iY_ORJiPBF2CShM33AtPdRPX-1f8PFM4Kfbe4M5TlPQ,126959
831
+ tools/qontract_cli.py,sha256=bFTYOymVksNKp_ntG2l9GoA40tODuxeRDU3rO4J-CjA,128875
832
832
  tools/sd_app_sre_alert_report.py,sha256=e9vAdyenUz2f5c8-z-5WY0wv-SJ9aePKDH2r4IwB6pc,5063
833
833
  tools/template_validation.py,sha256=qpKYaTgk0GOPGa2Ct5_5sKdwIHtCAKIBGzsMPuJU5fw,3371
834
834
  tools/cli_commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -859,8 +859,8 @@ tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jr
859
859
  tools/test/test_saas_promotion_state.py,sha256=dy4kkSSAQ7bC0Xp2CociETGN-2aABEfL6FU5D9Jl00Y,6056
860
860
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
861
861
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
862
- qontract_reconcile-0.10.1rc1011.dist-info/METADATA,sha256=mei58NlsUM1RcmUd_fFIw1dobxT6K84nBBpAyJVmwW4,2263
863
- qontract_reconcile-0.10.1rc1011.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
864
- qontract_reconcile-0.10.1rc1011.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
865
- qontract_reconcile-0.10.1rc1011.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
866
- qontract_reconcile-0.10.1rc1011.dist-info/RECORD,,
862
+ qontract_reconcile-0.10.1rc1013.dist-info/METADATA,sha256=tgKuWgs3q0f26bk6n-zH9HNNPtHowDnv4i-_JmbuCsQ,2263
863
+ qontract_reconcile-0.10.1rc1013.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
864
+ qontract_reconcile-0.10.1rc1013.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
865
+ qontract_reconcile-0.10.1rc1013.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
866
+ qontract_reconcile-0.10.1rc1013.dist-info/RECORD,,
@@ -79,6 +79,7 @@ class ReconcileAction(StrEnum):
79
79
  APPLY_ERROR = "Resource status in ERROR state"
80
80
  APPLY_SPEC_CHANGED = "Resource spec has changed"
81
81
  APPLY_DRIFT_DETECTION = "Resource drift detection run"
82
+ APPLY_USER_REQUESTED = "Resource reconciliation requested"
82
83
  DESTROY_CREATED = "Resource no longer exists in the configuration"
83
84
  DESTROY_ERROR = "Resource status in ERROR state"
84
85
 
@@ -112,6 +113,8 @@ class ExternalResourcesManager:
112
113
  ) -> ReconcileAction:
113
114
  if reconciliation.action == Action.APPLY:
114
115
  match state.resource_status:
116
+ case ResourceStatus.RECONCILIATION_REQUESTED:
117
+ return ReconcileAction.APPLY_USER_REQUESTED
115
118
  case ResourceStatus.NOT_EXISTS:
116
119
  return ReconcileAction.APPLY_NOT_EXISTS
117
120
  case ResourceStatus.ERROR:
@@ -36,6 +36,7 @@ class ResourceStatus(StrEnum):
36
36
  DELETE_IN_PROGRESS: str = "DELETE_IN_PROGRESS"
37
37
  ERROR: str = "ERROR"
38
38
  PENDING_SECRET_SYNC: str = "PENDING_SECRET_SYNC"
39
+ RECONCILIATION_REQUESTED: str = "RECONCILIATION_REQUESTED"
39
40
 
40
41
 
41
42
  class ExternalResourceState(BaseModel):
@@ -12,7 +12,10 @@ from reconcile.utils.mr.ocm_update_recommended_version import (
12
12
  from reconcile.utils.mr.ocm_upgrade_scheduler_org_updates import (
13
13
  CreateOCMUpgradeSchedulerOrgUpdates,
14
14
  )
15
- from reconcile.utils.mr.promote_qontract import PromoteQontractSchemas
15
+ from reconcile.utils.mr.promote_qontract import (
16
+ PromoteQontractReconcileCommercial,
17
+ PromoteQontractSchemas,
18
+ )
16
19
  from reconcile.utils.mr.user_maintenance import (
17
20
  CreateDeleteUserAppInterface,
18
21
  CreateDeleteUserInfra,
@@ -31,6 +34,7 @@ __all__ = [
31
34
  "CreateDeleteUserAppInterface",
32
35
  "CreateDeleteUserInfra",
33
36
  "PromoteQontractSchemas",
37
+ "PromoteQontractReconcileCommercial",
34
38
  ]
35
39
 
36
40
 
@@ -1,5 +1,8 @@
1
+ from ruamel.yaml.compat import StringIO
2
+
1
3
  from reconcile.utils.gitlab_api import GitLabApi
2
4
  from reconcile.utils.mr.base import MergeRequestBase
5
+ from reconcile.utils.ruamel import create_ruamel_instance
3
6
 
4
7
 
5
8
  class PromoteQontractSchemas(MergeRequestBase):
@@ -39,3 +42,126 @@ class PromoteQontractSchemas(MergeRequestBase):
39
42
  commit_message=self.description,
40
43
  content=new_content,
41
44
  )
45
+
46
+
47
+ class PromoteQontractReconcileCommercial(MergeRequestBase):
48
+ name = "promote_qontract_reconcile"
49
+
50
+ def __init__(self, version: str, commit_sha: str):
51
+ self.version = version
52
+ self.commit_sha = commit_sha
53
+
54
+ super().__init__()
55
+
56
+ self.labels = []
57
+
58
+ @property
59
+ def title(self) -> str:
60
+ return f"[{self.name}] promote qontract-reconcile to version {self.version}"
61
+
62
+ @property
63
+ def description(self) -> str:
64
+ return f"promote qontract-reconcile to version {self.version}"
65
+
66
+ def process(self, gitlab_cli: GitLabApi) -> None:
67
+ yml = create_ruamel_instance()
68
+
69
+ # .env
70
+ path = ".env"
71
+ raw_file = gitlab_cli.project.files.get(
72
+ file_path=path, ref=gitlab_cli.main_branch
73
+ ).decode()
74
+ content = raw_file.decode("utf-8")
75
+ lines = content.splitlines()
76
+ for index, text in enumerate(lines):
77
+ if text.startswith("export RECONCILE_IMAGE_TAG="):
78
+ lines[index] = f"export RECONCILE_IMAGE_TAG={self.version}"
79
+ new_content = "\n".join(lines) + "\n"
80
+ gitlab_cli.update_file(
81
+ branch_name=self.branch,
82
+ file_path=path,
83
+ commit_message=self.description,
84
+ content=new_content,
85
+ )
86
+
87
+ # resources/jenkins/global/defaults.yaml
88
+ path = "resources/jenkins/global/defaults.yaml"
89
+ raw_file = gitlab_cli.project.files.get(
90
+ file_path=path, ref=gitlab_cli.main_branch
91
+ ).decode()
92
+ content = raw_file.decode("utf-8")
93
+ lines = content.splitlines()
94
+ for index, text in enumerate(lines):
95
+ if text.startswith(" qontract_reconcile_image_tag: "):
96
+ lines[index] = f" qontract_reconcile_image_tag: '{self.version}'"
97
+ new_content = "\n".join(lines) + "\n"
98
+ gitlab_cli.update_file(
99
+ branch_name=self.branch,
100
+ file_path=path,
101
+ commit_message=self.description,
102
+ content=new_content,
103
+ )
104
+
105
+ # data/services/app-interface/cicd/ci-ext/saas-qontract-dashboards.yaml
106
+ path = "data/services/app-interface/cicd/ci-ext/saas-qontract-dashboards.yaml"
107
+ raw_file = gitlab_cli.project.files.get(
108
+ file_path=path, ref=gitlab_cli.main_branch
109
+ ).decode()
110
+ content = yml.load(raw_file)
111
+ for rt in content["resourceTemplates"]:
112
+ if rt["url"] == "https://github.com/app-sre/qontract-reconcile":
113
+ for t in rt["targets"]:
114
+ if t["name"] == "app-sre-observability-production":
115
+ t["ref"] = self.commit_sha
116
+ new_content = "---\n"
117
+ with StringIO() as stream:
118
+ yml.dump(content, stream)
119
+ new_content += stream.getvalue() or ""
120
+ gitlab_cli.update_file(
121
+ branch_name=self.branch,
122
+ file_path=path,
123
+ commit_message=self.description,
124
+ content=new_content,
125
+ )
126
+
127
+ # data/services/app-interface/cicd/ci-int/saas-qontract-manager-int.yaml
128
+ path = "data/services/app-interface/cicd/ci-int/saas-qontract-manager-int.yaml"
129
+ raw_file = gitlab_cli.project.files.get(
130
+ file_path=path, ref=gitlab_cli.main_branch
131
+ ).decode()
132
+ content = yml.load(raw_file)
133
+ for rt in content["resourceTemplates"]:
134
+ if rt["url"] == "https://github.com/app-sre/qontract-reconcile":
135
+ for t in rt["targets"]:
136
+ if t["name"] == "app-interface-production":
137
+ t["ref"] = self.commit_sha
138
+ new_content = "---\n"
139
+ with StringIO() as stream:
140
+ yml.dump(content, stream)
141
+ new_content += stream.getvalue() or ""
142
+ gitlab_cli.update_file(
143
+ branch_name=self.branch,
144
+ file_path=path,
145
+ commit_message=self.description,
146
+ content=new_content,
147
+ )
148
+
149
+ # data/pipelines/tekton-provider-global-defaults.yaml
150
+ path = "data/pipelines/tekton-provider-global-defaults.yaml"
151
+ raw_file = gitlab_cli.project.files.get(
152
+ file_path=path, ref=gitlab_cli.main_branch
153
+ ).decode()
154
+ content = yml.load(raw_file)
155
+ for tt in content["taskTemplates"]:
156
+ if tt["name"] == "openshift-saas-deploy":
157
+ tt["variables"]["qontract_reconcile_image_tag"] = self.version
158
+ new_content = "---\n"
159
+ with StringIO() as stream:
160
+ yml.dump(content, stream)
161
+ new_content += stream.getvalue() or ""
162
+ gitlab_cli.update_file(
163
+ branch_name=self.branch,
164
+ file_path=path,
165
+ commit_message=self.description,
166
+ content=new_content,
167
+ )
tools/qontract_cli.py CHANGED
@@ -56,14 +56,22 @@ from reconcile.cli import (
56
56
  config_file,
57
57
  use_jump_host,
58
58
  )
59
+ from reconcile.external_resources.integration import (
60
+ get_aws_api,
61
+ )
59
62
  from reconcile.external_resources.manager import (
60
63
  FLAG_RESOURCE_MANAGED_BY_ERV2,
61
64
  setup_factories,
62
65
  )
63
66
  from reconcile.external_resources.model import (
67
+ ExternalResourceKey,
64
68
  ExternalResourcesInventory,
65
69
  load_module_inventory,
66
70
  )
71
+ from reconcile.external_resources.state import (
72
+ ExternalResourcesStateDynamoDB,
73
+ ResourceStatus,
74
+ )
67
75
  from reconcile.gql_definitions.advanced_upgrade_service.aus_clusters import (
68
76
  query as aus_clusters_query,
69
77
  )
@@ -3942,5 +3950,47 @@ def get_input(
3942
3950
  print(resource.json(exclude={"data": {FLAG_RESOURCE_MANAGED_BY_ERV2}}))
3943
3951
 
3944
3952
 
3953
+ @external_resources.command()
3954
+ @click.argument("provision-provider", required=True)
3955
+ @click.argument("provisioner", required=True)
3956
+ @click.argument("provider", required=True)
3957
+ @click.argument("identifier", required=True)
3958
+ @click.pass_context
3959
+ def request_reconciliation(
3960
+ ctx, provision_provider: str, provisioner: str, provider: str, identifier: str
3961
+ ):
3962
+ """Marks a resource as it needs to get reconciled. The itegration will reconcile the resource at
3963
+ its next iteration.
3964
+
3965
+ e.g: e.g: qontract-reconcile --config=<config> external-resources request-reconciliation aws app-sre-stage rds dashdotdb-stage
3966
+ """
3967
+ er_settings = get_settings()[0]
3968
+ vault_settings = get_app_interface_vault_settings()
3969
+ secret_reader = create_secret_reader(use_vault=vault_settings.vault)
3970
+ with get_aws_api(
3971
+ query_func=gql.get_api().query,
3972
+ account_name=er_settings.state_dynamodb_account.name,
3973
+ region=er_settings.state_dynamodb_region,
3974
+ secret_reader=secret_reader,
3975
+ ) as aws_api:
3976
+ state_manager = ExternalResourcesStateDynamoDB(
3977
+ aws_api=aws_api,
3978
+ table_name=er_settings.state_dynamodb_table,
3979
+ )
3980
+ key = ExternalResourceKey(
3981
+ provision_provider=provision_provider,
3982
+ provisioner_name=provisioner,
3983
+ provider=provider,
3984
+ identifier=identifier,
3985
+ )
3986
+ current_state = state_manager.get_external_resource_state(key)
3987
+ if current_state.resource_status != ResourceStatus.NOT_EXISTS:
3988
+ state_manager.update_resource_status(
3989
+ key, ResourceStatus.RECONCILIATION_REQUESTED
3990
+ )
3991
+ else:
3992
+ logging.info("External Resource does not exist")
3993
+
3994
+
3945
3995
  if __name__ == "__main__":
3946
3996
  root() # pylint: disable=no-value-for-parameter