From 8053f58f90b7e404dde87612668adbb7f9b11ed9 Mon Sep 17 00:00:00 2001 From: arkadeepsen Date: Wed, 5 Jun 2024 12:10:15 +0530 Subject: [PATCH] Bump version of DNSNameResolver controller --- go.mod | 2 +- go.sum | 4 +-- .../controller/dnsnameresolver/resolver.go | 36 ++++++++++++------- vendor/modules.txt | 2 +- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 4e49d6c1..df6cd3f3 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/openshift/api v0.0.0-20240510053056-88a8afea030c github.com/openshift/build-machinery-go v0.0.0-20220913142420-e25cf57ea46d github.com/openshift/client-go v0.0.0-20231024221206-506d798bc61c - github.com/openshift/coredns-ocp-dnsnameresolver/operator v0.0.0-20240514135022-c41cdd134379 + github.com/openshift/coredns-ocp-dnsnameresolver/operator v0.0.0-20240712094134-af651cec05d1 github.com/openshift/library-go v0.0.0-20231102154438-cfcf2b4fbc87 github.com/sirupsen/logrus v1.9.0 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 90aa4af4..c9bab30f 100644 --- a/go.sum +++ b/go.sum @@ -92,8 +92,8 @@ github.com/openshift/build-machinery-go v0.0.0-20220913142420-e25cf57ea46d h1:RR github.com/openshift/build-machinery-go v0.0.0-20220913142420-e25cf57ea46d/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE= github.com/openshift/client-go v0.0.0-20231024221206-506d798bc61c h1:xfag+wccUqc9EdrWsnprD6x5KG2WE+iKGFfFELCwwRA= github.com/openshift/client-go v0.0.0-20231024221206-506d798bc61c/go.mod h1:3BkYp+FtKD2TypMD0nTPkVsxUaY4fJPLEMFMlOLtrJM= -github.com/openshift/coredns-ocp-dnsnameresolver/operator v0.0.0-20240514135022-c41cdd134379 h1:aJcP4gqTC2vLW6c/ZktcAIjzm31unnCRTNi2VZkLDIU= -github.com/openshift/coredns-ocp-dnsnameresolver/operator v0.0.0-20240514135022-c41cdd134379/go.mod h1:k0W4ol96vtJ9XtOU1cLzHci9biisZf0CflX+Pj3F1V8= +github.com/openshift/coredns-ocp-dnsnameresolver/operator v0.0.0-20240712094134-af651cec05d1 h1:3R+zdOclUXVxpewmSGgAKPUNLFGRFhTpaarOxVhPkww= +github.com/openshift/coredns-ocp-dnsnameresolver/operator v0.0.0-20240712094134-af651cec05d1/go.mod h1:xr33hQoeI2qcehK9kYPm9V86CTumVN/sdDOGdxw10Xg= github.com/openshift/library-go v0.0.0-20231102154438-cfcf2b4fbc87 h1:GcaI98ric0Q3WbZsTh8cIE39pgw12v3s3xuiIFO5zQ0= github.com/openshift/library-go v0.0.0-20231102154438-cfcf2b4fbc87/go.mod h1:8UzmrBMCn7+GzouL8DVYkL9COBQTB1Ggd13/mHJQCUg= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/vendor/github.com/openshift/coredns-ocp-dnsnameresolver/operator/controller/dnsnameresolver/resolver.go b/vendor/github.com/openshift/coredns-ocp-dnsnameresolver/operator/controller/dnsnameresolver/resolver.go index 99eabf88..bb08623c 100644 --- a/vendor/github.com/openshift/coredns-ocp-dnsnameresolver/operator/controller/dnsnameresolver/resolver.go +++ b/vendor/github.com/openshift/coredns-ocp-dnsnameresolver/operator/controller/dnsnameresolver/resolver.go @@ -105,23 +105,29 @@ func (resolver *Resolver) Start() { nextDNSName, nextLookupTime, numIPs, exists = resolver.delete(deletedDNSDetails) } remainingDuration := time.Until(nextLookupTime) - if !exists || remainingDuration > defaultMaxTTL { - // If no DNS name is found OR If the remaining duration is greater than default maximum TTL, then perform DNS lookup - // after default maximum TTL. - timeTillNextLookup = defaultMaxTTL - } else if remainingDuration.Seconds() > 0 { - // If the remaining duration is positive and less than default maximum TTL, then perform DNS lookup - // after the remaining duration. - timeTillNextLookup = remainingDuration - } else { - // TTL of the DNS name has already expired, so send DNS lookup request as soon as possible. - timeTillNextLookup = 1 * time.Millisecond - } + timeTillNextLookup = getTimeTillNextLookup(exists, remainingDuration) timer.Reset(timeTillNextLookup) } }() } +// getTimeTillNextLookup returns the duration after which the next DNS lookup should be performed. +func getTimeTillNextLookup(exists bool, remainingDuration time.Duration) time.Duration { + if !exists || remainingDuration > defaultMaxTTL { + // If no DNS name is found OR If the remaining duration is greater than default maximum TTL, then perform DNS lookup + // after default maximum TTL. + return defaultMaxTTL + } else if remainingDuration.Seconds() > 0 { + // If the remaining duration is positive and less than default maximum TTL, then perform DNS lookup + // after the remaining duration. + return remainingDuration + } else { + // A DNS lookup request has been sent upon TTL expiration of the DNS name. Reset the timer to wait until twice of default + // minimum TTL to perform the next lookup. + return 2 * defaultMinTTL + } +} + // AddResolvedName is called whenever a DNSNameResolver object is added or updated. func (resolver *Resolver) AddResolvedName(dnsDetails dnsDetails) { // Send a signal to the added channel indicating that details corresponding to a DNS @@ -304,6 +310,12 @@ func (resolver *Resolver) getNextDNSNameDetails() (string, time.Time, int, bool) dns = dnsName numIPs = resolvedName.numIPs } + // If there are no IP addresses associated with the DNS name and the next lookup + // time of the DNS name is already past the current time, then reset the next + // lookup time to the default maximum TTL. + if resolvedName.numIPs == 0 && !time.Now().Before(resolvedName.minNextLookupTime) { + resolvedName.minNextLookupTime = time.Now().Add(defaultMaxTTL) + } } return dns, minNextLookupTime, numIPs, exists } diff --git a/vendor/modules.txt b/vendor/modules.txt index 45568740..ea8b060d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -212,7 +212,7 @@ github.com/openshift/client-go/config/informers/externalversions/config/v1alpha1 github.com/openshift/client-go/config/informers/externalversions/internalinterfaces github.com/openshift/client-go/config/listers/config/v1 github.com/openshift/client-go/config/listers/config/v1alpha1 -# github.com/openshift/coredns-ocp-dnsnameresolver/operator v0.0.0-20240514135022-c41cdd134379 +# github.com/openshift/coredns-ocp-dnsnameresolver/operator v0.0.0-20240712094134-af651cec05d1 ## explicit; go 1.21 github.com/openshift/coredns-ocp-dnsnameresolver/operator/controller/dnsnameresolver # github.com/openshift/library-go v0.0.0-20231102154438-cfcf2b4fbc87