qontract-reconcile 0.10.1rc517__py3-none-any.whl → 0.10.1rc519__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.1rc517
3
+ Version: 0.10.1rc519
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
@@ -61,7 +61,7 @@ reconcile/ocm_machine_pools.py,sha256=eebJ6iiTdUcuKE5zBcfNxW1OGmPOvgBtmVu3xNVOoy
61
61
  reconcile/ocm_update_recommended_version.py,sha256=IYkfLXIprOW1jguZeELcGP1iBPuj-b53R-FTqKulMl8,4204
62
62
  reconcile/ocm_upgrade_scheduler_org_updater.py,sha256=ta8hMJ-su5mRcPpYrvB1COsojXV-SU3PzLPbQhy2Q0I,4190
63
63
  reconcile/openshift_base.py,sha256=7aifvl-ay5wpY6encbUX9pGbKdjiwJmevZ3XWGRzpCM,49696
64
- reconcile/openshift_cluster_bots.py,sha256=6L4eQuT76AmZGr-tN8hymqqCyCBgOj07nod-35PJtHw,10165
64
+ reconcile/openshift_cluster_bots.py,sha256=8cb-1j9ksIUxhfn_9oD--5YN9OznTCZky83MX8KgffM,10873
65
65
  reconcile/openshift_clusterrolebindings.py,sha256=QfSy1Ik8eEY5XObc1Q4xyhqyErZenJmbPv_u9wcDNNo,5864
66
66
  reconcile/openshift_groups.py,sha256=d-qGI1aUEpZZLZq7PuSnjVDgsy5EB063CQr2tNvYPCE,9419
67
67
  reconcile/openshift_limitranges.py,sha256=UvCGo_OQ4XoDK55TJmn55qEhhlkhLzhU12tX8nT5kPQ,3442
@@ -114,7 +114,7 @@ reconcile/terraform_repo.py,sha256=c0GZFuY3rCm6VHjHqYbsgOHrEkRWKF_1LrMThsn2XDw,1
114
114
  reconcile/terraform_resources.py,sha256=x5Do4xBBhjJdIVRi0Gy4h-ryCCZ6kU7bT_iB0_mGing,17105
115
115
  reconcile/terraform_tgw_attachments.py,sha256=_g7QSHM03YZzTU7O189S4HYtUn7WmwOBq67G4AieU24,15298
116
116
  reconcile/terraform_users.py,sha256=kXRUxCUchKCP2dbXXOzctynqMii4oyCP6bYZHQTrlTg,10202
117
- reconcile/terraform_vpc_peerings.py,sha256=UoxjkOw_w5esHP2IeIsphxYPuhdvbDAfY97ubfnEH0g,25029
117
+ reconcile/terraform_vpc_peerings.py,sha256=rnDH1u93OyzrBM8Hib0HwSnlxZtx4ScRQaZAcn3mx-k,25402
118
118
  reconcile/vault_replication.py,sha256=b23ZfsQwS470GMvPPv1E6TU8MLBg3HX31_9IvMzE1tk,17280
119
119
  reconcile/vpc_peerings_validator.py,sha256=Kv22HJVlTW9l9GB2eXwjPWqdDbr_VuvQBNPttox6s5o,7177
120
120
  reconcile/aus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -411,7 +411,7 @@ reconcile/test/test_ocm_machine_pools.py,sha256=3qo6t2Jfr1Wee0NUacyLTDmatp0o7CUN
411
411
  reconcile/test/test_ocm_update_recommended_version.py,sha256=iA4BVirTGVXlwcOyeR52IuNO81X_8NR6ZNd7ZFE7igs,4328
412
412
  reconcile/test/test_ocm_upgrade_scheduler_org_updater.py,sha256=zYRGUX7pAmxSv9oFYw2ZnPGa-YAPgDfmqXOJM4eE-8A,4353
413
413
  reconcile/test/test_openshift_base.py,sha256=uVsnMghAQhHaJTreeOw4x2INTKJ6qeiZiiteWeKflW8,33874
414
- reconcile/test/test_openshift_cluster_bots.py,sha256=GzwG73V-psL3qZ2R1ekiSWr9L6935eLduw7tls5KaUI,7928
414
+ reconcile/test/test_openshift_cluster_bots.py,sha256=-h1wDki9wh_WsNvNdPGuf-EjXP1MKWGRIIF9GcSuGjw,7928
415
415
  reconcile/test/test_openshift_namespace_labels.py,sha256=P1hqi6P88NijNrurdXG_QR2usyo3EYZSy9zpwYHvDsM,12104
416
416
  reconcile/test/test_openshift_namespaces.py,sha256=HmRnCE5EnFt3MYceVEFHmk8wWRtCrxu2AFGFkY9pdyA,9214
417
417
  reconcile/test/test_openshift_resource.py,sha256=lbTf48jX1q6rGnRiA5pPvfU0uPfY8zhNylMtryn0sLI,12995
@@ -444,7 +444,7 @@ reconcile/test/test_terraform_resources.py,sha256=1ny_QSFuRjV9jxZY8EeT4NVJ5dMv7c
444
444
  reconcile/test/test_terraform_tgw_attachments.py,sha256=cAq6exc-K-jtLla1CZUZQzVnBkyDnIlL7jybnddhLKc,36861
445
445
  reconcile/test/test_terraform_users.py,sha256=Xn4y6EcxnNQb6XcPoOhz_Ikxmh9Nrsu88OM1scN9hzY,5434
446
446
  reconcile/test/test_terraform_vpc_peerings.py,sha256=ubcsKh0TrUIwuI1-W3ETIgzsFvzAyeoFmEJFC-IK6JY,20538
447
- reconcile/test/test_terraform_vpc_peerings_build_desired_state.py,sha256=Pyw8Jbp8lX5Tsk1yWZ0-4NJmwxqdwK1NnVYk6peLIQc,47440
447
+ reconcile/test/test_terraform_vpc_peerings_build_desired_state.py,sha256=DAfpb12I0PlqnuVUHK2vh4LH4d1OylT3H2GE_3TGZZI,47852
448
448
  reconcile/test/test_three_way_diff_strategy.py,sha256=2fjEqE2w4pIzKq18PRcADTSe01aGwsZfMGloU8xfNaE,3346
449
449
  reconcile/test/test_unleash.py,sha256=c1s_FRAZrAzzd3FbZrzHYjJzHELhoxPHBZnEzqsfMQg,6416
450
450
  reconcile/test/test_vault_replication.py,sha256=wlc4jm9f8P641UvvxIFFFc5_unJysNkOVrKJscjhQr0,16867
@@ -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.1rc517.dist-info/METADATA,sha256=pm8ptXrk2UwiZZY4b3yOIkczJdFRVa5afyr01T7loMw,2349
672
- qontract_reconcile-0.10.1rc517.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
673
- qontract_reconcile-0.10.1rc517.dist-info/entry_points.txt,sha256=rTjAv28I_CHLM8ID3OPqMI_suoQ9s7tFbim4aYjn9kk,376
674
- qontract_reconcile-0.10.1rc517.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
675
- qontract_reconcile-0.10.1rc517.dist-info/RECORD,,
671
+ qontract_reconcile-0.10.1rc519.dist-info/METADATA,sha256=PkWYKrPAojcwXRY7Pu263rk2RvG9DyNwH8Tsqzg_JqA,2349
672
+ qontract_reconcile-0.10.1rc519.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
673
+ qontract_reconcile-0.10.1rc519.dist-info/entry_points.txt,sha256=rTjAv28I_CHLM8ID3OPqMI_suoQ9s7tFbim4aYjn9kk,376
674
+ qontract_reconcile-0.10.1rc519.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
675
+ qontract_reconcile-0.10.1rc519.dist-info/RECORD,,
@@ -124,7 +124,11 @@ def retrieve_token(kubeconfig: str, namespace: str, sa: str) -> str:
124
124
 
125
125
 
126
126
  def create_sa(
127
- kubeconfig: str, namespace: str, sa: str, create_namespace: bool = False
127
+ kubeconfig: str,
128
+ namespace: str,
129
+ sa: str,
130
+ create_namespace: bool = False,
131
+ cluster_admin: bool = False,
128
132
  ) -> str:
129
133
  items: list[dict] = []
130
134
  if create_namespace:
@@ -159,6 +163,26 @@ def create_sa(
159
163
  "type": "kubernetes.io/service-account-token",
160
164
  },
161
165
  ])
166
+ if cluster_admin:
167
+ items.append({
168
+ "apiVersion": "rbac.authorization.k8s.io/v1",
169
+ "kind": "ClusterRoleBinding",
170
+ "metadata": {
171
+ "name": f"{namespace}-{sa}",
172
+ },
173
+ "roleRef": {
174
+ "apiGroup": "rbac.authorization.k8s.io",
175
+ "kind": "ClusterRole",
176
+ "name": "cluster-admin",
177
+ },
178
+ "subjects": [
179
+ {
180
+ "kind": "ServiceAccount",
181
+ "name": sa,
182
+ "namespace": namespace,
183
+ }
184
+ ],
185
+ })
162
186
 
163
187
  oc_apply(kubeconfig, namespace, items)
164
188
  token = retrieve_token(kubeconfig, namespace, sa)
@@ -200,6 +224,7 @@ def create_cluster_bots(
200
224
  config.cluster_admin_ns,
201
225
  config.cluster_admin_sa,
202
226
  create_namespace=True,
227
+ cluster_admin=True,
203
228
  )
204
229
  except subprocess.CalledProcessError as e:
205
230
  logging.error(e.stderr)
@@ -210,9 +210,11 @@ def build_desired_state_single_cluster(
210
210
  )
211
211
  )
212
212
  if requester_vpc_id is None:
213
- raise BadTerraformPeeringState(
214
- f"[{cluster_name}] could not find VPC ID for cluster"
213
+ logging.warning(
214
+ f"[{cluster_name}] could not find VPC ID for cluster. "
215
+ f"Skipping {peer_connection_provider} connection {peer_connection['name']}"
215
216
  )
217
+ continue
216
218
 
217
219
  requester = {
218
220
  "cidr_block": cluster_info["network"]["vpc"],
@@ -234,9 +236,11 @@ def build_desired_state_single_cluster(
234
236
  hcp_vpc_endpoint_sg=_private_hosted_control_plane(peer_cluster),
235
237
  )
236
238
  if accepter_vpc_id is None:
237
- raise BadTerraformPeeringState(
238
- f"[{peer_cluster_name}] could not find VPC ID for cluster"
239
+ logging.warning(
240
+ f"[{peer_cluster_name}] could not find VPC ID for cluster. "
241
+ f"Skipping {peer_info['provider']} connection {peer_info['name']}"
239
242
  )
243
+ continue
240
244
 
241
245
  requester["peer_owner_id"] = acc_aws["uid"]
242
246
  if acc_aws.get("assume_role"):
@@ -340,10 +344,11 @@ def build_desired_state_vpc_mesh_single_cluster(
340
344
  )
341
345
 
342
346
  if requester_vpc_id is None:
343
- raise BadTerraformPeeringState(
344
- f"{cluster} could not find VPC ID for cluster and "
345
- f"peer account {account}"
347
+ logging.warning(
348
+ f"[{cluster}] could not find VPC ID for cluster and peer account {account}. "
349
+ f"Skipping {peer_connection_provider} connection {peer_connection['name']}"
346
350
  )
351
+ continue
347
352
 
348
353
  requester["vpc_id"] = requester_vpc_id
349
354
  requester["route_table_ids"] = requester_route_table_ids
@@ -478,9 +483,11 @@ def build_desired_state_vpc_single_cluster(
478
483
  )
479
484
 
480
485
  if requester_vpc_id is None:
481
- raise BadTerraformPeeringState(
482
- f"[{cluster}] could not find VPC ID for cluster"
486
+ logging.warning(
487
+ f"[{cluster}] could not find VPC ID for cluster. "
488
+ f"Skipping {peer_connection_provider} connection {peer_connection['name']}"
483
489
  )
490
+ continue
484
491
 
485
492
  requester["vpc_id"] = requester_vpc_id
486
493
  requester["route_table_ids"] = requester_route_table_ids
@@ -234,6 +234,6 @@ def test_run_cluster_admin(
234
234
  )
235
235
  mocks.oc.return_value = {"data": {"token": "mytoken"}}
236
236
  ocb.run(**integ_params)
237
- assert mocks.oc.call_count == 7
237
+ assert mocks.oc.call_count == 8
238
238
  mocks.vault.assert_called_once()
239
239
  mocks.submit_mr.assert_called_once()
@@ -466,11 +466,10 @@ def test_c2c_no_vpc_in_aws(mocker):
466
466
 
467
467
  awsapi = MockAWSAPI()
468
468
 
469
- with pytest.raises(sut.BadTerraformPeeringState) as ex:
470
- sut.build_desired_state_single_cluster(
471
- requester_cluster, ocm, awsapi, account_filter=None
472
- )
473
- assert str(ex.value).endswith("could not find VPC ID for cluster")
469
+ desired_state = sut.build_desired_state_single_cluster(
470
+ requester_cluster, ocm, awsapi, account_filter=None
471
+ )
472
+ assert desired_state == []
474
473
 
475
474
 
476
475
  def test_c2c_no_peer_account(mocker):
@@ -936,10 +935,10 @@ class TestBuildDesiredStateVpcMeshSingleCluster(testslide.TestCase):
936
935
  None,
937
936
  )).and_assert_called_once()
938
937
 
939
- with self.assertRaises(sut.BadTerraformPeeringState):
940
- sut.build_desired_state_vpc_mesh_single_cluster(
941
- self.cluster, self.ocm, self.awsapi, None
942
- )
938
+ desired_state = sut.build_desired_state_vpc_mesh_single_cluster(
939
+ self.cluster, self.ocm, self.awsapi, None
940
+ )
941
+ assert desired_state == []
943
942
 
944
943
 
945
944
  class TestBuildDesiredStateVpc(testslide.TestCase):
@@ -1341,7 +1340,22 @@ class TestBuildDesiredStateVpcSingleCluster(testslide.TestCase):
1341
1340
  self.ocm, "get_aws_infrastructure_access_terraform_assume_role"
1342
1341
  ).to_return_value("a:role:that:you:will:like").and_assert_called_once()
1343
1342
 
1344
- with self.assertRaises(sut.BadTerraformPeeringState):
1343
+ desired_state = sut.build_desired_state_vpc_single_cluster(
1344
+ self.cluster, self.ocm, self.awsapi, None
1345
+ )
1346
+ assert desired_state == []
1347
+
1348
+ def test_aws_exception(self):
1349
+ exc_txt = "AWS Problem!"
1350
+ self.mock_callable(self.awsapi, "get_cluster_vpc_details").to_raise(
1351
+ Exception(exc_txt)
1352
+ )
1353
+
1354
+ self.mock_callable(
1355
+ self.ocm, "get_aws_infrastructure_access_terraform_assume_role"
1356
+ ).to_return_value("a:role:that:you:will:like").and_assert_called_once()
1357
+
1358
+ with pytest.raises(Exception, match=exc_txt):
1345
1359
  sut.build_desired_state_vpc_single_cluster(
1346
1360
  self.cluster, self.ocm, self.awsapi, None
1347
1361
  )