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

Datadog Airflow OAuth Integration not working #19143

Open
dalsania1 opened this issue Nov 26, 2024 · 0 comments
Open

Datadog Airflow OAuth Integration not working #19143

dalsania1 opened this issue Nov 26, 2024 · 0 comments

Comments

@dalsania1
Copy link

dalsania1 commented Nov 26, 2024

I am attempting to use the OAuth Reader as part of the airflow datadog integration by following the documentation outlined here.
https://github.com/DataDog/integrations-core/blob/e1dda566ad5aa2c921a396077cb8f0f8c42bba75/airflow/datadog_checks/airflow/data/conf.yaml.example
I am deploying the datadog agent via helm and using the following airflow configuration settings.

datadog:
  confd:
    airflow.yaml: |-
      ad_identifiers:
        - <MY_CONTAINER>
      init_config: {}
      instances:
          url: "https://%%host%%:8443"
          auth_token:
            reader:
              type: oauth
              url: <MY_URL>
              client_id: "%%env_AIRFLOW_CLIENT_ID%%"
              client_secret: "%%env_AIRFLOW_CLIENT_SECRET%%"
              options:
                resource: <MY_RESOURCE>
            writer:
              type: header
              name: Authorization
              value: Bearer <TOKEN>
              placeholder: <TOKEN>

When the datadog agent goes to run the airflow check, I see the following error:

      Traceback (most recent call last):
        File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/base/checks/base.py", line 1298, in run
          self.check(instance)
        File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/airflow/airflow.py", line 48, in check
          resp = self._get_json(target_url)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/airflow/airflow.py", line 137, in _get_json
          resp = self.http.get(url)
                 ^^^^^^^^^^^^^^^^^^
        File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/base/utils/http.py", line 352, in get
          return self._request('get', url, options)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/base/utils/http.py", line 397, in _request
          self.handle_auth_token(method=method, url=url, default_options=self.options)
        File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/base/utils/http.py", line 545, in handle_auth_token
          self.auth_token_handler.poll(**request)
        File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/base/utils/http.py", line 753, in poll
          token = self.reader.read(**request)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/base/utils/http.py", line 841, in read
          if self._token is None or get_timestamp() >= self._expiration or 'error' in request:
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      TypeError: '>=' not supported between instances of 'float' and 'NoneType

I suspect that the code here is causing the issue:

self._token = None
self._expiration = None
def read(self, **request):
if self._token is None or get_timestamp() >= self._expiration or 'error' in request:
global oauth2
if oauth2 is None:

Is this a bug in the code or am I just not passing in the airflow configuration values correctly?

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant