Skip to content

Commit 86af906

Browse files
committed
Revert "remove leftoever impossible to reach kubelet logs due to getHostAliases"
This reverts commit 66c4f62.
1 parent 66c4f62 commit 86af906

3 files changed

Lines changed: 0 additions & 69 deletions

File tree

pkg/util/cloudproviders/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ go_library(
1010
importpath = "github.com/DataDog/datadog-agent/pkg/util/cloudproviders",
1111
visibility = ["//visibility:public"],
1212
deps = [
13-
"//pkg/config/helper",
1413
"//pkg/config/setup",
1514
"//pkg/util/cloudproviders/alibaba",
1615
"//pkg/util/cloudproviders/azure",

pkg/util/cloudproviders/cloudproviders.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"sync"
1313
"time"
1414

15-
"github.com/DataDog/datadog-agent/pkg/config/helper"
1615
configsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
1716
"github.com/DataDog/datadog-agent/pkg/util/hostname/validate"
1817
"github.com/DataDog/datadog-agent/pkg/util/kubelet"
@@ -135,34 +134,16 @@ var (
135134
hostAliasLogOnce = true
136135
)
137136

138-
// kubeletDependentHostAliasDetectors are the host-alias detectors that route through
139-
// the shared kubelet client singleton. Cluster Checks Runners are Deployment
140-
// replicas, not DaemonSets, so they are never colocated with a node's kubelet and can
141-
// never reach it.
142-
var kubeletDependentHostAliasDetectors = map[string]bool{
143-
"kubelet": true,
144-
kubernetes.CloudProviderName: true,
145-
}
146-
147137
// GetHostAliases returns the hostname aliases and the name of the possible cloud providers
148138
func GetHostAliases(ctx context.Context) ([]string, string) {
149139
aliases := []string{}
150140
cloudprovider := ""
151-
isCLCRunner := helper.IsCLCRunner(configsetup.Datadog())
152141

153142
// cloud providers endpoints can take a few seconds to answer. We're using a WaitGroup to call all of them
154143
// concurrently since GetHostAliases is called during the agent startup and is blocking.
155144
var wg sync.WaitGroup
156145

157146
for _, hostAliasesDetector := range hostAliasesDetectors {
158-
if isCLCRunner && kubeletDependentHostAliasDetectors[hostAliasesDetector.name] {
159-
// Skip probing the kubelet client singleton: it can never succeed on a
160-
// CCR and would otherwise trigger its exponential-backoff retrier and
161-
// its "Impossible to reach Kubelet" warning for no benefit.
162-
log.Debugf("Skipping %s Host Alias: Agent is a Cluster Checks Runner and has no reachable local Kubelet", hostAliasesDetector.name)
163-
continue
164-
}
165-
166147
wg.Add(1)
167148
go func(hostAliasesDetector cloudProviderAliasesDetector) {
168149
defer wg.Done()

pkg/util/cloudproviders/cloudproviders_test.go

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -64,55 +64,6 @@ func TestCloudProviderAliases(t *testing.T) {
6464
assert.Contains(t, []string{"detector1", "detector3"}, cloudprovider)
6565
}
6666

67-
// TestCloudProviderAliasesSkipsKubeletDependentDetectorsOnCLCRunner ensures
68-
// that GetHostAliases never invokes the "kubelet" or "kubernetes" detectors
69-
// on a Cluster Checks Runner, since CCRs are Deployment replicas (not
70-
// DaemonSets) and can never reach a local kubelet.
71-
func TestCloudProviderAliasesSkipsKubeletDependentDetectorsOnCLCRunner(t *testing.T) {
72-
origDetectors := hostAliasesDetectors
73-
defer func() { hostAliasesDetectors = origDetectors }()
74-
75-
config := configmock.New(t)
76-
config.SetInTest("clc_runner_enabled", true)
77-
config.SetInTest("config_providers", []map[string]interface{}{{"name": "clusterchecks"}})
78-
79-
kubeletCalled := false
80-
kubernetesDetectorCalled := false
81-
otherDetectorCalled := false
82-
83-
hostAliasesDetectors = []cloudProviderAliasesDetector{
84-
{
85-
name: "kubelet",
86-
callback: func(_ context.Context) ([]string, error) {
87-
kubeletCalled = true
88-
return []string{"kubelet-alias"}, nil
89-
},
90-
},
91-
{
92-
name: "kubernetes",
93-
callback: func(_ context.Context) ([]string, error) {
94-
kubernetesDetectorCalled = true
95-
return []string{"kubernetes-alias"}, nil
96-
},
97-
},
98-
{
99-
name: "other",
100-
isCloudEnv: true,
101-
callback: func(_ context.Context) ([]string, error) {
102-
otherDetectorCalled = true
103-
return []string{"other-alias"}, nil
104-
},
105-
},
106-
}
107-
108-
aliases, cloudprovider := GetHostAliases(context.TODO())
109-
assert.False(t, kubeletCalled, "kubelet host alias detector should be skipped on a Cluster Checks Runner")
110-
assert.False(t, kubernetesDetectorCalled, "kubernetes host alias detector should be skipped on a Cluster Checks Runner")
111-
assert.True(t, otherDetectorCalled, "non-kubelet-dependent host alias detectors should still run on a Cluster Checks Runner")
112-
assert.Equal(t, []string{"other-alias"}, aliases)
113-
assert.Equal(t, "other", cloudprovider)
114-
}
115-
11667
func TestCloudProviderHostCCRID(t *testing.T) {
11768
origDetectors := hostCCRIDDetectors
11869
defer func() { hostCCRIDDetectors = origDetectors }()

0 commit comments

Comments
 (0)