From c9c0d5eec26a0aa596bf4a6ac69e7a939a10b405 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 17 Dec 2019 21:32:45 -0800 Subject: [PATCH] Allow CNAME records when specified as MINIO_PUBLIC_IPS (#8662) This is necessary for `m3` global bucket support --- cmd/common-main.go | 1 - cmd/config/etcd/dns/etcd_dns.go | 2 ++ cmd/endpoint.go | 22 ++++++++++++++-------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/cmd/common-main.go b/cmd/common-main.go index c78421cbd..23f890193 100644 --- a/cmd/common-main.go +++ b/cmd/common-main.go @@ -188,7 +188,6 @@ func handleCommonEnvVars() { for _, addr := range addrs { domainIPs.Add(addr) } - continue } domainIPs.Add(endpoint) } diff --git a/cmd/config/etcd/dns/etcd_dns.go b/cmd/config/etcd/dns/etcd_dns.go index 610ed3261..ba0f6b0e9 100644 --- a/cmd/config/etcd/dns/etcd_dns.go +++ b/cmd/config/etcd/dns/etcd_dns.go @@ -154,6 +154,8 @@ func (c *CoreDNS) list(key string) ([]SrvRecord, error) { // Put - Adds DNS entries into etcd endpoint in CoreDNS etcd message format. func (c *CoreDNS) Put(bucket string) error { + c.Delete(bucket) // delete any existing entries. + for ip := range c.domainIPs { bucketMsg, err := newCoreDNSMsg(ip, c.domainPort, defaultTTL) if err != nil { diff --git a/cmd/endpoint.go b/cmd/endpoint.go index be635a718..dd6d82367 100644 --- a/cmd/endpoint.go +++ b/cmd/endpoint.go @@ -694,17 +694,23 @@ func updateDomainIPs(endPoints set.StringSet) { continue } } - IPs, err := getHostIP(host) - if err != nil { - continue - } - IPsWithPort := IPs.ApplyFunc(func(ip string) string { - return net.JoinHostPort(ip, port) - }) + if net.ParseIP(host) == nil { + IPs, err := getHostIP(host) + if err != nil { + continue + } + + IPsWithPort := IPs.ApplyFunc(func(ip string) string { + return net.JoinHostPort(ip, port) + }) - ipList = ipList.Union(IPsWithPort) + ipList = ipList.Union(IPsWithPort) + } + + ipList.Add(net.JoinHostPort(host, port)) } + globalDomainIPs = ipList.FuncMatch(func(ip string, matchString string) bool { host, _, err := net.SplitHostPort(ip) if err != nil {