You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2022/04/26 14:17:39 UTC

[airflow] branch main updated: `BigtableCreateInstanceOperator` & `BigtableHook.create_instance` Remove `replica_cluster_id`, `replica_cluster_zone`. (#23251)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 434ab5a03c `BigtableCreateInstanceOperator` & `BigtableHook.create_instance` Remove `replica_cluster_id`, `replica_cluster_zone`. (#23251)
434ab5a03c is described below

commit 434ab5a03ce2f34570bb4d9b7fb1e22c8e6762e2
Author: eladkal <45...@users.noreply.github.com>
AuthorDate: Tue Apr 26 17:17:30 2022 +0300

    `BigtableCreateInstanceOperator` & `BigtableHook.create_instance` Remove `replica_cluster_id`, `replica_cluster_zone`. (#23251)
---
 airflow/providers/google/CHANGELOG.rst                 |  4 ++++
 airflow/providers/google/cloud/hooks/bigtable.py       | 18 ------------------
 airflow/providers/google/cloud/operators/bigtable.py   |  9 ---------
 tests/providers/google/cloud/hooks/test_bigtable.py    |  6 ++----
 .../providers/google/cloud/operators/test_bigtable.py  |  6 ------
 5 files changed, 6 insertions(+), 37 deletions(-)

diff --git a/airflow/providers/google/CHANGELOG.rst b/airflow/providers/google/CHANGELOG.rst
index 4bc816d9e4..a5d39106f5 100644
--- a/airflow/providers/google/CHANGELOG.rst
+++ b/airflow/providers/google/CHANGELOG.rst
@@ -34,6 +34,10 @@ Breaking changes
    For more information, see `Deprecation and sunset <https://developers.google.com/google-ads/api/docs/sunset-dates>`_
    and `Upgrading to the newest version <https://developers.google.com/google-ads/api/docs/version-migration>`_
 
+* ``BigtableCreateInstanceOperator`` Remove ``replica_cluster_id``, ``replica_cluster_zone``. Please use ``replica_clusters``.
+
+* ``BigtableHook.create_instance``: Remove ``replica_cluster_id``, ``replica_cluster_zone``. Please use ``replica_clusters``.
+
 * ``GoogleDisplayVideo360CreateReportOperator``: remove ``params``. Please use ``parameters``
 
 * ``FacebookAdsReportToGcsOperator``: remove ``params``. Please use ``parameters``
diff --git a/airflow/providers/google/cloud/hooks/bigtable.py b/airflow/providers/google/cloud/hooks/bigtable.py
index 1feccd37f3..e43e03f6fc 100644
--- a/airflow/providers/google/cloud/hooks/bigtable.py
+++ b/airflow/providers/google/cloud/hooks/bigtable.py
@@ -17,7 +17,6 @@
 # under the License.
 """This module contains a Google Cloud Bigtable Hook."""
 import enum
-import warnings
 from typing import Dict, List, Optional, Sequence, Union
 
 from google.cloud.bigtable import Client
@@ -106,8 +105,6 @@ class BigtableHook(GoogleBaseHook):
         main_cluster_zone: str,
         project_id: str,
         replica_clusters: Optional[List[Dict[str, str]]] = None,
-        replica_cluster_id: Optional[str] = None,
-        replica_cluster_zone: Optional[str] = None,
         instance_display_name: Optional[str] = None,
         instance_type: enums.Instance.Type = enums.Instance.Type.TYPE_UNSPECIFIED,
         instance_labels: Optional[Dict] = None,
@@ -128,9 +125,6 @@ class BigtableHook(GoogleBaseHook):
         :param replica_clusters: (optional) A list of replica clusters for the new
             instance. Each cluster dictionary contains an id and a zone.
             Example: [{"id": "replica-1", "zone": "us-west1-a"}]
-        :param replica_cluster_id: (deprecated) The ID for replica cluster for the new
-            instance.
-        :param replica_cluster_zone: (deprecated)  The zone for replica cluster.
         :param instance_type: (optional) The type of the instance.
         :param instance_display_name: (optional) Human-readable name of the instance.
                 Defaults to ``instance_id``.
@@ -160,18 +154,6 @@ class BigtableHook(GoogleBaseHook):
         if instance_type != enums.Instance.Type.DEVELOPMENT and cluster_nodes:
             cluster_kwargs["serve_nodes"] = cluster_nodes
         clusters = [instance.cluster(**cluster_kwargs)]
-        if replica_cluster_id and replica_cluster_zone:
-            warnings.warn(
-                "The replica_cluster_id and replica_cluster_zone parameter have been deprecated."
-                "You should pass the replica_clusters parameter.",
-                DeprecationWarning,
-                stacklevel=2,
-            )
-            clusters.append(
-                instance.cluster(
-                    replica_cluster_id, replica_cluster_zone, cluster_nodes, cluster_storage_type
-                )
-            )
         if replica_clusters:
             for replica_cluster in replica_clusters:
                 if "id" in replica_cluster and "zone" in replica_cluster:
diff --git a/airflow/providers/google/cloud/operators/bigtable.py b/airflow/providers/google/cloud/operators/bigtable.py
index 7520a655ca..c763db375f 100644
--- a/airflow/providers/google/cloud/operators/bigtable.py
+++ b/airflow/providers/google/cloud/operators/bigtable.py
@@ -65,9 +65,6 @@ class BigtableCreateInstanceOperator(BaseOperator, BigtableValidationMixin):
     :param replica_clusters: (optional) A list of replica clusters for the new
         instance. Each cluster dictionary contains an id and a zone.
         Example: [{"id": "replica-1", "zone": "us-west1-a"}]
-    :param replica_cluster_id: (deprecated) The ID for replica cluster for the new
-        instance.
-    :param replica_cluster_zone: (deprecated)  The zone for replica cluster.
     :param instance_type: (optional) The type of the instance.
     :param instance_display_name: (optional) Human-readable name of the instance. Defaults
         to ``instance_id``.
@@ -105,8 +102,6 @@ class BigtableCreateInstanceOperator(BaseOperator, BigtableValidationMixin):
         main_cluster_zone: str,
         project_id: Optional[str] = None,
         replica_clusters: Optional[List[Dict[str, str]]] = None,
-        replica_cluster_id: Optional[str] = None,
-        replica_cluster_zone: Optional[str] = None,
         instance_display_name: Optional[str] = None,
         instance_type: Optional[enums.Instance.Type] = None,
         instance_labels: Optional[Dict] = None,
@@ -122,8 +117,6 @@ class BigtableCreateInstanceOperator(BaseOperator, BigtableValidationMixin):
         self.main_cluster_id = main_cluster_id
         self.main_cluster_zone = main_cluster_zone
         self.replica_clusters = replica_clusters
-        self.replica_cluster_id = replica_cluster_id
-        self.replica_cluster_zone = replica_cluster_zone
         self.instance_display_name = instance_display_name
         self.instance_type = instance_type
         self.instance_labels = instance_labels
@@ -156,8 +149,6 @@ class BigtableCreateInstanceOperator(BaseOperator, BigtableValidationMixin):
                 main_cluster_id=self.main_cluster_id,
                 main_cluster_zone=self.main_cluster_zone,
                 replica_clusters=self.replica_clusters,
-                replica_cluster_id=self.replica_cluster_id,
-                replica_cluster_zone=self.replica_cluster_zone,
                 instance_display_name=self.instance_display_name,
                 instance_type=self.instance_type,
                 instance_labels=self.instance_labels,
diff --git a/tests/providers/google/cloud/hooks/test_bigtable.py b/tests/providers/google/cloud/hooks/test_bigtable.py
index 797e62bdf6..86a54494ee 100644
--- a/tests/providers/google/cloud/hooks/test_bigtable.py
+++ b/tests/providers/google/cloud/hooks/test_bigtable.py
@@ -313,8 +313,7 @@ class TestBigtableHookDefaultProjectId(unittest.TestCase):
             instance_id=CBT_INSTANCE,
             main_cluster_id=CBT_CLUSTER,
             main_cluster_zone=CBT_ZONE,
-            replica_cluster_id=CBT_REPLICA_CLUSTER_ID,
-            replica_cluster_zone=CBT_REPLICA_CLUSTER_ZONE,
+            replica_clusters=[{"id": CBT_REPLICA_CLUSTER_ID, "zone": CBT_REPLICA_CLUSTER_ZONE}],
             cluster_nodes=1,
             cluster_storage_type=enums.StorageType.SSD,
             project_id=GCP_PROJECT_ID_HOOK_UNIT_TEST,
@@ -357,8 +356,7 @@ class TestBigtableHookDefaultProjectId(unittest.TestCase):
             instance_id=CBT_INSTANCE,
             main_cluster_id=CBT_CLUSTER,
             main_cluster_zone=CBT_ZONE,
-            replica_cluster_id=CBT_REPLICA_CLUSTER_ID,
-            replica_cluster_zone=CBT_REPLICA_CLUSTER_ZONE,
+            replica_clusters=[{"id": CBT_REPLICA_CLUSTER_ID, "zone": CBT_REPLICA_CLUSTER_ZONE}],
             cluster_nodes=1,
             cluster_storage_type=enums.StorageType.SSD,
             project_id=GCP_PROJECT_ID_HOOK_UNIT_TEST,
diff --git a/tests/providers/google/cloud/operators/test_bigtable.py b/tests/providers/google/cloud/operators/test_bigtable.py
index 0a3bf31ad5..27293d901e 100644
--- a/tests/providers/google/cloud/operators/test_bigtable.py
+++ b/tests/providers/google/cloud/operators/test_bigtable.py
@@ -163,8 +163,6 @@ class TestBigtableInstanceCreate:
             main_cluster_zone=CLUSTER_ZONE,
             project_id=PROJECT_ID,
             replica_clusters=None,
-            replica_cluster_id=None,
-            replica_cluster_zone=None,
             timeout=None,
         )
 
@@ -196,8 +194,6 @@ class TestBigtableInstanceCreate:
             main_cluster_zone=CLUSTER_ZONE,
             project_id=PROJECT_ID,
             replica_clusters=None,
-            replica_cluster_id=None,
-            replica_cluster_zone=None,
             timeout=None,
         )
 
@@ -230,8 +226,6 @@ class TestBigtableInstanceCreate:
             main_cluster_zone=CLUSTER_ZONE,
             project_id=PROJECT_ID,
             replica_clusters=REPLICATE_CLUSTERS,
-            replica_cluster_id=None,
-            replica_cluster_zone=None,
             timeout=None,
         )