Skip to content

Commit

Permalink
Removing cloud services
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Schendel <[email protected]>
  • Loading branch information
amitschendel committed Dec 2, 2024
1 parent 15a1696 commit cb0e462
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions pkg/dnsmanager/dns_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ type cacheEntry struct {
}

const (
defaultPositiveTTL = 1 * time.Minute // Default TTL for successful lookups
defaultNegativeTTL = 5 * time.Second // Default TTL for failed lookups
defaultPositiveTTL = 1 * time.Minute // Default TTL for successful lookups
defaultNegativeTTL = 5 * time.Second // Default TTL for failed lookups
maxServiceCacheSize = 50 // Maximum number of cloud services to cache per container
)

var _ DNSManagerClient = (*DNSManager)(nil)
Expand All @@ -52,7 +53,10 @@ func (dm *DNSManager) ContainerCallback(notif containercollection.PubSubEvent) {
func (dm *DNSManager) ReportEvent(dnsEvent tracerdnstype.Event) {
if isCloudService(dnsEvent.DNSName) {
if dm.containerToCloudServices.Has(dnsEvent.Runtime.ContainerID) {
dm.containerToCloudServices.Get(dnsEvent.Runtime.ContainerID).Add(dnsEvent.DNSName)
// Guard against cache size getting too large by checking the cardinality per container
if dm.containerToCloudServices.Get(dnsEvent.Runtime.ContainerID).Cardinality() < maxServiceCacheSize {
dm.containerToCloudServices.Get(dnsEvent.Runtime.ContainerID).Add(dnsEvent.DNSName)
}
}
}

Expand Down Expand Up @@ -141,19 +145,9 @@ func isCloudService(domain string) bool {
"run.app.",
}

// Check for other common cloud providers
otherCloudDomains := []string{
"herokuapps.com.",
"digitaloceanspaces.com.",
"cloudflare.com.",
"vercel.app.",
"netlify.app.",
}

// Combine all cloud domains
allCloudDomains := append(awsDomains, azureDomains...)
allCloudDomains = append(allCloudDomains, gcpDomains...)
allCloudDomains = append(allCloudDomains, otherCloudDomains...)

// Check if the input domain ends with any of the cloud domains
for _, cloudDomain := range allCloudDomains {
Expand Down

0 comments on commit cb0e462

Please sign in to comment.