Skip to content

feat: vmref: Support HA managed state#466

Open
TobiPeterG wants to merge 1 commit intoTelmate:masterfrom
TobiPeterG:add-ha-check
Open

feat: vmref: Support HA managed state#466
TobiPeterG wants to merge 1 commit intoTelmate:masterfrom
TobiPeterG:add-ha-check

Conversation

@TobiPeterG
Copy link

This will allow the terraform provider to check if a VM is HA managed before removing the HA resource.

This doesn't fix the broken check, but checking the HA state before removing the VM is the correct thing to do. Please fix or remove the broken HA managed error check.

@TobiPeterG
Copy link
Author

Related: #465

Copy link
Collaborator

@Tinyblargon Tinyblargon 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, only one functional change.
If possible please add a test?

Name GuestName `json:"name"`
State PowerState `json:"state"`
Uptime time.Duration `json:"uptime"`
HaManaged int `json:"hamanaged"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you change this to a bool as we abstract away PVE's handling of bool as int.

Copy link
Author

Choose a reason for hiding this comment

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

Where do you know that it is boolean? I couldn't find documentation for the object that is returned.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did some digging. This is has the same fields as the ha object in the status. They only refer to managed with 0 and 1, given that PVE uses 1 and 0 instead of true and fasle in API requests to safe a few bytes. I'm 99% confident this is an int encoded boolean.

https://github.com/proxmox/pve-ha-manager/blob/a75d95d378be798b536a593d258c5f203a39ef9c/src/PVE/HA/Config.pm#L465-L481

return 0
}

func (raw RawGuestStatus) GetHaManaged() int {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a test case to?

func Test_RawGuestStatus_Get(t *testing.T) {

@Tinyblargon Tinyblargon added type/enhancement An improvement of existing functionality modifies/go Pull requests that update Go code size/S Denotes a PR that changes 10-29 lines, ignoring generated files test/needen This PR has to be tested labels Oct 10, 2025
@TobiPeterG
Copy link
Author

Hey, sorry for the late reply. We switched to bpg's proxmox provider, so I'm not allowed to work on this anymore. Feel free to take the changes and add what's missing :)

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

Labels

modifies/go Pull requests that update Go code size/S Denotes a PR that changes 10-29 lines, ignoring generated files test/needen This PR has to be tested type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants