diff --git a/CHANGELOG.md b/CHANGELOG.md index 590a88d2..4e359255 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://pypi.org/project/google-cloud-container/#history +### [2.10.7](https://github.com/googleapis/python-container/compare/v2.10.6...v2.10.7) (2022-03-22) + + +### Bug Fixes + +* test cleanup stages with try finally ([#212](https://github.com/googleapis/python-container/issues/212)) ([529bcbf](https://github.com/googleapis/python-container/commit/529bcbf618858aab17b6f5e86d25069a1266860a)) + ### [2.10.6](https://github.com/googleapis/python-container/compare/v2.10.5...v2.10.6) (2022-03-07) diff --git a/samples/snippets/create_cluster_test.py b/samples/snippets/create_cluster_test.py index a06ab2c5..728c0750 100644 --- a/samples/snippets/create_cluster_test.py +++ b/samples/snippets/create_cluster_test.py @@ -37,21 +37,23 @@ def setup_and_tear_down() -> None: # run the tests here yield - # delete the cluster - client = gke.ClusterManagerClient() - cluster_location = client.common_location_path(PROJECT_ID, ZONE) - cluster_name = f"{cluster_location}/clusters/{CLUSTER_NAME}" - op = client.delete_cluster({"name": cluster_name}) - op_id = f"{cluster_location}/operations/{op.name}" - - # schedule a retry to ensure the cluster is deleted - @backoff.on_predicate( - backoff.expo, lambda x: x != gke.Operation.Status.DONE, max_tries=20 - ) - def wait_for_delete() -> gke.Operation.Status: - return client.get_operation({"name": op_id}).status - - wait_for_delete() + try: + # delete the cluster + client = gke.ClusterManagerClient() + cluster_location = client.common_location_path(PROJECT_ID, ZONE) + cluster_name = f"{cluster_location}/clusters/{CLUSTER_NAME}" + op = client.delete_cluster({"name": cluster_name}) + op_id = f"{cluster_location}/operations/{op.name}" + + finally: + # schedule a retry to ensure the cluster is deleted + @backoff.on_predicate( + backoff.expo, lambda x: x != gke.Operation.Status.DONE, max_tries=20 + ) + def wait_for_delete() -> gke.Operation.Status: + return client.get_operation({"name": op_id}).status + + wait_for_delete() def test_create_clusters(capsys: object) -> None: diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 66866c5a..cba90b27 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,3 +1,3 @@ -google-cloud-container==2.10.5 +google-cloud-container==2.10.6 backoff==1.11.1 -pytest==7.0.1 \ No newline at end of file +pytest==7.1.1 \ No newline at end of file diff --git a/setup.py b/setup.py index f04272b5..045f45aa 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ name = "google-cloud-container" description = "Google Container Engine API client library" -version = "2.10.6" +version = "2.10.7" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta'