You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "MaksYermak (via GitHub)" <gi...@apache.org> on 2025/01/20 09:36:56 UTC

[PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

MaksYermak opened a new pull request, #45795:
URL: https://github.com/apache/airflow/pull/45795

   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   In this PR I have created operators for working with Clusters for GCP Managed Service for Apache Kafka
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

Posted by "VladaZakharova (via GitHub)" <gi...@apache.org>.
VladaZakharova commented on PR #45795:
URL: https://github.com/apache/airflow/pull/45795#issuecomment-2604240371

   hi @potiuk ! Can you please check changes from this PR? :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #45795:
URL: https://github.com/apache/airflow/pull/45795


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on PR #45795:
URL: https://github.com/apache/airflow/pull/45795#issuecomment-2633528602

   > Hi @eladkal ! Can you please check changes here? Thanks :)
   
   sorry won't get to it in the next 1-2 weeks. Maybe someone else can review


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

Posted by "MaksYermak (via GitHub)" <gi...@apache.org>.
MaksYermak commented on PR #45795:
URL: https://github.com/apache/airflow/pull/45795#issuecomment-2616095447

   @eladkal I have updated the naming for hook and operators. Could you please check PR one more time?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

Posted by "VladaZakharova (via GitHub)" <gi...@apache.org>.
VladaZakharova commented on PR #45795:
URL: https://github.com/apache/airflow/pull/45795#issuecomment-2633531567

   > > Hi @eladkal ! Can you please check changes here? Thanks :)
   > 
   > sorry won't get to it in the next 1-2 weeks. Maybe someone else can review
   
   Oh, i see, thanks for reply! 
   
   @potiuk Can you please check then? :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

Posted by "MaksYermak (via GitHub)" <gi...@apache.org>.
MaksYermak commented on PR #45795:
URL: https://github.com/apache/airflow/pull/45795#issuecomment-2693632641

   > @MaksYermak do you have any idea what's going on with the kafka messages here?
   > 
   > https://github.com/apache/airflow/actions/runs/13555901653/job/37890520619?pr=46503#step:6:5930
   
   Hello @dstandish,
   All that I can say is that something happened with kafka cluster, which can be accessible by this url localhost:9092/bootstrap, maybe this cluster does not exist, because this `url` for me looks like default one. Or maybe `consumer` and `producer` functions do not have enough permissions to connect to the cluster. But it's hard for me to say what exactly happened.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

Posted by "VladaZakharova (via GitHub)" <gi...@apache.org>.
VladaZakharova commented on PR #45795:
URL: https://github.com/apache/airflow/pull/45795#issuecomment-2633501316

   Hi @eladkal ! Can you please check changes here? Thanks :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #45795:
URL: https://github.com/apache/airflow/pull/45795#discussion_r1929724913


##########
providers/src/airflow/providers/google/cloud/hooks/apache_kafka.py:
##########
@@ -0,0 +1,289 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""This module contains a Managed Service for Apache Kafka hook."""
+
+from __future__ import annotations
+
+from collections.abc import Sequence
+from copy import deepcopy
+from typing import TYPE_CHECKING
+
+from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault

Review Comment:
   I don't think we should import private functions from upstream libraries.



##########
providers/src/airflow/providers/google/cloud/hooks/apache_kafka.py:
##########
@@ -0,0 +1,289 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""This module contains a Managed Service for Apache Kafka hook."""
+
+from __future__ import annotations
+
+from collections.abc import Sequence
+from copy import deepcopy
+from typing import TYPE_CHECKING
+
+from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
+from google.cloud.managedkafka_v1 import Cluster, ManagedKafkaClient, types
+
+from airflow.exceptions import AirflowException
+from airflow.providers.google.common.consts import CLIENT_INFO
+from airflow.providers.google.common.hooks.base_google import GoogleBaseHook
+
+if TYPE_CHECKING:
+    from google.api_core.operation import Operation
+    from google.api_core.retry import Retry
+    from google.cloud.managedkafka_v1.services.managed_kafka.pagers import ListClustersPager
+    from google.protobuf.field_mask_pb2 import FieldMask
+
+
+class ApacheKafkaHook(GoogleBaseHook):

Review Comment:
   I have some concerns about the naming. This can be very very confusing with the apache kafka integration in the apache provider.
   Is this the actual name Google use to lunch the service?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

Posted by "MaksYermak (via GitHub)" <gi...@apache.org>.
MaksYermak commented on code in PR #45795:
URL: https://github.com/apache/airflow/pull/45795#discussion_r1930341687


##########
providers/src/airflow/providers/google/cloud/hooks/apache_kafka.py:
##########
@@ -0,0 +1,289 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""This module contains a Managed Service for Apache Kafka hook."""
+
+from __future__ import annotations
+
+from collections.abc import Sequence
+from copy import deepcopy
+from typing import TYPE_CHECKING
+
+from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
+from google.cloud.managedkafka_v1 import Cluster, ManagedKafkaClient, types
+
+from airflow.exceptions import AirflowException
+from airflow.providers.google.common.consts import CLIENT_INFO
+from airflow.providers.google.common.hooks.base_google import GoogleBaseHook
+
+if TYPE_CHECKING:
+    from google.api_core.operation import Operation
+    from google.api_core.retry import Retry
+    from google.cloud.managedkafka_v1.services.managed_kafka.pagers import ListClustersPager
+    from google.protobuf.field_mask_pb2 import FieldMask
+
+
+class ApacheKafkaHook(GoogleBaseHook):

Review Comment:
   @eladkal no, for client library the use name `managed_kafka` and the service in the GCP has name [Google Cloud Managed Service for Apache Kafka](https://cloud.google.com/products/managed-service-for-apache-kafka). I will change names for hook and operators from `ApacheKafka*` to `ManagedKafka*`. What do you think about this naming?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

Posted by "MaksYermak (via GitHub)" <gi...@apache.org>.
MaksYermak commented on code in PR #45795:
URL: https://github.com/apache/airflow/pull/45795#discussion_r1930333212


##########
providers/src/airflow/providers/google/cloud/hooks/apache_kafka.py:
##########
@@ -0,0 +1,289 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""This module contains a Managed Service for Apache Kafka hook."""
+
+from __future__ import annotations
+
+from collections.abc import Sequence
+from copy import deepcopy
+from typing import TYPE_CHECKING
+
+from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault

Review Comment:
   @eladkal it's not a function it's a type class for `DEFAULT` value.  We do it for type checking for `retry` parameter and we use this `import` for each google's hook and operator. It's needed for the `DEFAULT` value which we also import by this line. The `DEFAULT` has type `_MethodDefault`. And we use this class `_MethodDefault` only for type checking.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

Posted by "MaksYermak (via GitHub)" <gi...@apache.org>.
MaksYermak commented on PR #45795:
URL: https://github.com/apache/airflow/pull/45795#issuecomment-2653415302

   @eladkal @potiuk could you please check this PR again?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Create operators for working with Clusters for GCP Apache Kafka [airflow]

Posted by "dstandish (via GitHub)" <gi...@apache.org>.
dstandish commented on PR #45795:
URL: https://github.com/apache/airflow/pull/45795#issuecomment-2688511785

   @MaksYermak do you have any idea what's going on with the kafka messages here?
   
   https://github.com/apache/airflow/actions/runs/13555901653/job/37890520619?pr=46503#step:6:5930
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org