Skip to content

kubelet check failing to initialize - NameError: name 'log' is not defined #16179

Open
@ledor473

Description

@ledor473

Output of the info page

 Check Initialization Errors
  ===========================


      kubelet (7.9.2)
      ---------------

      instance 0:

        could not invoke 'kubelet' python check constructor. New constructor API returned:
Traceback (most recent call last):
  File "/opt/datadog-agent/embedded/lib/python3.9/site-packages/datadog_checks/kubelet/kubelet.py", line 179, in __init__
    cadvisor_instance = self._create_cadvisor_prometheus_instance(inst)
  File "/opt/datadog-agent/embedded/lib/python3.9/site-packages/datadog_checks/kubelet/prometheus.py", line 81, in _create_cadvisor_prometheus_instance
    endpoint = get_prometheus_url("dummy_url/cadvisor")
  File "/opt/datadog-agent/embedded/lib/python3.9/site-packages/datadog_checks/kubelet/common.py", line 114, in get_prometheus_url
    log.warning(error)
NameError: name 'log' is not defined
Deprecated constructor API returned:
__init__() got an unexpected keyword argument 'agentConfig'
  Loading Errors
  ==============
    kubelet
    -------
      Core Check Loader:
        Check kubelet not found in Catalog

      JMX Check Loader:
        check is not a jmx check, or unable to determine if it's so

      Python Check Loader:
        could not configure check instance for python check kubelet: could not invoke 'kubelet' python check constructor. New constructor API returned:
Traceback (most recent call last):
  File "/opt/datadog-agent/embedded/lib/python3.9/site-packages/datadog_checks/kubelet/kubelet.py", line 179, in __init__
    cadvisor_instance = self._create_cadvisor_prometheus_instance(inst)
  File "/opt/datadog-agent/embedded/lib/python3.9/site-packages/datadog_checks/kubelet/prometheus.py", line 81, in _create_cadvisor_prometheus_instance
    endpoint = get_prometheus_url("dummy_url/cadvisor")
  File "/opt/datadog-agent/embedded/lib/python3.9/site-packages/datadog_checks/kubelet/common.py", line 114, in get_prometheus_url
    log.warning(error)
NameError: name 'log' is not defined
Deprecated constructor API returned:
__init__() got an unexpected keyword argument 'agentConfig'

Additional environment details (Operating System, Cloud provider, etc):
AWS EKS v1.24.17

Steps to reproduce the issue:

  1. Run an instance refresh on a very large cluster which results in new nodes being
  2. Do an agent status on the new datadog-agent on the new nodes
  3. Some of the agents will show the error above if you are "lucky" enough

Describe the results you received:
The Agent does not retry the kubelet integration causing metrics loss.

Describe the results you expected:
The Agent should retry

Additional information you deem important (e.g. issue happens only occasionally):
It appears to be caused by the log variable not being defined here:

if error:
log.warning(error)

This was introduced in #15706 which was the second attempt (#14546) to fix #14791

@AliDatadog @iliakur @sblumenthal

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions