feat: add proxmox_node_status data source - #1510
Open
cgoolsby wants to merge 1 commit into
Open
Conversation
Adds a new data source that queries the Proxmox /nodes API endpoint
to expose per-node status information, including whether a node has
been placed into maintenance mode by the HA manager.
Attributes returned:
- status (string): "online" or "offline"
- maintenance (bool): true when the node is in HA maintenance mode
- uptime (int): node uptime in seconds
- cpu (float): CPU utilization fraction
- mem_used (int): memory used in bytes
- mem_total (int): total memory in bytes
The primary use case is excluding nodes in maintenance mode from
workload placement. For example, using a precondition to prevent
deploying VMs onto a node that is draining:
data "proxmox_node_status" "pve1" {
node = "pve1"
}
resource "proxmox_vm_qemu" "app" {
lifecycle {
precondition {
condition = !data.proxmox_node_status.pve1.maintenance
error_message = "Node pve1 is in maintenance mode."
}
}
}
maintenance and status are kept as separate attributes because they
are orthogonal: a node can be online and in maintenance simultaneously.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
proxmox_node_statusdata source that queries the Proxmox/nodesAPI endpointmaintenanceboolean attributestatus,uptime,cpu,mem_used, andmem_totalfor convenienceMotivation
The primary use case is excluding nodes in maintenance mode from workload placement. Without this data source, there is no way to query node-level status from within Terraform, leaving users no option but to manually check the Proxmox UI before running
terraform apply.Usage
Prevent deploying onto a node in maintenance mode:
Skip resources on a maintenance node:
Notes
proxmox-api-gorequired — uses the existingGetNodeList()methodmaintenancefield is absent from the API response for normal nodes and safely defaults tofalse; Proxmox sends a numeric1when the HA manager places a node into maintenance modemaintenanceandstatusare kept as separate attributes because they are orthogonal: a node can beonlineand in maintenance simultaneouslyTest plan
go build ./...passesgo vet ./...passesstaticcheck ./...passesgo test -race -vet=off ./...passesmaintenance = truewhen node is in maintenance mode in Proxmox web UImaintenance = falsefor a normal online node