From d4064867ca7cf9eb2f8978a0fc17e4bb7a4f2b30 Mon Sep 17 00:00:00 2001 From: Arnau Verdaguer Date: Mon, 11 Nov 2024 15:22:11 +0100 Subject: [PATCH] Use dns cluster info from lib common get function Openshift coreDNS creates the domain name using an string located in dnses.operator.openshift.io. This string can change in the future, calling lib-common/GetDNSClusterDomain the responsability of gathering this information correctly only falls under lib-common intead of all operators. Resolves: OSPRH-3627 Depends-on: https://github.com/openstack-k8s-operators/lib-common/pull/580 --- api/v1beta1/ovndbcluster_types.go | 4 ---- controllers/ovndbcluster_controller.go | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/api/v1beta1/ovndbcluster_types.go b/api/v1beta1/ovndbcluster_types.go index 83ef7d48..9bdb8264 100644 --- a/api/v1beta1/ovndbcluster_types.go +++ b/api/v1beta1/ovndbcluster_types.go @@ -40,10 +40,6 @@ const ( // ServiceClusterType - Constant to identify Cluster services ServiceClusterType = "cluster" - // DNSSuffix : hardcoded value on how DNSCore domain is configured - DNSSuffix = "cluster.local" - // TODO: retrieve it from environment - // Container image fall-back defaults // OVNNBContainerImage is the fall-back container image for OVNDBCluster NB diff --git a/controllers/ovndbcluster_controller.go b/controllers/ovndbcluster_controller.go index 73391632..d4e985a5 100644 --- a/controllers/ovndbcluster_controller.go +++ b/controllers/ovndbcluster_controller.go @@ -40,6 +40,7 @@ import ( infranetworkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1" "github.com/openstack-k8s-operators/lib-common/modules/common" + "github.com/openstack-k8s-operators/lib-common/modules/common/clusterdns" "github.com/openstack-k8s-operators/lib-common/modules/common/condition" "github.com/openstack-k8s-operators/lib-common/modules/common/configmap" "github.com/openstack-k8s-operators/lib-common/modules/common/env" @@ -623,7 +624,9 @@ func (r *OVNDBClusterReconciler) reconcileNormal(ctx context.Context, instance * if svc.Spec.ClusterIP == "None" || svc.Spec.Type == corev1.ServiceTypeLoadBalancer { continue } - internalDbAddress = append(internalDbAddress, fmt.Sprintf("%s:%s.%s.svc.%s:%d", scheme, svc.Name, svc.Namespace, ovnv1.DNSSuffix, svcPort)) + // TODO: Watch operator.openshift.io resource once cluster domain is customizable + clusterDomain := clusterdns.GetDNSClusterDomain() + internalDbAddress = append(internalDbAddress, fmt.Sprintf("%s:%s.%s.svc.%s:%d", scheme, svc.Name, svc.Namespace, clusterDomain, svcPort)) } // Note setting this to the singular headless service address (e.g ssl:ovsdbserver-sb...) "works" but will not