From ab50e30f97116abbc4dbcf916005b98aa087d8ba Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Sun, 26 Aug 2018 17:24:46 -0400 Subject: [PATCH] WIP: Remove the 'dns' options from libvirt This will allow the libvirt nodes to use the hypervisor's DNS instead of having to hard code some upstream DNS server. Previously this was a problem if your local machine pointed to the libvirt dnsmasq for DNS resolution of the nodes. Any unknown address would cause an inifnite loop. Now, the libvirt dnsmasq will respond that the name is unknown instead of forwarding it to the hypervisor's DNS server. Since i can't see a reason for the DNS option, I take it out. Now it 'just works'. --- installer/pkg/config/cluster.go | 3 +- installer/pkg/config/libvirt/libvirt.go | 9 ++--- installer/pkg/config/validate.go | 3 -- installer/pkg/config/validate_test.go | 35 ++++++++----------- .../pkg/workflow/fixtures/terraform.tfvars | 1 - steps/topology/libvirt/main.tf | 10 +++--- steps/variables-libvirt.tf | 5 --- 7 files changed, 25 insertions(+), 41 deletions(-) diff --git a/installer/pkg/config/cluster.go b/installer/pkg/config/cluster.go index 27ce4d0412f..cfa2edb455a 100644 --- a/installer/pkg/config/cluster.go +++ b/installer/pkg/config/cluster.go @@ -60,8 +60,7 @@ var defaultCluster = Cluster{ }, Libvirt: libvirt.Libvirt{ Network: libvirt.Network{ - DNSServer: libvirt.DefaultDNSServer, - IfName: libvirt.DefaultIfName, + IfName: libvirt.DefaultIfName, }, }, Networking: Networking{ diff --git a/installer/pkg/config/libvirt/libvirt.go b/installer/pkg/config/libvirt/libvirt.go index 5012816264e..ab1b6233f1b 100644 --- a/installer/pkg/config/libvirt/libvirt.go +++ b/installer/pkg/config/libvirt/libvirt.go @@ -8,8 +8,6 @@ import ( ) const ( - // DefaultDNSServer is the default DNS server for libvirt. - DefaultDNSServer = "8.8.8.8" // DefaultIfName is the default interface name for libvirt. DefaultIfName = "osbr0" ) @@ -26,10 +24,9 @@ type Libvirt struct { // Network describes a libvirt network configuration. type Network struct { - Name string `json:"tectonic_libvirt_network_name,omitempty" yaml:"name"` - IfName string `json:"tectonic_libvirt_network_if,omitempty" yaml:"ifName"` - DNSServer string `json:"tectonic_libvirt_resolver,omitempty" yaml:"dnsServer"` - IPRange string `json:"tectonic_libvirt_ip_range,omitempty" yaml:"ipRange"` + Name string `json:"tectonic_libvirt_network_name,omitempty" yaml:"name"` + IfName string `json:"tectonic_libvirt_network_if,omitempty" yaml:"ifName"` + IPRange string `json:"tectonic_libvirt_ip_range,omitempty" yaml:"ipRange"` } // TFVars fills in computed Terraform variables. diff --git a/installer/pkg/config/validate.go b/installer/pkg/config/validate.go index 069a3acc1fc..6b1ee37a985 100644 --- a/installer/pkg/config/validate.go +++ b/installer/pkg/config/validate.go @@ -189,9 +189,6 @@ func (c *Cluster) validateLibvirt() []error { if err := validate.PrefixError("libvirt network ifName", validate.NonEmpty(c.Libvirt.Network.IfName)); err != nil { errs = append(errs, err) } - if err := validate.PrefixError("libvirt network dnsServer", validate.IPv4(c.Libvirt.Network.DNSServer)); err != nil { - errs = append(errs, err) - } errs = append(errs, c.validateOverlapWithPodOrServiceCIDR(c.Libvirt.Network.IPRange, "libvirt ipRange")...) return errs } diff --git a/installer/pkg/config/validate_test.go b/installer/pkg/config/validate_test.go index 42350a70663..47a56346428 100644 --- a/installer/pkg/config/validate_test.go +++ b/installer/pkg/config/validate_test.go @@ -574,10 +574,9 @@ func TestValidateLibvirt(t *testing.T) { cluster: Cluster{ Libvirt: libvirt.Libvirt{ Network: libvirt.Network{ - Name: "tectonic", - IfName: libvirt.DefaultIfName, - DNSServer: libvirt.DefaultDNSServer, - IPRange: "10.0.1.0/24", + Name: "tectonic", + IfName: libvirt.DefaultIfName, + IPRange: "10.0.1.0/24", }, QCOWImagePath: fInvalid.Name(), URI: "baz", @@ -590,10 +589,9 @@ func TestValidateLibvirt(t *testing.T) { cluster: Cluster{ Libvirt: libvirt.Libvirt{ Network: libvirt.Network{ - Name: "tectonic", - IfName: libvirt.DefaultIfName, - DNSServer: libvirt.DefaultDNSServer, - IPRange: "10.0.1.0/24", + Name: "tectonic", + IfName: libvirt.DefaultIfName, + IPRange: "10.0.1.0/24", }, QCOWImagePath: fValid.Name(), URI: "baz", @@ -606,10 +604,9 @@ func TestValidateLibvirt(t *testing.T) { cluster: Cluster{ Libvirt: libvirt.Libvirt{ Network: libvirt.Network{ - Name: "tectonic", - IfName: libvirt.DefaultIfName, - DNSServer: libvirt.DefaultDNSServer, - IPRange: "10.2.1.0/24", + Name: "tectonic", + IfName: libvirt.DefaultIfName, + IPRange: "10.2.1.0/24", }, QCOWImagePath: fValid.Name(), URI: "baz", @@ -622,10 +619,9 @@ func TestValidateLibvirt(t *testing.T) { cluster: Cluster{ Libvirt: libvirt.Libvirt{ Network: libvirt.Network{ - Name: "tectonic", - IfName: libvirt.DefaultIfName, - DNSServer: libvirt.DefaultDNSServer, - IPRange: "x", + Name: "tectonic", + IfName: libvirt.DefaultIfName, + IPRange: "x", }, QCOWImagePath: "foo", URI: "baz", @@ -638,10 +634,9 @@ func TestValidateLibvirt(t *testing.T) { cluster: Cluster{ Libvirt: libvirt.Libvirt{ Network: libvirt.Network{ - Name: "tectonic", - IfName: libvirt.DefaultIfName, - DNSServer: "foo", - IPRange: "192.168.0.1/24", + Name: "tectonic", + IfName: libvirt.DefaultIfName, + IPRange: "192.168.0.1/24", }, QCOWImagePath: "foo", URI: "baz", diff --git a/installer/pkg/workflow/fixtures/terraform.tfvars b/installer/pkg/workflow/fixtures/terraform.tfvars index e87d24cfcec..89f0ba6f33a 100644 --- a/installer/pkg/workflow/fixtures/terraform.tfvars +++ b/installer/pkg/workflow/fixtures/terraform.tfvars @@ -22,7 +22,6 @@ ], "tectonic_ignition_worker": "worker.ign", "tectonic_libvirt_network_if": "osbr0", - "tectonic_libvirt_resolver": "8.8.8.8", "tectonic_master_count": 2, "tectonic_cluster_name": "aws-basic", "tectonic_networking": "canal", diff --git a/steps/topology/libvirt/main.tf b/steps/topology/libvirt/main.tf index dc18a26b408..5f894554a80 100644 --- a/steps/topology/libvirt/main.tf +++ b/steps/topology/libvirt/main.tf @@ -15,10 +15,6 @@ resource "libvirt_network" "tectonic_net" { "${var.tectonic_libvirt_ip_range}", ] - dns_forwarder { - address = "${var.tectonic_libvirt_resolver}" - } - dns_host = ["${flatten(list( data.libvirt_network_dns_host_template.bootstrap.*.rendered, data.libvirt_network_dns_host_template.masters.*.rendered, @@ -26,6 +22,12 @@ resource "libvirt_network" "tectonic_net" { data.libvirt_network_dns_host_template.workers.*.rendered, ))}"] + dns = [ + { + local_only = true + }, + ] + autostart = true } diff --git a/steps/variables-libvirt.tf b/steps/variables-libvirt.tf index 673b7af7f2a..a1839d2cd83 100644 --- a/steps/variables-libvirt.tf +++ b/steps/variables-libvirt.tf @@ -18,11 +18,6 @@ variable "tectonic_libvirt_ip_range" { description = "IP range for the libvirt machines" } -variable "tectonic_libvirt_resolver" { - type = "string" - description = "the upstream dns resolver" -} - variable "tectonic_coreos_qcow_path" { type = "string" description = "path to a container linux qcow image"