Skip to content

Conversation

@puretension
Copy link
Contributor

What does this PR do?

Fixes AttributeError when Proxmox VMs don't have Qemu Agent installed or available.

Motivation

Fixes #21300 - When Qemu Agent is not installed on Proxmox VMs, the /agent/get-host-name endpoint fails and causes an AttributeError. This breaks hostname collection for VMs without the agent.

Description of the changes

  • Add AttributeError to the existing exception handling in _get_vm_hostname()
  • Falls back to using vm_name when Qemu Agent is unavailable
  • Maintains existing logging behavior for debugging

How to test the changes?

Test with Proxmox VMs that don't have Qemu Agent installed - the integration should continue working and use VM names as hostnames.

Review checklist

  • Feature or bugfix MUST have appropriate tests (existing tests cover the fallback behavior)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA
  • If you need to backport this PR to another branch, you can add the backport/ label

@codecov
Copy link

codecov bot commented Sep 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.00%. Comparing base (d0a9b95) to head (2e34aa3).
⚠️ Report is 68 commits behind head on master.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

github-actions bot commented Sep 18, 2025

⚠️ The qa/skip-qa label has been added with shippable changes

The following files, which will be shipped with the agent, were modified in this PR and
the qa/skip-qa label has been added.

You can ignore this if you are sure the changes in this PR do not require QA. Otherwise, consider removing the label.

List of modified files that will be shipped with the agent
proxmox/changelog.d/21399.fixed
proxmox/datadog_checks/proxmox/check.py

@puretension puretension force-pushed the fix-proxmox-hostname-without-qemu-agent-21300 branch from 19ffa61 to 5d4b286 Compare September 18, 2025 18:03
sarah-witt
sarah-witt previously approved these changes Sep 29, 2025
Copy link
Contributor

@sarah-witt sarah-witt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks for the fix!

@temporal-github-worker-1 temporal-github-worker-1 bot dismissed sarah-witt’s stale review September 30, 2025 02:07

Review from sarah-witt is dismissed. Related teams and files:

  • agent-integrations
    • proxmox/datadog_checks/proxmox/check.py
    • proxmox/tests/test_unit.py
@puretension puretension force-pushed the fix-proxmox-hostname-without-qemu-agent-21300 branch from 8afb64b to 8f59804 Compare September 30, 2025 02:15
- Add AttributeError to existing exception handling in _get_vm_hostname()
- Fall back to using vm_name when Qemu Agent is unavailable
- Add test case for AttributeError scenario
- Maintain existing logging behavior for debugging

Fixes DataDog#21300

Signed-off-by: puretension <[email protected]>
@puretension puretension force-pushed the fix-proxmox-hostname-without-qemu-agent-21300 branch from 24be028 to e4715eb Compare September 30, 2025 05:58
puretension and others added 2 commits October 9, 2025 02:56
- Move hostname parsing logic inside try block for cleaner error handling
- Maintain fallback to vm_name when API call fails
- Improve code readability and exception flow

Co-authored-by: sarah-witt <[email protected]>
Signed-off-by: puretension <[email protected]>
Signed-off-by: sarah-witt <[email protected]>
…zed test

Move test_get_hostname_attribute_error test case to a parameter in
test_get_hostname_error and use MockResponse class as requested in review.

Signed-off-by: puretension <[email protected]>
…not configured

- Replace AttributeErrorMockResponse with MockResponse using status_code=200
- Use actual JSON response: {"data": null, "message": "No QEMU guest agent configured\n"}
- Update test case ID to qemu_agent_not_configured for clarity

Signed-off-by: puretension <[email protected]>
Remove multiple consecutive blank lines that were causing linting failures

Signed-off-by: puretension <[email protected]>
- Add required blank lines between functions
- Fix trailing comma spacing in MockResponse

Signed-off-by: puretension <[email protected]>
Copy link
Contributor

@sarah-witt sarah-witt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@sarah-witt sarah-witt added this pull request to the merge queue Oct 20, 2025
Merged via the queue into DataDog:master with commit f40b1e3 Oct 20, 2025
32 of 33 checks passed
@puretension
Copy link
Contributor Author

puretension commented Oct 20, 2025

Thanks a lot, @sarah-witt! 🙏
Really appreciate your proactive feedback and guidance. it helped me get this fix merged smoothly.
It’s an honor to have my first Datadog contribution merged!
I’ll keep contributing more actively to Datadog.

@aadlung
Copy link

aadlung commented Nov 16, 2025

When will this be included into the actual Datadog agent? When I updated it e.g. to 7.72.2 it is still the old check.py in the Proxmox integration?

@Kyle-Neale
Copy link
Contributor

When will this be included into the actual Datadog agent? When I updated it e.g. to 7.72.2 it is still the old check.py in the Proxmox integration?

This should be included in v7.73.0 of the Agent which includes v2.2.0 of the Proxmox integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proxmox Integration: Cannot get hostname without Qemu Agent

4 participants