qontract-reconcile 0.10.2.dev299__py3-none-any.whl → 0.10.2.dev314__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.
- {qontract_reconcile-0.10.2.dev299.dist-info → qontract_reconcile-0.10.2.dev314.dist-info}/METADATA +1 -1
- {qontract_reconcile-0.10.2.dev299.dist-info → qontract_reconcile-0.10.2.dev314.dist-info}/RECORD +25 -25
- reconcile/gql_definitions/common/aws_vpc_requests.py +4 -1
- reconcile/gql_definitions/fragments/aws_vpc_request.py +3 -0
- reconcile/gql_definitions/introspection.json +36 -12
- reconcile/prometheus_rules_tester/integration.py +1 -1
- reconcile/rhidp/common.py +2 -0
- reconcile/terraform_tgw_attachments.py +1 -1
- reconcile/terraform_users.py +3 -1
- reconcile/terraform_vpc_peerings.py +1 -1
- reconcile/terraform_vpc_resources/integration.py +19 -1
- reconcile/utils/ocm/base.py +10 -0
- reconcile/utils/openssl.py +2 -2
- reconcile/utils/repo_owners.py +21 -29
- reconcile/utils/runtime/meta.py +2 -1
- reconcile/utils/sharding.py +1 -1
- reconcile/utils/sqs_gateway.py +14 -10
- reconcile/utils/structs.py +3 -3
- reconcile/utils/terraform_client.py +27 -25
- reconcile/utils/terrascript_aws_client.py +487 -372
- reconcile/utils/throughput.py +1 -1
- reconcile/vpc_peerings_validator.py +2 -2
- tools/sre_checkpoints/util.py +5 -3
- {qontract_reconcile-0.10.2.dev299.dist-info → qontract_reconcile-0.10.2.dev314.dist-info}/WHEEL +0 -0
- {qontract_reconcile-0.10.2.dev299.dist-info → qontract_reconcile-0.10.2.dev314.dist-info}/entry_points.txt +0 -0
@@ -5,8 +5,8 @@ import shutil
|
|
5
5
|
import tempfile
|
6
6
|
from collections import defaultdict
|
7
7
|
from collections.abc import (
|
8
|
-
Generator,
|
9
8
|
Iterable,
|
9
|
+
Iterator,
|
10
10
|
Mapping,
|
11
11
|
)
|
12
12
|
from contextlib import contextmanager
|
@@ -86,8 +86,8 @@ class TerraformClient:
|
|
86
86
|
working_dirs: Mapping[str, str],
|
87
87
|
thread_pool_size: int,
|
88
88
|
aws_api: AWSApi | None = None,
|
89
|
-
init_users=False,
|
90
|
-
):
|
89
|
+
init_users: bool = False,
|
90
|
+
) -> None:
|
91
91
|
self.integration = integration
|
92
92
|
self.integration_version = integration_version
|
93
93
|
self.integration_prefix = integration_prefix
|
@@ -101,7 +101,7 @@ class TerraformClient:
|
|
101
101
|
|
102
102
|
self.specs: list[TerraformSpec] = []
|
103
103
|
self.init_specs()
|
104
|
-
self.outputs: dict = {}
|
104
|
+
self.outputs: dict[str, Any] = {}
|
105
105
|
self.init_outputs()
|
106
106
|
|
107
107
|
self.OUTPUT_TYPE_SECRETS = "Secrets"
|
@@ -112,19 +112,19 @@ class TerraformClient:
|
|
112
112
|
if init_users:
|
113
113
|
self.init_existing_users()
|
114
114
|
|
115
|
-
def init_existing_users(self):
|
115
|
+
def init_existing_users(self) -> None:
|
116
116
|
self.users = {
|
117
117
|
account: list(self.format_output(output, self.OUTPUT_TYPE_PASSWORDS).keys())
|
118
118
|
for account, output in self.outputs.items()
|
119
119
|
}
|
120
120
|
|
121
|
-
def increment_apply_count(self):
|
121
|
+
def increment_apply_count(self) -> None:
|
122
122
|
self.apply_count += 1
|
123
123
|
|
124
124
|
def should_apply(self) -> bool:
|
125
125
|
return self.apply_count > 0
|
126
126
|
|
127
|
-
def get_new_users(self):
|
127
|
+
def get_new_users(self) -> list[tuple[str, Any, str, Any]]:
|
128
128
|
new_users = []
|
129
129
|
self.init_outputs() # get updated output
|
130
130
|
for account, output in self.outputs.items():
|
@@ -141,7 +141,7 @@ class TerraformClient:
|
|
141
141
|
))
|
142
142
|
return new_users
|
143
143
|
|
144
|
-
def init_specs(self):
|
144
|
+
def init_specs(self) -> None:
|
145
145
|
self.specs = [
|
146
146
|
TerraformSpec(name=name, working_dir=wd)
|
147
147
|
for name, wd in self.working_dirs.items()
|
@@ -152,7 +152,7 @@ class TerraformClient:
|
|
152
152
|
@contextmanager
|
153
153
|
def _terraform_log_file(
|
154
154
|
self, working_dir: str
|
155
|
-
) ->
|
155
|
+
) -> Iterator[tuple[IO[bytes], dict[str, str]]]:
|
156
156
|
with tempfile.NamedTemporaryFile(dir=working_dir) as f:
|
157
157
|
env = {
|
158
158
|
"TF_LOG": TERRAFORM_LOG_LEVEL,
|
@@ -161,7 +161,7 @@ class TerraformClient:
|
|
161
161
|
yield f, env
|
162
162
|
|
163
163
|
@retry(exceptions=TerraformCommandError)
|
164
|
-
def terraform_init(self, spec: TerraformSpec):
|
164
|
+
def terraform_init(self, spec: TerraformSpec) -> None:
|
165
165
|
with self._terraform_log_file(spec.working_dir) as (f, env):
|
166
166
|
return_code, stdout, stderr = lean_tf.init(spec.working_dir, env=env)
|
167
167
|
log = f.read().decode("utf-8")
|
@@ -171,12 +171,12 @@ class TerraformClient:
|
|
171
171
|
return_code, "init", output=stdout, stderr=stderr
|
172
172
|
)
|
173
173
|
|
174
|
-
def init_outputs(self):
|
174
|
+
def init_outputs(self) -> None:
|
175
175
|
results = threaded.run(self.terraform_output, self.specs, self.thread_pool_size)
|
176
176
|
self.outputs = dict(results)
|
177
177
|
|
178
178
|
@retry(exceptions=TerraformCommandError)
|
179
|
-
def terraform_output(self, spec: TerraformSpec):
|
179
|
+
def terraform_output(self, spec: TerraformSpec) -> tuple[str, Any]:
|
180
180
|
with self._terraform_log_file(spec.working_dir) as (f, env):
|
181
181
|
return_code, stdout, stderr = lean_tf.output(spec.working_dir, env=env)
|
182
182
|
log = f.read().decode("utf-8")
|
@@ -194,17 +194,17 @@ class TerraformClient:
|
|
194
194
|
return spec.name, json.loads(stdout)
|
195
195
|
|
196
196
|
# terraform plan
|
197
|
-
def plan(self, enable_deletion):
|
197
|
+
def plan(self, enable_deletion: bool) -> tuple[bool, bool]:
|
198
198
|
errors = False
|
199
199
|
disabled_deletions_detected = False
|
200
|
-
results = threaded.run(
|
200
|
+
results: list[tuple[bool, list[AccountUser], bool]] = threaded.run(
|
201
201
|
self.terraform_plan,
|
202
202
|
self.specs,
|
203
203
|
self.thread_pool_size,
|
204
204
|
enable_deletion=enable_deletion,
|
205
205
|
)
|
206
206
|
|
207
|
-
self.created_users = []
|
207
|
+
self.created_users: list[AccountUser] = []
|
208
208
|
for disabled_deletion_detected, created_users, error in results:
|
209
209
|
if error:
|
210
210
|
errors = True
|
@@ -278,7 +278,7 @@ class TerraformClient:
|
|
278
278
|
self,
|
279
279
|
spec: TerraformSpec,
|
280
280
|
enable_deletion: bool,
|
281
|
-
) -> tuple[bool, list]:
|
281
|
+
) -> tuple[bool, list[AccountUser]]:
|
282
282
|
disabled_deletion_detected = False
|
283
283
|
name = spec.name
|
284
284
|
account_enable_deletion = self.accounts[name].get("enableDeletion") or False
|
@@ -412,7 +412,9 @@ class TerraformClient:
|
|
412
412
|
)
|
413
413
|
return disabled_deletion_detected, created_users
|
414
414
|
|
415
|
-
def deletion_approved(
|
415
|
+
def deletion_approved(
|
416
|
+
self, account_name: str, resource_type: str, resource_name: str
|
417
|
+
) -> bool:
|
416
418
|
account = self.accounts[account_name]
|
417
419
|
deletion_approvals = account.get("deletionApprovals")
|
418
420
|
if not deletion_approvals:
|
@@ -439,11 +441,11 @@ class TerraformClient:
|
|
439
441
|
return False
|
440
442
|
|
441
443
|
# terraform apply
|
442
|
-
def apply(self):
|
444
|
+
def apply(self) -> bool:
|
443
445
|
errors = threaded.run(self.terraform_apply, self.specs, self.thread_pool_size)
|
444
446
|
return any(errors)
|
445
447
|
|
446
|
-
def terraform_apply(self, spec: TerraformSpec):
|
448
|
+
def terraform_apply(self, spec: TerraformSpec) -> bool:
|
447
449
|
with self._terraform_log_file(spec.working_dir) as (f, env):
|
448
450
|
return_code, stdout, stderr = lean_tf.apply(
|
449
451
|
spec.working_dir,
|
@@ -486,9 +488,9 @@ class TerraformClient:
|
|
486
488
|
|
487
489
|
return replicas_info
|
488
490
|
|
489
|
-
def format_output(self, output, type):
|
491
|
+
def format_output(self, output: Any, type: str) -> dict[str, dict[str, Any]]:
|
490
492
|
# data is a dictionary of dictionaries
|
491
|
-
data = {}
|
493
|
+
data: dict[str, dict[str, Any]] = {}
|
492
494
|
if output is None:
|
493
495
|
return data
|
494
496
|
|
@@ -643,7 +645,7 @@ class TerraformClient:
|
|
643
645
|
return error_occured
|
644
646
|
|
645
647
|
@staticmethod
|
646
|
-
def split_to_lines(*outputs):
|
648
|
+
def split_to_lines(*outputs: str) -> Any:
|
647
649
|
split_outputs = []
|
648
650
|
try:
|
649
651
|
for output in outputs:
|
@@ -656,7 +658,7 @@ class TerraformClient:
|
|
656
658
|
return split_outputs[0]
|
657
659
|
return split_outputs
|
658
660
|
|
659
|
-
def cleanup(self):
|
661
|
+
def cleanup(self) -> None:
|
660
662
|
if self._aws_api is not None:
|
661
663
|
self._aws_api.cleanup()
|
662
664
|
for wd in self.working_dirs.values():
|
@@ -757,7 +759,7 @@ class TerraformClient:
|
|
757
759
|
|
758
760
|
def validate_db_upgrade(
|
759
761
|
self, account_name: str, resource_name: str, resource_change: Mapping[str, Any]
|
760
|
-
):
|
762
|
+
) -> None:
|
761
763
|
"""
|
762
764
|
Determine whether the RDS engine version upgrade is valid.
|
763
765
|
|
@@ -862,7 +864,7 @@ class TerraformClient:
|
|
862
864
|
],
|
863
865
|
}
|
864
866
|
|
865
|
-
def is_supported(engine, version):
|
867
|
+
def is_supported(engine: str, version: str) -> bool:
|
866
868
|
parsed_version = pkg_version.parse(version)
|
867
869
|
if engine == "mysql":
|
868
870
|
return any(
|