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

AzureContainerInstancesOperator uses a deprecated authentication flow in apache-airflow-providers-microsoft-azure #34749

Closed
1 of 2 tasks
strictness opened this issue Oct 4, 2023 · 2 comments
Labels
area:providers kind:bug This is a clearly a bug provider:microsoft-azure Azure-related issues

Comments

@strictness
Copy link

strictness commented Oct 4, 2023

Apache Airflow version

2.7.1

What happened

My previous bug report (#34736) was closed, but upon further investigation I am pretty sure that the fix should be handled in this repository. I have added the solution in a separate section below.

We currently have to hardcode our version of apache-airflow-providers-microsoft-azure to 6.2.4 in order for AzureContainerInstancesOperator to work as expected. If we bump the version to 6.3.0 or higher we get this error during execution:

[2023-10-03, 19:07:37 EEST] {taskinstance.py:1935} ERROR - Task failed with exception
Traceback (most recent call last):
  File "/home/airflow/.local/lib/python3.9/site-packages/airflow/providers/microsoft/azure/operators/container_instances.py", line 196, in execute
    if self._ci_hook.exists(self.resource_group, self.name):
  File "/home/airflow/.local/lib/python3.9/site-packages/airflow/providers/microsoft/azure/hooks/container_instance.py", line 198, in exists
    for container in self.connection.container_groups.list_by_resource_group(resource_group):
  File "/home/airflow/.local/lib/python3.9/site-packages/azure/core/paging.py", line 123, in __next__
    return next(self._page_iterator)
  File "/home/airflow/.local/lib/python3.9/site-packages/azure/core/paging.py", line 75, in __next__
    self._response = self._get_next(self.continuation_token)
  File "/home/airflow/.local/lib/python3.9/site-packages/azure/mgmt/containerinstance/operations/_container_groups_operations.py", line 182, in get_next
    pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
  File "/home/airflow/.local/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 230, in run
    return first_node.send(pipeline_request)
  File "/home/airflow/.local/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 86, in send
    response = self.next.send(request)
  File "/home/airflow/.local/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 86, in send
    response = self.next.send(request)
  File "/home/airflow/.local/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 86, in send
    response = self.next.send(request)
  [Previous line repeated 2 more times]
  File "/home/airflow/.local/lib/python3.9/site-packages/azure/mgmt/core/policies/_base.py", line 46, in send
    response = self.next.send(request)
  File "/home/airflow/.local/lib/python3.9/site-packages/azure/core/pipeline/policies/_redirect.py", line 197, in send
    response = self.next.send(request)
  File "/home/airflow/.local/lib/python3.9/site-packages/azure/core/pipeline/policies/_retry.py", line 531, in send
    response = self.next.send(request)
  File "/home/airflow/.local/lib/python3.9/site-packages/azure/core/pipeline/policies/_authentication.py", line 124, in send
    self.on_request(request)
  File "/home/airflow/.local/lib/python3.9/site-packages/azure/core/pipeline/policies/_authentication.py", line 99, in on_request
    self._token = self._credential.get_token(*self._scopes)
AttributeError: 'ServicePrincipalCredentials' object has no attribute 'get_token'

What you think should happen instead

The hook in container_instance.py should use the azure.identity package instead of azure.common.credentials. Link to code

Microsoft posted deprecation warnings about using that package since early 2021 - azure.common.

Here is a related issue, where the solution is to start using azure.identity instead.

How to reproduce

Install airflow 2.7.1 and try creating a DAG with AzureContainerInstancesOperator and run it.

Operating System

Windows 10

Versions of Apache Airflow Providers

apache-airflow-providers-microsoft-azure=6.3.0 or 7.0.0

Deployment

Docker-Compose

Deployment details

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@strictness strictness added area:core kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet labels Oct 4, 2023
@Lee-W Lee-W added provider:microsoft-azure Azure-related issues area:providers and removed area:core needs-triage label for new issues that we didn't triage yet labels Oct 4, 2023
@eladkal
Copy link
Contributor

eladkal commented Oct 4, 2023

Hi
thank you for this input!
We are updating the library in #34738
and tracking the task in #30199
can you share your input on the PR itself?
cc @pankajastro

@eladkal
Copy link
Contributor

eladkal commented Oct 10, 2023

fixed in #34738

@eladkal eladkal closed this as completed Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers kind:bug This is a clearly a bug provider:microsoft-azure Azure-related issues
Projects
None yet
Development

No branches or pull requests

3 participants