-
Notifications
You must be signed in to change notification settings - Fork 465
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
Provider does not track active state of network #947
Comments
// resourceLibvirtNetworkUpdate updates dynamically some attributes in the network
func resourceLibvirtNetworkUpdate(d *schema.ResourceData, meta interface{}) error {
// check the list of things that can be changed dynamically
// in https://wiki.libvirt.org/page/Networking#virsh_net-update
virConn := meta.(*Client).libvirt
if virConn == nil {
return fmt.Errorf(LibVirtConIsNil)
}
network, err := virConn.NetworkLookupByUUID(parseUUID(d.Id()))
if err != nil {
return fmt.Errorf("can't retrieve network with ID '%s' during update: %s", d.Id(), err)
}
d.Partial(true)
activeInt, err := virConn.NetworkIsActive(network)
if err != nil {
return fmt.Errorf("error when getting network %s status during update: %s", network.Name, err)
}
active := activeInt == 1
if !active {
log.Printf("[DEBUG] Activating network %s", network.Name)
if err := virConn.NetworkCreate(network); err != nil {
return fmt.Errorf("error when activating network %s during update: %s", network.Name, err)
}
} in But I am not sure what is the best way to track this. A computed attribute? Tell somehow terraform to foce the update even if no parameter from the schema is changed? |
I think this is nice feature to have. |
I think the overall network provider is messy because it deviated a lot from libvirt, due to its origin in supporting specific use cases for Kubernetes infrastructure. I don't have an opinion on what is the best way. I think the best is to continue the v2 network resource that is 1:1 with libvirt (there is a branch for it). |
When creating a libvirt network without autostart and rebooting the hypervisor, the network and the instances (domains) are inactive / stopped, as expected.
Running
terraform plan
in this scenario we get this:This shows that provider is able to track if the libvirt_domain is running and try to bring it up again, but it does NOT! track the state of the network it is connected to and we manually need to run
virsh net-start network
before runningterraform plan
again in order to get a successful result.The text was updated successfully, but these errors were encountered: