bring back minor DNS cache for k8s setups (#19341)

k8s as it stands is flaky in DNS lookups,
bring this change back such that we can
cache DNS atleast for 30secs TTL.
This commit is contained in:
Harshavardhana
2024-03-26 08:00:38 -07:00
committed by GitHub
parent 4b9192034c
commit dc45a5010d
6 changed files with 28 additions and 76 deletions

View File

@@ -141,9 +141,14 @@ var ServerFlags = []cli.Flag{
},
cli.DurationFlag{
Name: "dns-cache-ttl",
Usage: "custom DNS cache TTL for baremetal setups",
Usage: "custom DNS cache TTL",
Hidden: true,
Value: 10 * time.Minute,
Value: func() time.Duration {
if orchestrated {
return 30 * time.Second
}
return 10 * time.Minute
}(),
EnvVar: "MINIO_DNS_CACHE_TTL",
},
cli.IntFlag{
@@ -593,12 +598,7 @@ func setGlobalInternodeInterface(interfaceName string) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
lookupHost := globalDNSCache.LookupHost
if IsKubernetes() || IsDocker() {
lookupHost = net.DefaultResolver.LookupHost
}
haddrs, err := lookupHost(ctx, host)
haddrs, err := globalDNSCache.LookupHost(ctx, host)
if err == nil {
ip = haddrs[0]
}
@@ -636,12 +636,7 @@ func getServerListenAddrs() []string {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
lookupHost := globalDNSCache.LookupHost
if IsKubernetes() || IsDocker() {
lookupHost = net.DefaultResolver.LookupHost
}
haddrs, err := lookupHost(ctx, host)
haddrs, err := globalDNSCache.LookupHost(ctx, host)
if err == nil {
for _, addr := range haddrs {
addrs.Add(net.JoinHostPort(addr, globalMinioPort))