Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloudBuildRunBuildTriggerOPerator: 'property' object has no attribute 'build' #22398

Closed
2 tasks done
stephenoken opened this issue Mar 21, 2022 · 2 comments · Fixed by #22419
Closed
2 tasks done

CloudBuildRunBuildTriggerOPerator: 'property' object has no attribute 'build' #22398

stephenoken opened this issue Mar 21, 2022 · 2 comments · Fixed by #22419
Assignees
Labels
area:providers good first issue kind:bug This is a clearly a bug provider:google Google (including GCP) related issues

Comments

@stephenoken
Copy link
Contributor

Apache Airflow Provider(s)

google

Versions of Apache Airflow Providers

apache-airflow-providers-google==6.6.0

Apache Airflow version

2.2.4 (latest released)

Operating System

GCP Cloud Composer 2

Deployment

Composer

Deployment details

We're currently using the default set up of cloud composer 2 on GCP.

What happened

When trying to trigger cloud build trigger using the CloudBuildRunBuildTriggerOperator We receive the following error:

[2022-03-21, 12:28:57 UTC] {credentials_provider.py:312} INFO - Getting connection using `google.auth.default()` since no key file is defined for hook.
[2022-03-21, 12:28:58 UTC] {cloud_build.py:503} INFO - Start running build trigger: <TRIGGER ID>.
[2022-03-21, 12:29:00 UTC] {taskinstance.py:1702} ERROR - Task failed with exception
Traceback (most recent call last):
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/hooks/cloud_build.py", line 75, in _get_build_id_from_operation
    return operation.metadata.build.id
AttributeError: 'property' object has no attribute 'build'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1330, in _run_raw_task
    self._execute_task_with_callbacks(context)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1457, in _execute_task_with_callbacks
    result = self._execute_task(context, self.task)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1513, in _execute_task
    result = execute_callable(context=context)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/operators/cloud_build.py", line 739, in execute
    result = hook.run_build_trigger(
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/common/hooks/base_google.py", line 433, in inner_wrapper
    return func(self, *args, **kwargs)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/hooks/cloud_build.py", line 512, in run_build_trigger
    id_ = self._get_build_id_from_operation(Operation)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/hooks/cloud_build.py", line 77, in _get_build_id_from_operation
    raise AirflowException("Could not retrieve Build ID from Operation.")
airflow.exceptions.AirflowException: Could not retrieve Build ID from Operation.
[2022-03-21, 12:29:00 UTC] {taskinstance.py:1268} INFO - Marking task as FAILED. dag_id=deploy_index, task_id=trigger_build, execution_date=20220321T122848, start_date=20220321T122856, end_date=20220321T122900
[2022-03-21, 12:29:00 UTC] {standard_task_runner.py:89} ERROR - Failed to execute job 1003 for task trigger_build
Traceback (most recent call last):
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/hooks/cloud_build.py", line 75, in _get_build_id_from_operation
    return operation.metadata.build.id
AttributeError: 'property' object has no attribute 'build'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/task/task_runner/standard_task_runner.py", line 85, in _start_by_fork
    args.func(args, dag=self.dag)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/cli/cli_parser.py", line 48, in command
    return func(*args, **kwargs)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/utils/cli.py", line 94, in wrapper
    return f(*args, **kwargs)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/cli/commands/task_command.py", line 302, in task_run
    _run_task_by_selected_method(args, dag, ti)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/cli/commands/task_command.py", line 107, in _run_task_by_selected_method
    _run_raw_task(args, ti)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/cli/commands/task_command.py", line 180, in _run_raw_task
    ti._run_raw_task(
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/utils/session.py", line 70, in wrapper
    return func(*args, session=session, **kwargs)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1330, in _run_raw_task
    self._execute_task_with_callbacks(context)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1457, in _execute_task_with_callbacks
    result = self._execute_task(context, self.task)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1513, in _execute_task
    result = execute_callable(context=context)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/operators/cloud_build.py", line 739, in execute
    result = hook.run_build_trigger(
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/common/hooks/base_google.py", line 433, in inner_wrapper
    return func(self, *args, **kwargs)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/hooks/cloud_build.py", line 512, in run_build_trigger
    id_ = self._get_build_id_from_operation(Operation)
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/hooks/cloud_build.py", line 77, in _get_build_id_from_operation
    raise AirflowException("Could not retrieve Build ID from Operation.")
airflow.exceptions.AirflowException: Could not retrieve Build ID from Operation.
[2022-03-21, 12:29:00 UTC] {local_task_job.py:154} INFO - Task exited with return code 1
[2022-03-21, 12:29:01 UTC] {local_task_job.py:264} INFO - 0 downstream tasks scheduled from follow-on schedule check

Below is the code snippet that's causing the above error.

trigger_deploy = CloudBuildRunBuildTriggerOperator(
        task_id="trigger_deploy",
        trigger_id="TRIGGER_ID",
        project_id="PROEJCT_ID",
        source=RepoSource({"project_id": "PROJECT_ID",
                           "repo_name": "REPO_NAME",
                           "branch_name": "BRANCH",
                           }),
        wait=True,
        do_xcom_push=True
    )

What you think should happen instead

No response

How to reproduce

No response

Anything else

We reckon the source of the bug is here.

        id_ = self._get_build_id_from_operation(Operation)

Since the function signature is looking for an instance of Operation instead of the class itself.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@stephenoken stephenoken added area:providers kind:bug This is a clearly a bug labels Mar 21, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Mar 21, 2022

Thanks for opening your first issue here! Be sure to follow the issue template!

@eladkal
Copy link
Contributor

eladkal commented Mar 21, 2022

feel free to submit a PR

@eladkal eladkal added provider:google Google (including GCP) related issues good first issue labels Mar 21, 2022
stephenoken pushed a commit to stephenoken/airflow that referenced this issue Mar 22, 2022
…e 'build' apache#22398

 * Fixed issue where the `_get_build_id_from_operation` was accepting the Operation class instead of an instance of operation in the `create_build` function.

 * Added an assertion to verify the above fix.
eladkal pushed a commit that referenced this issue Mar 23, 2022
…22419)

* Fix CloudBuildRunBuildTriggerOperator: 'property' object has no attribute 'build' #22398
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers good first issue kind:bug This is a clearly a bug provider:google Google (including GCP) related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants