From 46c38ea3bf4640924969833533f904021c93edc0 Mon Sep 17 00:00:00 2001 From: Nell Jerram Date: Mon, 26 Jun 2023 13:37:22 +0100 Subject: [PATCH] Don't keep adding same DNS server, and don't change FelixConfig when not needed --- .../installation/core_controller.go | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pkg/controller/installation/core_controller.go b/pkg/controller/installation/core_controller.go index e9a8a9c7a5..4eca9ee9e0 100644 --- a/pkg/controller/installation/core_controller.go +++ b/pkg/controller/installation/core_controller.go @@ -1663,24 +1663,29 @@ func (r *ReconcileInstallation) setDefaultsOnFelixConfiguration(install *operato dnsService := "" switch install.Spec.KubernetesProvider { case operator.ProviderOpenShift: - dnsService = "openshift-dns/dns-default" + dnsService = "k8s-service:openshift-dns/dns-default" case operator.ProviderRKE2: - dnsService = "kube-system/rke2-coredns-rke2-coredns" + dnsService = "k8s-service:kube-system/rke2-coredns-rke2-coredns" } if dnsService != "" { felixDefault := "k8s-service:kube-dns" - trustedServers := []string{"k8s-service:" + dnsService} - // Keep any other values that are already configured, excepting the kube-dns - // default. + trustedServers := []string{dnsService} + // Keep any other values that are already configured, excepting the value + // that we are setting and the kube-dns default. + existingSetting := "" if fc.Spec.DNSTrustedServers != nil { + existingSetting = strings.Join(*(fc.Spec.DNSTrustedServers), ",") for _, server := range *(fc.Spec.DNSTrustedServers) { - if server != felixDefault { + if server != felixDefault && server != dnsService { trustedServers = append(trustedServers, server) } } } - fc.Spec.DNSTrustedServers = &trustedServers - updated = true + newSetting := strings.Join(trustedServers, ",") + if newSetting != existingSetting { + fc.Spec.DNSTrustedServers = &trustedServers + updated = true + } } } return updated