-
Notifications
You must be signed in to change notification settings - Fork 458
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
libvirt/resource_libvirt_network: Support updates for dns.hosts #469
Conversation
Looks like this needs indexes or some such for deleting an entry where there were previously more than one. As of 5f190c9, that's giving me:
|
@wking thx for pr. so for testing the Basically when you add a 2nd step in the terraformACC framework it will tests for updating the resource I will have a deeper loook when i have time thx! |
I'm working through the review suggestions now. Also related is the libvirt patch I just filed, although I don't think we need to block this PR on that landing. |
@wking nice one yop |
5f190c9
to
018c3f4
Compare
Recreating the nework detaches associated interfaces [1]: Sometimes, one needs to edit the network definition and apply the changes on the fly. The most common scenario for this is adding new static MAC+IP mappings for the network's DHCP server. If you edit the network with "virsh net-edit", any changes you make won't take effect until the network is destroyed and re-started, which unfortunately will cause a all guests to lose network connectivity with the host until their network interfaces are explicitly re-attached. With this commit, we update the network on dns.hosts changes instead of forcing a new network. This allows DNS host changes without clearing domain network interfaces. I'm removing stale entries by IP alone, because libvirt allows multiple IP addresses to share a hostname [2,3]. I have a patch in flight that may update that logic to make IP matching explicitly the only consideration [4]. The lowercase error messages break with the existing pattern for at least some of this package, but they comply with [5]: Error strings should not be capitalized (unless beginning with proper nouns or acronyms) or end with punctuation, since they are usually printed following other context. Putting the new helpers in their own network.go is Dario's suggestion [6]. [1]: https://wiki.libvirt.org/page/Networking#Applying_modifications_to_the_network [2]: https://libvirt.org/formatnetwork.html#elementsAddress [3]: https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/conf/network_conf.c;h=39a13b433dbbf91ccb080036df754fdeb3adc905;hb=7a10a6a598ab4e8599c867060a7232a06c663e51#l3336 [4]: https://www.redhat.com/archives/libvir-list/2018-November/msg00231.html [5]: https://github.com/golang/go/wiki/CodeReviewComments#error-strings [6]: dmacvicar#469 (comment)
Recreating the nework detaches associated interfaces [1]: Sometimes, one needs to edit the network definition and apply the changes on the fly. The most common scenario for this is adding new static MAC+IP mappings for the network's DHCP server. If you edit the network with "virsh net-edit", any changes you make won't take effect until the network is destroyed and re-started, which unfortunately will cause a all guests to lose network connectivity with the host until their network interfaces are explicitly re-attached. With this commit, we update the network on dns.hosts changes instead of forcing a new network. This allows DNS host changes without clearing domain network interfaces. I'm removing stale entries by IP alone, because libvirt allows multiple IP addresses to share a hostname [2,3]. I have a patch in flight that may update that logic to make IP matching explicitly the only consideration [4]. The lowercase error messages break with the existing pattern for at least some of this package, but they comply with [5]: Error strings should not be capitalized (unless beginning with proper nouns or acronyms) or end with punctuation, since they are usually printed following other context. Putting the new helpers in their own network.go is Dario's suggestion [6]. Update unit tests are documented in [7]. [1]: https://wiki.libvirt.org/page/Networking#Applying_modifications_to_the_network [2]: https://libvirt.org/formatnetwork.html#elementsAddress [3]: https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/conf/network_conf.c;h=39a13b433dbbf91ccb080036df754fdeb3adc905;hb=7a10a6a598ab4e8599c867060a7232a06c663e51#l3336 [4]: https://www.redhat.com/archives/libvir-list/2018-November/msg00231.html [5]: https://github.com/golang/go/wiki/CodeReviewComments#error-strings [6]: dmacvicar#469 (comment) [7]: https://www.terraform.io/docs/extend/best-practices/testing.html#update-test-verify-configuration-changes
018c3f4
to
ef44231
Compare
Ok, I've pushed 5f190c9 -> ef44231, moving the helpers into $ TF_ACC=1 LIBVIRT_DEFAULT_URI=qemu:///system go test -v -run TestAccLibvirtNetwork_DNSHosts ./libvirt/
=== RUN TestAccLibvirtNetwork_DNSHosts
--- PASS: TestAccLibvirtNetwork_DNSHosts (10.44s)
PASS
ok github.com/dmacvicar/terraform-provider-libvirt/libvirt 10.457s |
I've filed this libvirt bug to track the patch I mentioned earlier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
thx
@wking we can wait for @dmacvicar when he has time for review Otherwise i will merge it during the week but looks good thx |
Let me know if you don't expect to get this landed before the weekend. We're planning on cutting an openshift-installer release and I'll have to adjust the docs to point at my branch until this lands here. |
@wking merged, thanks you for your contribution. Enjoy your day 🌞 |
Recreating the nework detaches associated interfaces:
With this pull-request, we update the network on
dns.hosts
changes instead of forcing a new network. This allows DNS host changes without clearing domain network interfaces.Partially handles #389, #468.