mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 13:31:52 +00:00
Simplify the node name for metrics - just use localhost
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
parent
4036b6fb41
commit
931456a142
@ -40,7 +40,6 @@ import (
|
|||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
utilnet "k8s.io/apimachinery/pkg/util/net"
|
|
||||||
"k8s.io/apimachinery/pkg/util/runtime"
|
"k8s.io/apimachinery/pkg/util/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
@ -641,20 +640,5 @@ func WaitForPodInitContainerToFail(ctx context.Context, c clientset.Interface, n
|
|||||||
}
|
}
|
||||||
|
|
||||||
func nodeNameOrIP() string {
|
func nodeNameOrIP() string {
|
||||||
// Check if the node name in test context can be resolved
|
return "localhost"
|
||||||
if ips, err := net.LookupIP(framework.TestContext.NodeName); err != nil {
|
|
||||||
if dnsErr, ok := err.(*net.DNSError); ok && dnsErr.IsNotFound {
|
|
||||||
// if it can't be resolved, pick a host interface
|
|
||||||
if ip, err := utilnet.ChooseHostInterface(); err == nil {
|
|
||||||
return ip.String()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if len(ips) > 0 {
|
|
||||||
// yay, node name resolved correctly, pick the first
|
|
||||||
return ips[0].String()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fallback to node name in test context
|
|
||||||
return framework.TestContext.NodeName
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user