Skip to content

fix(node): add CPU utilization to node data source#2605

Merged
bpg-dev merged 2 commits intobpg:mainfrom
666Goofy666:node_cpu_utilization
Feb 17, 2026
Merged

fix(node): add CPU utilization to node data source#2605
bpg-dev merged 2 commits intobpg:mainfrom
666Goofy666:node_cpu_utilization

Conversation

@666Goofy666
Copy link
Copy Markdown
Contributor

@666Goofy666 666Goofy666 commented Feb 17, 2026

What does this PR do?

Enhancement: Add CPU utilization from the PVE Node API to proxmox_virtual_environment_node.

This change aims to close: #2387

However, I don’t think it’s a good idea to add the socket count to proxmox_virtual_environment_nodes, since the PVE Nodes API does not return this information. It would require calculating it from the Node API.
We currently do not perform N+1 calls in the provider.
¯\(ツ)

Contributor's Note

  • I have run make lint and fixed any issues.
  • I have updated documentation (FWK: schema descriptions + make docs; SDK: manual /docs/ edits).
  • I have added / updated acceptance tests (required for new resources and bug fixes — see ADR-006).
  • I have considered backward compatibility (no breaking schema changes without ! in PR title).
  • For new resources: I followed the reference examples.
  • I have run make example to verify the change works (mainly for SDK / provider config changes).

Proof of Work

./testacc TestAccDatasourceNode -- -v
Running single test: TestAccDatasourceNode
Found test in: ./fwprovider/test/datasource_node_test.go
Package: github.com/bpg/terraform-provider-proxmox/fwprovider/test

=== RUN   TestAccDatasourceNode
=== PAUSE TestAccDatasourceNode
=== CONT  TestAccDatasourceNode
=== RUN   TestAccDatasourceNode/read_node_attributes
=== PAUSE TestAccDatasourceNode/read_node_attributes
=== CONT  TestAccDatasourceNode/read_node_attributes
--- PASS: TestAccDatasourceNode (0.00s)
    --- PASS: TestAccDatasourceNode/read_node_attributes (1.18s)
PASS
ok      github.com/bpg/terraform-provider-proxmox/fwprovider/test       **1.200s**

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #2387

Signed-off-by: 666Goofy666 <153852747+666Goofy666@users.noreply.github.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @666Goofy666, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the proxmox_virtual_environment_node data source by integrating CPU utilization metrics directly from the Proxmox Node API. This provides users with immediate access to real-time CPU performance data for their Proxmox nodes, improving monitoring and resource management capabilities within Terraform configurations.

Highlights

  • New Attribute Added: The cpu_utilization attribute has been added to the proxmox_virtual_environment_node data source, providing real-time CPU usage metrics.
  • API Integration: The internal API response structure (GetInfoResponseData) was updated to include the CPUUtilization field, enabling the provider to fetch this data from the Proxmox Node API.
  • Data Processing: Logic was implemented to retrieve the CPU utilization value, round it to two decimal places, and expose it through the data source schema.
  • Documentation and Testing: The data source documentation has been updated to reflect the new attribute, and acceptance tests were modified to verify its presence and correctness.
Changelog
  • docs/data-sources/virtual_environment_node.md
    • Added cpu_utilization to the list of output attributes in the documentation.
  • fwprovider/test/datasource_node_test.go
    • Included cpu_utilization in the list of attributes verified by the acceptance test.
  • proxmox/nodes/nodes_types.go
    • Introduced CPUUtilization field to the GetInfoResponseData struct for API response parsing.
  • proxmoxtf/datasource/node.go
    • Imported the math package for numerical operations.
    • Defined a new constant mkDataSourceVirtualEnvironmentNodeCPUUtilization.
    • Added the cpu_utilization attribute to the data source schema as a TypeFloat.
    • Implemented the nodeRead function to retrieve CPUUtilization from the API response, round it to two decimal places, and set it in the Terraform state.
Activity
  • The author confirmed running make lint and addressing any identified issues.
  • Documentation for the virtual_environment_node data source has been updated to include the new cpu_utilization attribute.
  • Acceptance tests for the node data source were updated and successfully passed, verifying the new functionality.
  • Backward compatibility was considered, ensuring no breaking schema changes were introduced.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds CPU utilization to the proxmox_virtual_environment_node data source. While the logic for adding the new field is sound, the implementation is placed in the legacy SDK provider (proxmoxtf/). This contradicts the project's architectural guidelines, which state that new features must be added to the modern framework provider (fwprovider/). The implementation should be moved. Additionally, the documentation for the new field could be more specific about its value range to improve clarity for users.

Signed-off-by: 666Goofy666 <153852747+666Goofy666@users.noreply.github.com>
@bpg-dev bpg-dev changed the title fix(node): Add CPU utilization to node data source fix(node): add CPU utilization to node data source Feb 17, 2026
Copy link
Copy Markdown
Member

@bpg-dev bpg-dev left a comment

Choose a reason for hiding this comment

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

Thanks @666Goofy666, good addition!

LGTM! 🚀

@bpg-dev bpg-dev merged commit 1a1cbbb into bpg:main Feb 17, 2026
5 checks passed
@666Goofy666 666Goofy666 deleted the node_cpu_utilization branch February 18, 2026 19:45
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

Successfully merging this pull request may close these issues.

proxmox_virtual_environment_nodes resource doesn't show cpu sockets

2 participants