You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ivan-toriya-precis (via GitHub)" <gi...@apache.org> on 2023/07/28 14:08:40 UTC
[GitHub] [airflow] ivan-toriya-precis opened a new issue, #32918: GCSToBigQueryOperator dataset access scope not working with a service account
ivan-toriya-precis opened a new issue, #32918:
URL: https://github.com/apache/airflow/issues/32918
### Apache Airflow version
Other Airflow 2 version (please specify below)
### What happened
Airflow Version: 2.5.3
In my_connection_X (project_id_X) I have my_service_account_X, which has BigQuery Admin role on dataset_Y scope (in project_id_Y).
```python
gcs_to_bq = GCSToBigQueryOperator(
task_id="gcs_to_bq",
bucket="bucket_name_Y",
source_format="CSV",
compression="GZIP",
source_objects=f"{DIR_NAME}/{FILE_NAME}.csv",
destination_project_dataset_table="project_id_Y.dataset_Y.table_Y",
write_disposition="WRITE_TRUNCATE",
gcp_conn_id="my_connection_X",
skip_leading_rows=1,
impersonation_chain=my_service_account_X
```
We were using Cloud Composer 1 (Airflow 2.2.5) and it worked, when we switched to Cloud Composer 2 (Airflow 2.5.3) we have an error.
### What you think should happen instead
The dataset scope access should work as before.
But now, we can see the error about **project** scope.
```sh
[2023-07-28, 13:22:49 UTC] {taskinstance.py:1778} ERROR - Task failed with exception
Traceback (most recent call last):
File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/transfers/gcs_to_bigquery.py", line 378, in execute
job: BigQueryJob | UnknownJob = self._submit_job(self.hook, job_id)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/transfers/gcs_to_bigquery.py", line 300, in _submit_job
return hook.insert_job(
File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/common/hooks/base_google.py", line 468, in inner_wrapper
return func(self, *args, **kwargs)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/hooks/bigquery.py", line 1595, in insert_job
job_api_repr._begin()
File "/opt/python3.8/lib/python3.8/site-packages/google/cloud/bigquery/job/base.py", line 693, in _begin
api_response = client._call_api(
File "/opt/python3.8/lib/python3.8/site-packages/google/cloud/bigquery/client.py", line 816, in _call_api
return call()
File "/opt/python3.8/lib/python3.8/site-packages/google/api_core/retry.py", line 349, in retry_wrapped_func
return retry_target(
File "/opt/python3.8/lib/python3.8/site-packages/google/api_core/retry.py", line 191, in retry_target
return target()
File "/opt/python3.8/lib/python3.8/site-packages/google/cloud/_http/__init__.py", line 494, in api_request
raise exceptions.from_http_response(response)
google.api_core.exceptions.Forbidden: 403 POST https://bigquery.googleapis.com/bigquery/v2/projects/project_id_Y/jobs?prettyPrint=false: Access Denied: Project project_id_Y: User does not have bigquery.jobs.create permission in project project_id_Y.
```
### How to reproduce
1. You need to have two GCP projects.
2. Create my_service_account_X in project_id_X
3. Assign my_service_account_X BigQuery Admin role on dataset_Y scope (in project_id_Y)
4. Try to call GCSToBigQueryOperator on any file.
### Operating System
Ubuntu 20.04.6 LTS
### Versions of Apache Airflow Providers
```sh
apache-airflow-providers-apache-beam @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_apache_beam-5.1.1-py3-none-any.whl
apache-airflow-providers-cncf-kubernetes @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_cncf_kubernetes-7.1.0-py3-none-any.whl
apache-airflow-providers-common-sql @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_common_sql-1.5.2-py3-none-any.whl
apache-airflow-providers-dbt-cloud @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_dbt_cloud-3.2.1-py3-none-any.whl
apache-airflow-providers-ftp @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_ftp-3.4.2-py3-none-any.whl
apache-airflow-providers-google @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_google-2023.6.6%2Bcomposer-py3-none-any.whl
apache-airflow-providers-hashicorp @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_hashicorp-3.4.1-py3-none-any.whl
apache-airflow-providers-http @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_http-4.4.2-py3-none-any.whl
apache-airflow-providers-imap @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_imap-3.2.2-py3-none-any.whl
apache-airflow-providers-mysql @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_mysql-5.1.1-py3-none-any.whl
apache-airflow-providers-postgres @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_postgres-5.5.1-py3-none-any.whl
apache-airflow-providers-sendgrid @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_sendgrid-3.2.1-py3-none-any.whl
apache-airflow-providers-sftp==4.4.0
apache-airflow-providers-slack==7.3.1
apache-airflow-providers-sqlite @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_sqlite-3.4.2-py3-none-any.whl
apache-airflow-providers-ssh @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_ssh-3.7.1-py3-none-any.whl
```
### Deployment
Google Cloud Composer
### Deployment details
composer-2.3.4-airflow-2.5.3
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ivan-toriya-precis commented on issue #32918: GCSToBigQueryOperator dataset access scope not working with a service account
Posted by "ivan-toriya-precis (via GitHub)" <gi...@apache.org>.
ivan-toriya-precis commented on issue #32918:
URL: https://github.com/apache/airflow/issues/32918#issuecomment-1667355607
@dzhigimont I don't have full project access, so I can only grant dataset scoped roles. So granting 'BigQuery User' (the role I can grant on dataset with 'bigquery.jobs.create' permission) still gives me an error `User does not have bigquery.jobs.create permission in project project_id_Y`
--
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
[GitHub] [airflow] ivan-toriya-precis commented on issue #32918: GCSToBigQueryOperator dataset access scope not working with a service account
Posted by "ivan-toriya-precis (via GitHub)" <gi...@apache.org>.
ivan-toriya-precis commented on issue #32918:
URL: https://github.com/apache/airflow/issues/32918#issuecomment-1658364088
Ah, sorry about that.
The apache-airflow-providers-google was on 10.1.1 Updated just now to the latest 10.3.0, still the same error.
```sh
Traceback (most recent call last):
File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/transfers/gcs_to_bigquery.py", line 380, in execute
job: BigQueryJob | UnknownJob = self._submit_job(self.hook, job_id)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/transfers/gcs_to_bigquery.py", line 302, in _submit_job
return hook.insert_job(
File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/common/hooks/base_google.py", line 475, in inner_wrapper
return func(self, *args, **kwargs)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/hooks/bigquery.py", line 1599, in insert_job
job_api_repr._begin()
File "/opt/python3.8/lib/python3.8/site-packages/google/cloud/bigquery/job/base.py", line 693, in _begin
api_response = client._call_api(
File "/opt/python3.8/lib/python3.8/site-packages/google/cloud/bigquery/client.py", line 816, in _call_api
return call()
File "/opt/python3.8/lib/python3.8/site-packages/google/api_core/retry.py", line 349, in retry_wrapped_func
return retry_target(
File "/opt/python3.8/lib/python3.8/site-packages/google/api_core/retry.py", line 191, in retry_target
return target()
File "/opt/python3.8/lib/python3.8/site-packages/google/cloud/_http/__init__.py", line 494, in api_request
raise exceptions.from_http_response(response)
google.api_core.exceptions.Forbidden: 403 POST https://bigquery.googleapis.com/bigquery/v2/projects/project_id_Y/jobs?prettyPrint=false: Access Denied: Project project_id_Y: User does not have bigquery.jobs.create permission in project project_id_Y.
```
--
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
[GitHub] [airflow] ivan-toriya-precis closed issue #32918: GCSToBigQueryOperator dataset access scope not working with a service account
Posted by "ivan-toriya-precis (via GitHub)" <gi...@apache.org>.
ivan-toriya-precis closed issue #32918: GCSToBigQueryOperator dataset access scope not working with a service account
URL: https://github.com/apache/airflow/issues/32918
--
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
[GitHub] [airflow] ivan-toriya-precis commented on issue #32918: GCSToBigQueryOperator dataset access scope not working with a service account
Posted by "ivan-toriya-precis (via GitHub)" <gi...@apache.org>.
ivan-toriya-precis commented on issue #32918:
URL: https://github.com/apache/airflow/issues/32918#issuecomment-1667370938
@dzhigimont ah, I missed the role description on 'BigQuery User'
> When applied to a project, this role also provides the ability to run jobs, including queries, within the project.
So I guess, only the project scoped permission can fix the issue.
--
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
[GitHub] [airflow] eladkal commented on issue #32918: GCSToBigQueryOperator dataset access scope not working with a service account
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on issue #32918:
URL: https://github.com/apache/airflow/issues/32918#issuecomment-1666583923
> a new version of the provider requires a little bit more permissions
This doesn't sound like something related to the provider itself but more to the underlying google libraries?
However maybe we should add a note for this in the relevant version of the [change log](https://github.com/apache/airflow/blob/main/airflow/providers/google/CHANGELOG.rst)?
as simple as adding
```
.. note::
noting something...
```
@dzhigimont will you be willing to create a PR for it?
--
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
[GitHub] [airflow] nathadfield commented on issue #32918: GCSToBigQueryOperator dataset access scope not working with a service account
Posted by "nathadfield (via GitHub)" <gi...@apache.org>.
nathadfield commented on issue #32918:
URL: https://github.com/apache/airflow/issues/32918#issuecomment-1691322807
@dzhigimont @eladkal Doesn't sound like there's anything broken here. Shall we close this?
--
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
[GitHub] [airflow] dzhigimont commented on issue #32918: GCSToBigQueryOperator dataset access scope not working with a service account
Posted by "dzhigimont (via GitHub)" <gi...@apache.org>.
dzhigimont commented on issue #32918:
URL: https://github.com/apache/airflow/issues/32918#issuecomment-1666490721
@ivan-toriya-precis Add the role 'BigQuery Job User' to your service account and it will be working, a new version of the provider requires a little bit more permissions
--
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
[GitHub] [airflow] boring-cyborg[bot] commented on issue #32918: GCSToBigQueryOperator dataset access scope not working with a service account
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on issue #32918:
URL: https://github.com/apache/airflow/issues/32918#issuecomment-1655752774
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
--
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
[GitHub] [airflow] eladkal commented on issue #32918: GCSToBigQueryOperator dataset access scope not working with a service account
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on issue #32918:
URL: https://github.com/apache/airflow/issues/32918#issuecomment-1655825932
Hi @ivan-toriya-precis
This is Airflow repo not Cloud composer so when you are reporting:
> apache-airflow-providers-google @ file:///usr/local/lib/airflow-pypi-dependencies-2.5.3/python3.8/apache_airflow_providers_google-2023.6.6%2Bcomposer-py3-none-any.whl
Its impossible for us to know which google provider version you are refering to as 2023.6.6 is not open source version. Google provider source code is not part of Airflow core thus updating Airflow version has nothing to do with your issue. The issue is that you updated Google provider version.
Please check if issue still happens with latest google provider. If so please state which version of google provider you are updating from. (If this is unkown to you please check with Google support if they can chime in this issue and clarify this missing parts).
--
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
[GitHub] [airflow] dzhigimont commented on issue #32918: GCSToBigQueryOperator dataset access scope not working with a service account
Posted by "dzhigimont (via GitHub)" <gi...@apache.org>.
dzhigimont commented on issue #32918:
URL: https://github.com/apache/airflow/issues/32918#issuecomment-1668185251
@ivan-toriya-precis
> > a new version of the provider requires a little bit more permissions
>
> This doesn't sound like something related to the provider itself but more to the underlying google libraries? However maybe we should add a note for this in the relevant version of the [change log](https://github.com/apache/airflow/blob/main/airflow/providers/google/CHANGELOG.rst)? as simple as adding
>
> ```
> .. note::
> noting something...
> ```
>
> @dzhigimont will you be willing to create a PR for it?
I am not sure that internal GCP IAM roles changes should be reflected in the provider change log
--
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
[GitHub] [airflow] dzhigimont commented on issue #32918: GCSToBigQueryOperator dataset access scope not working with a service account
Posted by "dzhigimont (via GitHub)" <gi...@apache.org>.
dzhigimont commented on issue #32918:
URL: https://github.com/apache/airflow/issues/32918#issuecomment-1668189781
> @dzhigimont ah, I missed the role description on 'BigQuery User'
>
> > When applied to a project, this role also provides the ability to run jobs, including queries, within the project.
>
> So I guess, only the project scoped permission can fix the issue.
I think so, it's better to contact your SA team to clarify permissions
--
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