mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 15:05:20 +00:00
Migrate cmd/kube-proxy to contextual logging (#122197)
* cmd/kube-proxy support contextual logging Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com> * use ktesting.NewTestContext(t) in unit test Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com> * use ktesting.NewTestContext(t) in unit test Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com> * remove unnecessary blank line & add cmd/kube-proxy to contextual section in logcheck.conf Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com> * add more contextual logging Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com> * new lint yaml Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com> --------- Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
This commit is contained in:
@@ -38,6 +38,7 @@ import (
|
||||
componentbaseconfig "k8s.io/component-base/config"
|
||||
logsapi "k8s.io/component-base/logs/api/v1"
|
||||
kubeproxyconfig "k8s.io/kubernetes/pkg/proxy/apis/config"
|
||||
"k8s.io/kubernetes/test/utils/ktesting"
|
||||
netutils "k8s.io/utils/net"
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
@@ -646,7 +647,8 @@ func Test_getNodeIPs(t *testing.T) {
|
||||
nodeName := fmt.Sprintf("node%d", i+1)
|
||||
expectIP := fmt.Sprintf("192.168.0.%d", i+1)
|
||||
go func() {
|
||||
ips := getNodeIPs(client, nodeName)
|
||||
logger, _ := ktesting.NewTestContext(t)
|
||||
ips := getNodeIPs(logger, client, nodeName)
|
||||
if len(ips) == 0 {
|
||||
ch <- fmt.Errorf("expected IP %s for %s but got nil", expectIP, nodeName)
|
||||
} else if ips[0].String() != expectIP {
|
||||
@@ -825,7 +827,8 @@ func Test_detectNodeIPs(t *testing.T) {
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
primaryFamily, ips := detectNodeIPs(c.rawNodeIPs, c.bindAddress)
|
||||
logger, _ := ktesting.NewTestContext(t)
|
||||
primaryFamily, ips := detectNodeIPs(logger, c.rawNodeIPs, c.bindAddress)
|
||||
if primaryFamily != c.expectedFamily {
|
||||
t.Errorf("Expected family %q got %q", c.expectedFamily, primaryFamily)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user