Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(domain): restore error handling for network operations #1144

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SJFCS
Copy link

@SJFCS SJFCS commented Jan 11, 2025

Restore critical error checks for network
These checks are necessary to ensure proper error propagation when network operations fail.

Fixes #1091

Please make sure you read the contributor documentation before opening a Pull Request.

Restore critical error checks for network
These checks are necessary to ensure proper error propagation when network operations fail.

Fixes dmacvicar#1091
@SJFCS
Copy link
Author

SJFCS commented Jan 11, 2025

  1. In version 0.7.1, the domainGetIfacesInfo function has special logic for error handling.
    if an ErrAgentUnresponsive error is encountered when using qemu-agent to obtain an IP address, the code will ignore the error and continue trying, which gives qemu-agent time to start and respond.
switch virErr := err.(type) {
case libvirt.Error:
    // Agent can be unresponsive if being installed/setup
    if addrsrc == uint32(libvirt.DomainInterfaceAddressesSrcLease) && virErr.Code != uint32(libvirt.ErrOperationInvalid) ||
        addrsrc == uint32(libvirt.DomainInterfaceAddressesSrcAgent) && virErr.Code != uint32(libvirt.ErrAgentUnresponsive) {
        return interfaces, fmt.Errorf("Error retrieving interface addresses: %w", err)
    }
}
  1. In the latest version(all version after 0.7.1), error handling becomes simpler.
    any error will be returned directly, including ErrAgentUnresponsive, which causes qemu-agent to fail before it has fully started and responded.
if err != nil {
    return interfaces, fmt.Errorf("error retrieving interface addresses: %w", err)
}

This PR fixes this error handling.

Make the test cases mentioned issues/1091 pass.

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.

"wait_for_lease = true" is broken in versions greater than 0.7.1
1 participant