Skip to content

Conversation

@ne-bknn
Copy link

@ne-bknn ne-bknn commented Sep 11, 2024

Includes network activity status in terraform state, thus allowing terraform to update network resource in case it is inactive (e.g. after hypervisor reboot or virsh net-destroy)

Network activity is checked in Update method, but not in Read, its not recorded in local state. This makes terraform think that network should not be updated (since the state matches recorded one). Then, VM initialization fails, since it depends on an inactive network.

First brought up in #1095.

Includes network activity status in terraform state,
thus allowing terraform to update network resource
in case it is inactive (e.g. after hypervisor reboot
or `virsh net-destroy`)
@ne-bknn
Copy link
Author

ne-bknn commented Sep 12, 2024

Uh, actually referenced here with explanation why this isn't yet fixed: #947

I've just copy-pasted running variable from libvirt_domain schema. My reasoning is that they are semantically equivalent, so if this variable config is correct for libvirt_domain it should be correct for libvirt_network. What's the catch?

Full disclosure: only user-level experience with terraform, no experience with libvirt. My assumptions may be horribly wrong.

@dmacvicar
Copy link
Owner

Thanks for the attempt.

It is more complicated than that. It requires on acting on the status based of what you read to bring the network up if it was up last time and it is now down.

@dmacvicar dmacvicar marked this pull request as draft September 15, 2024 09:43
@ne-bknn
Copy link
Author

ne-bknn commented Sep 15, 2024

I understand that I can be and most probably is wrong, but I do not understand why. Network state is checked in Update and Update brings it up if its not up:

activeInt, err := virConn.NetworkIsActive(network)
if err != nil {
return diag.Errorf("error when getting network %s status during update: %s", network.Name, err)
}
if activeInt != 1 {
log.Printf("[DEBUG] Activating network %s", network.Name)
if err := virConn.NetworkCreate(network); err != nil {
return diag.Errorf("error when activating network %s during update: %s", network.Name, err)
}
}

We just have to signal to terraform that network state is not the expected one. My (manual and naive) tests show that it works - if the network is up, it won't be updated, if it is down, it will be. What case I fail to see?

@dmacvicar dmacvicar changed the base branch from main to v0.8 November 8, 2025 00:12
@dmacvicar
Copy link
Owner

ℹ️ ℹ️ ℹ️ ℹ️ ℹ️ ℹ️

This contribution is relevant to the legacy version of the provider, which is now in the v0.8 branch of this repository.

Future development is based on a new provider, which is not compatible with this one, nor does share code.

As the new provider solves many issues with the legacy, and to make development in my free time more enjoyable, I have decided to close all PRs for the legacy provider, and to ask to check if the contribution would apply to the new one. This also to encourage trying the new version.

and check the documentation:

You are free to reopen the PR for v0.8, which is targetted now to the v0.8 branch. We may also start a discussion if we can assemble a team of maintainters for the legacy branch. My efforts will go into the new provider.

I ask you to check the new provider and re-evaluate this contribution. 🙏

@dmacvicar dmacvicar closed this Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants