From 6163859ae8477b3c7842fc73acfc2cf94493a844 Mon Sep 17 00:00:00 2001 From: corneredrat Date: Wed, 1 Feb 2023 14:09:07 +0530 Subject: [PATCH 01/12] read node and port information from env varibles for kube* services --- pkg/healthchecker/types/types.go | 35 ++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/pkg/healthchecker/types/types.go b/pkg/healthchecker/types/types.go index 97039f03..98881acc 100644 --- a/pkg/healthchecker/types/types.go +++ b/pkg/healthchecker/types/types.go @@ -18,6 +18,7 @@ package types import ( "fmt" + "os" "sort" "strconv" "strings" @@ -38,12 +39,42 @@ const ( ContainerdService = "containerd" KubeProxyComponent = "kube-proxy" + LogPatternFlagSeparator = ":" + + nodeEnvKey = "HOST_IP" + kubeletPort = "KUBELET_PORT" + kubeProxyPort = "KUBEPROXY_PORT" +) + +var ( KubeletHealthCheckEndpoint = "http://127.0.0.1:10248/healthz" KubeProxyHealthCheckEndpoint = "http://127.0.0.1:10256/healthz" - - LogPatternFlagSeparator = ":" ) +func init() { + var o string + + hostIP := "127.0.0.1" + kubeletPort := "10248" + kubeProxyPort := "10256" + + o = os.Getenv(nodeEnvKey) + if o != "" { + hostIP = o + } + o = os.Getenv(kubeletPort) + if o != "" { + kubeletPort = o + } + o = os.Getenv(kubeProxyPort) + if o != "" { + kubeProxyPort = o + } + + KubeletHealthCheckEndpoint = fmt.Sprintf("http://%s:%s/healthz", hostIP, kubeletPort) + KubeProxyHealthCheckEndpoint = fmt.Sprintf("http://%s:%s/healthz", hostIP, kubeProxyPort) +} + type HealthChecker interface { CheckHealth() (bool, error) } From 2415e30efebfc7b4f47ab971ddaf8454c3a7b8b8 Mon Sep 17 00:00:00 2001 From: corneredrat Date: Wed, 1 Feb 2023 21:42:52 +0530 Subject: [PATCH 02/12] remove redundant initialization --- pkg/healthchecker/types/types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/healthchecker/types/types.go b/pkg/healthchecker/types/types.go index 98881acc..d470f01e 100644 --- a/pkg/healthchecker/types/types.go +++ b/pkg/healthchecker/types/types.go @@ -47,8 +47,8 @@ const ( ) var ( - KubeletHealthCheckEndpoint = "http://127.0.0.1:10248/healthz" - KubeProxyHealthCheckEndpoint = "http://127.0.0.1:10256/healthz" + KubeletHealthCheckEndpoint string + KubeProxyHealthCheckEndpoint string ) func init() { From f601956af93dd359d622c6bd4df96099c698760a Mon Sep 17 00:00:00 2001 From: corneredrat Date: Wed, 1 Feb 2023 21:43:53 +0530 Subject: [PATCH 03/12] name var for env keys appropriately --- pkg/healthchecker/types/types.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/healthchecker/types/types.go b/pkg/healthchecker/types/types.go index d470f01e..981027c4 100644 --- a/pkg/healthchecker/types/types.go +++ b/pkg/healthchecker/types/types.go @@ -41,9 +41,9 @@ const ( LogPatternFlagSeparator = ":" - nodeEnvKey = "HOST_IP" - kubeletPort = "KUBELET_PORT" - kubeProxyPort = "KUBEPROXY_PORT" + nodeEnvKey = "HOST_IP" + kubeletPortKey = "KUBELET_PORT" + kubeProxyPortKey = "KUBEPROXY_PORT" ) var ( @@ -62,11 +62,11 @@ func init() { if o != "" { hostIP = o } - o = os.Getenv(kubeletPort) + o = os.Getenv(kubeletPortKey) if o != "" { kubeletPort = o } - o = os.Getenv(kubeProxyPort) + o = os.Getenv(kubeProxyPortKey) if o != "" { kubeProxyPort = o } From 92e63b59916a80c98cfa1d7c076c2c2ecf4c3b78 Mon Sep 17 00:00:00 2001 From: corneredrat Date: Sat, 4 Feb 2023 21:14:20 +0530 Subject: [PATCH 04/12] move node endpoints initialization to separate section --- pkg/healthchecker/types/types.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/healthchecker/types/types.go b/pkg/healthchecker/types/types.go index 981027c4..a59ae08f 100644 --- a/pkg/healthchecker/types/types.go +++ b/pkg/healthchecker/types/types.go @@ -52,6 +52,10 @@ var ( ) func init() { + setKubeEndpoints() +} + +func setKubeEndpoints() { var o string hostIP := "127.0.0.1" @@ -73,6 +77,7 @@ func init() { KubeletHealthCheckEndpoint = fmt.Sprintf("http://%s:%s/healthz", hostIP, kubeletPort) KubeProxyHealthCheckEndpoint = fmt.Sprintf("http://%s:%s/healthz", hostIP, kubeProxyPort) + } type HealthChecker interface { From 83e520784bf5455e658bd514b3a0e29750d203a1 Mon Sep 17 00:00:00 2001 From: corneredrat Date: Sat, 4 Feb 2023 22:48:49 +0530 Subject: [PATCH 05/12] use consts --- pkg/healthchecker/types/types.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/healthchecker/types/types.go b/pkg/healthchecker/types/types.go index a59ae08f..38f4536a 100644 --- a/pkg/healthchecker/types/types.go +++ b/pkg/healthchecker/types/types.go @@ -44,6 +44,10 @@ const ( nodeEnvKey = "HOST_IP" kubeletPortKey = "KUBELET_PORT" kubeProxyPortKey = "KUBEPROXY_PORT" + + defaultHostIP = "127.0.0.1" + defaultKubeletPort = "10248" + defaultKubeproxyPort = "10256" ) var ( @@ -58,9 +62,9 @@ func init() { func setKubeEndpoints() { var o string - hostIP := "127.0.0.1" - kubeletPort := "10248" - kubeProxyPort := "10256" + hostIP := defaultHostIP + kubeletPort := defaultKubeletPort + kubeProxyPort := defaultKubeproxyPort o = os.Getenv(nodeEnvKey) if o != "" { From a117c0c05695898342272d6b22e4e2aae150e4d7 Mon Sep 17 00:00:00 2001 From: corneredrat Date: Thu, 9 Feb 2023 15:02:52 +0530 Subject: [PATCH 06/12] 1. make vars private 2. expose endpoints via functions 3. add test cases 4. rename host addr var --- pkg/healthchecker/health_checker.go | 4 +- pkg/healthchecker/types/types.go | 30 ++++++---- pkg/healthchecker/types/types_test.go | 79 +++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 14 deletions(-) diff --git a/pkg/healthchecker/health_checker.go b/pkg/healthchecker/health_checker.go index c1ff2bda..06d94108 100644 --- a/pkg/healthchecker/health_checker.go +++ b/pkg/healthchecker/health_checker.go @@ -138,9 +138,9 @@ func healthCheckEndpointOKFunc(endpoint string, timeout time.Duration) func() (b func getHealthCheckFunc(hco *options.HealthCheckerOptions) func() (bool, error) { switch hco.Component { case types.KubeletComponent: - return healthCheckEndpointOKFunc(types.KubeletHealthCheckEndpoint, hco.HealthCheckTimeout) + return healthCheckEndpointOKFunc(types.KubeletHealthCheckEndpoint(), hco.HealthCheckTimeout) case types.KubeProxyComponent: - return healthCheckEndpointOKFunc(types.KubeProxyHealthCheckEndpoint, hco.HealthCheckTimeout) + return healthCheckEndpointOKFunc(types.KubeProxyHealthCheckEndpoint(), hco.HealthCheckTimeout) case types.DockerComponent: return func() (bool, error) { if _, err := execCommand(hco.HealthCheckTimeout, getDockerPath(), "ps"); err != nil { diff --git a/pkg/healthchecker/types/types.go b/pkg/healthchecker/types/types.go index 38f4536a..f17af30b 100644 --- a/pkg/healthchecker/types/types.go +++ b/pkg/healthchecker/types/types.go @@ -40,19 +40,18 @@ const ( KubeProxyComponent = "kube-proxy" LogPatternFlagSeparator = ":" + hostAddressKey = "HOST_ADDRESS" + kubeletPortKey = "KUBELET_PORT" + kubeProxyPortKey = "KUBEPROXY_PORT" - nodeEnvKey = "HOST_IP" - kubeletPortKey = "KUBELET_PORT" - kubeProxyPortKey = "KUBEPROXY_PORT" - - defaultHostIP = "127.0.0.1" + defaultHost = "127.0.0.1" defaultKubeletPort = "10248" defaultKubeproxyPort = "10256" ) var ( - KubeletHealthCheckEndpoint string - KubeProxyHealthCheckEndpoint string + kubeletHealthCheckEndpoint string + kubeProxyHealthCheckEndpoint string ) func init() { @@ -62,13 +61,13 @@ func init() { func setKubeEndpoints() { var o string - hostIP := defaultHostIP + hostAddress := defaultHost kubeletPort := defaultKubeletPort kubeProxyPort := defaultKubeproxyPort - o = os.Getenv(nodeEnvKey) + o = os.Getenv(hostAddressKey) if o != "" { - hostIP = o + hostAddress = o } o = os.Getenv(kubeletPortKey) if o != "" { @@ -79,11 +78,18 @@ func setKubeEndpoints() { kubeProxyPort = o } - KubeletHealthCheckEndpoint = fmt.Sprintf("http://%s:%s/healthz", hostIP, kubeletPort) - KubeProxyHealthCheckEndpoint = fmt.Sprintf("http://%s:%s/healthz", hostIP, kubeProxyPort) + kubeletHealthCheckEndpoint = fmt.Sprintf("http://%s:%s/healthz", hostAddress, kubeletPort) + kubeProxyHealthCheckEndpoint = fmt.Sprintf("http://%s:%s/healthz", hostAddress, kubeProxyPort) } +func KubeProxyHealthCheckEndpoint() string { + return kubeProxyHealthCheckEndpoint +} +func KubeletHealthCheckEndpoint() string { + return kubeletHealthCheckEndpoint +} + type HealthChecker interface { CheckHealth() (bool, error) } diff --git a/pkg/healthchecker/types/types_test.go b/pkg/healthchecker/types/types_test.go index b5da17f5..36e35872 100644 --- a/pkg/healthchecker/types/types_test.go +++ b/pkg/healthchecker/types/types_test.go @@ -98,3 +98,82 @@ func TestLogPatternFlag(t *testing.T) { }) } } + +func TestKubeEndpointConfiguration(t *testing.T) { + testCases := []struct { + name string + envConfig map[string]string + expectedKubeletEndpoint string + expectedKubeProxyEndpoint string + }{ + { + name: "no overrides supplied", + envConfig: map[string]string{}, + expectedKubeletEndpoint: "127.0.0.1:10248", + expectedKubeProxyEndpoint: "127.0.0.1:10256", + }, { + name: "HOST_ADDRESS override supplied", + envConfig: map[string]string{ + "HOST_ADDRESS": "samplehost.testdomain.com", + }, + expectedKubeletEndpoint: "samplehost.testdomain.com:10248", + expectedKubeProxyEndpoint: "samplehost.testdomain.com:10256", + }, + { + name: "KUBELET_PORT override supplied", + envConfig: map[string]string{ + "KUBELET_PORT": "12345", + }, + expectedKubeletEndpoint: "127.0.0.1:12345", + expectedKubeProxyEndpoint: "127.0.0.1:10256", + }, + { + name: "KUBEPROXY_PORT override supplied", + envConfig: map[string]string{ + "KUBEPROXY_PORT": "12345", + }, + expectedKubeletEndpoint: "127.0.0.1:10248", + expectedKubeProxyEndpoint: "127.0.0.1:12345", + }, + { + name: "HOST_ADDRESS and KUBELET_PORT override supplied", + envConfig: map[string]string{ + "HOST_ADDRESS": "samplehost.testdomain.com", + "KUBELET_PORT": "12345", + }, + expectedKubeletEndpoint: "samplehost.testdomain.com:12345", + expectedKubeProxyEndpoint: "samplehost.testdomain.com:10256", + }, + { + name: "HOST_ADDRESS and KUBEPROXY_PORT override supplied", + envConfig: map[string]string{ + "HOST_ADDRESS": "samplehost.testdomain.com", + "KUBEPROXY_PORT": "12345", + }, + expectedKubeletEndpoint: "samplehost.testdomain.com:10248", + expectedKubeProxyEndpoint: "samplehost.testdomain.com:12345", + }, + { + name: "HOST_ADDRESS, KUBELET_PORT and KUBEPROXY_PORT override supplied", + envConfig: map[string]string{ + "HOST_ADDRESS": "10.0.10.1", + "KUBELET_PROXY": "12345", + "KUBEPROXY_PORT": "12346", + }, + expectedKubeletEndpoint: "10.0.10.1:12345", + expectedKubeProxyEndpoint: "10.0.10.1:12346", + }, + } + for _, test := range testCases { + t.Run(test.name, func(t *testing.T) { + for key, val := range test.envConfig { + t.Setenv(key, val) + } + kubeProxyHCEndpoint := KubeProxyHealthCheckEndpoint() + kubeletHCEndpoint := KubeletHealthCheckEndpoint() + + assert.Equal(t, kubeProxyHCEndpoint, test.expectedKubeProxyEndpoint) + assert.Equal(t, kubeletHCEndpoint, test.expectedKubeletEndpoint) + }) + } +} From d88e0dda0239ddfdbc3a8a8b6c6fe40efc804221 Mon Sep 17 00:00:00 2001 From: corneredrat Date: Thu, 9 Feb 2023 15:58:06 +0530 Subject: [PATCH 07/12] fix test for kube endpoints --- pkg/healthchecker/types/types_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/healthchecker/types/types_test.go b/pkg/healthchecker/types/types_test.go index 36e35872..9b2a6098 100644 --- a/pkg/healthchecker/types/types_test.go +++ b/pkg/healthchecker/types/types_test.go @@ -171,7 +171,7 @@ func TestKubeEndpointConfiguration(t *testing.T) { } kubeProxyHCEndpoint := KubeProxyHealthCheckEndpoint() kubeletHCEndpoint := KubeletHealthCheckEndpoint() - + setKubeEndpoints() assert.Equal(t, kubeProxyHCEndpoint, test.expectedKubeProxyEndpoint) assert.Equal(t, kubeletHCEndpoint, test.expectedKubeletEndpoint) }) From e6ab24db7f5ef6be66ea9a708b9d6c3ecd8c9617 Mon Sep 17 00:00:00 2001 From: corneredrat Date: Thu, 9 Feb 2023 21:38:31 +0530 Subject: [PATCH 08/12] update expected results --- pkg/healthchecker/types/types_test.go | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/healthchecker/types/types_test.go b/pkg/healthchecker/types/types_test.go index 9b2a6098..a9576fa3 100644 --- a/pkg/healthchecker/types/types_test.go +++ b/pkg/healthchecker/types/types_test.go @@ -109,31 +109,31 @@ func TestKubeEndpointConfiguration(t *testing.T) { { name: "no overrides supplied", envConfig: map[string]string{}, - expectedKubeletEndpoint: "127.0.0.1:10248", - expectedKubeProxyEndpoint: "127.0.0.1:10256", + expectedKubeletEndpoint: "http://127.0.0.1:10248", + expectedKubeProxyEndpoint: "http://127.0.0.1:10256", }, { name: "HOST_ADDRESS override supplied", envConfig: map[string]string{ "HOST_ADDRESS": "samplehost.testdomain.com", }, - expectedKubeletEndpoint: "samplehost.testdomain.com:10248", - expectedKubeProxyEndpoint: "samplehost.testdomain.com:10256", + expectedKubeletEndpoint: "http://samplehost.testdomain.com:10248", + expectedKubeProxyEndpoint: "http://samplehost.testdomain.com:10256", }, { name: "KUBELET_PORT override supplied", envConfig: map[string]string{ "KUBELET_PORT": "12345", }, - expectedKubeletEndpoint: "127.0.0.1:12345", - expectedKubeProxyEndpoint: "127.0.0.1:10256", + expectedKubeletEndpoint: "http://127.0.0.1:12345", + expectedKubeProxyEndpoint: "http://127.0.0.1:10256", }, { name: "KUBEPROXY_PORT override supplied", envConfig: map[string]string{ "KUBEPROXY_PORT": "12345", }, - expectedKubeletEndpoint: "127.0.0.1:10248", - expectedKubeProxyEndpoint: "127.0.0.1:12345", + expectedKubeletEndpoint: "http://127.0.0.1:10248", + expectedKubeProxyEndpoint: "http://127.0.0.1:12345", }, { name: "HOST_ADDRESS and KUBELET_PORT override supplied", @@ -141,8 +141,8 @@ func TestKubeEndpointConfiguration(t *testing.T) { "HOST_ADDRESS": "samplehost.testdomain.com", "KUBELET_PORT": "12345", }, - expectedKubeletEndpoint: "samplehost.testdomain.com:12345", - expectedKubeProxyEndpoint: "samplehost.testdomain.com:10256", + expectedKubeletEndpoint: "http://samplehost.testdomain.com:12345", + expectedKubeProxyEndpoint: "http://samplehost.testdomain.com:10256", }, { name: "HOST_ADDRESS and KUBEPROXY_PORT override supplied", @@ -150,8 +150,8 @@ func TestKubeEndpointConfiguration(t *testing.T) { "HOST_ADDRESS": "samplehost.testdomain.com", "KUBEPROXY_PORT": "12345", }, - expectedKubeletEndpoint: "samplehost.testdomain.com:10248", - expectedKubeProxyEndpoint: "samplehost.testdomain.com:12345", + expectedKubeletEndpoint: "http://samplehost.testdomain.com:10248", + expectedKubeProxyEndpoint: "http://samplehost.testdomain.com:12345", }, { name: "HOST_ADDRESS, KUBELET_PORT and KUBEPROXY_PORT override supplied", @@ -160,8 +160,8 @@ func TestKubeEndpointConfiguration(t *testing.T) { "KUBELET_PROXY": "12345", "KUBEPROXY_PORT": "12346", }, - expectedKubeletEndpoint: "10.0.10.1:12345", - expectedKubeProxyEndpoint: "10.0.10.1:12346", + expectedKubeletEndpoint: "http://10.0.10.1:12345", + expectedKubeProxyEndpoint: "http://10.0.10.1:12346", }, } for _, test := range testCases { From 07317328f14eaf526a706f06943a2038cf8baa18 Mon Sep 17 00:00:00 2001 From: corneredrat Date: Thu, 9 Feb 2023 21:59:47 +0530 Subject: [PATCH 09/12] update expected results --- pkg/healthchecker/types/types_test.go | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/healthchecker/types/types_test.go b/pkg/healthchecker/types/types_test.go index a9576fa3..eb77d05c 100644 --- a/pkg/healthchecker/types/types_test.go +++ b/pkg/healthchecker/types/types_test.go @@ -109,31 +109,31 @@ func TestKubeEndpointConfiguration(t *testing.T) { { name: "no overrides supplied", envConfig: map[string]string{}, - expectedKubeletEndpoint: "http://127.0.0.1:10248", - expectedKubeProxyEndpoint: "http://127.0.0.1:10256", + expectedKubeletEndpoint: "http://127.0.0.1:10248/healthz", + expectedKubeProxyEndpoint: "http://127.0.0.1:10256/healthz", }, { name: "HOST_ADDRESS override supplied", envConfig: map[string]string{ "HOST_ADDRESS": "samplehost.testdomain.com", }, - expectedKubeletEndpoint: "http://samplehost.testdomain.com:10248", - expectedKubeProxyEndpoint: "http://samplehost.testdomain.com:10256", + expectedKubeletEndpoint: "http://samplehost.testdomain.com:10248/healthz", + expectedKubeProxyEndpoint: "http://samplehost.testdomain.com:10256/healthz", }, { name: "KUBELET_PORT override supplied", envConfig: map[string]string{ "KUBELET_PORT": "12345", }, - expectedKubeletEndpoint: "http://127.0.0.1:12345", - expectedKubeProxyEndpoint: "http://127.0.0.1:10256", + expectedKubeletEndpoint: "http://127.0.0.1:12345/healthz", + expectedKubeProxyEndpoint: "http://127.0.0.1:10256/healthz", }, { name: "KUBEPROXY_PORT override supplied", envConfig: map[string]string{ "KUBEPROXY_PORT": "12345", }, - expectedKubeletEndpoint: "http://127.0.0.1:10248", - expectedKubeProxyEndpoint: "http://127.0.0.1:12345", + expectedKubeletEndpoint: "http://127.0.0.1:10248/healthz", + expectedKubeProxyEndpoint: "http://127.0.0.1:12345/healthz", }, { name: "HOST_ADDRESS and KUBELET_PORT override supplied", @@ -141,8 +141,8 @@ func TestKubeEndpointConfiguration(t *testing.T) { "HOST_ADDRESS": "samplehost.testdomain.com", "KUBELET_PORT": "12345", }, - expectedKubeletEndpoint: "http://samplehost.testdomain.com:12345", - expectedKubeProxyEndpoint: "http://samplehost.testdomain.com:10256", + expectedKubeletEndpoint: "http://samplehost.testdomain.com:12345/healthz", + expectedKubeProxyEndpoint: "http://samplehost.testdomain.com:10256/healthz", }, { name: "HOST_ADDRESS and KUBEPROXY_PORT override supplied", @@ -150,8 +150,8 @@ func TestKubeEndpointConfiguration(t *testing.T) { "HOST_ADDRESS": "samplehost.testdomain.com", "KUBEPROXY_PORT": "12345", }, - expectedKubeletEndpoint: "http://samplehost.testdomain.com:10248", - expectedKubeProxyEndpoint: "http://samplehost.testdomain.com:12345", + expectedKubeletEndpoint: "http://samplehost.testdomain.com:10248/healthz", + expectedKubeProxyEndpoint: "http://samplehost.testdomain.com:12345/healthz", }, { name: "HOST_ADDRESS, KUBELET_PORT and KUBEPROXY_PORT override supplied", @@ -160,8 +160,8 @@ func TestKubeEndpointConfiguration(t *testing.T) { "KUBELET_PROXY": "12345", "KUBEPROXY_PORT": "12346", }, - expectedKubeletEndpoint: "http://10.0.10.1:12345", - expectedKubeProxyEndpoint: "http://10.0.10.1:12346", + expectedKubeletEndpoint: "http://10.0.10.1:12345/healthz", + expectedKubeProxyEndpoint: "http://10.0.10.1:12346/healthz", }, } for _, test := range testCases { From 429777eb5d67e4c156104ac80cb88fcb1544830a Mon Sep 17 00:00:00 2001 From: corneredrat Date: Thu, 9 Feb 2023 22:14:40 +0530 Subject: [PATCH 10/12] fux unit tests --- pkg/healthchecker/types/types_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/healthchecker/types/types_test.go b/pkg/healthchecker/types/types_test.go index eb77d05c..d8c9b1a1 100644 --- a/pkg/healthchecker/types/types_test.go +++ b/pkg/healthchecker/types/types_test.go @@ -169,9 +169,11 @@ func TestKubeEndpointConfiguration(t *testing.T) { for key, val := range test.envConfig { t.Setenv(key, val) } + setKubeEndpoints() + kubeProxyHCEndpoint := KubeProxyHealthCheckEndpoint() kubeletHCEndpoint := KubeletHealthCheckEndpoint() - setKubeEndpoints() + assert.Equal(t, kubeProxyHCEndpoint, test.expectedKubeProxyEndpoint) assert.Equal(t, kubeletHCEndpoint, test.expectedKubeletEndpoint) }) From 2e0ff3d14c875bd6538b498825738732a14e2c4a Mon Sep 17 00:00:00 2001 From: corneredrat Date: Thu, 9 Feb 2023 23:10:38 +0530 Subject: [PATCH 11/12] fix unit tests --- pkg/healthchecker/types/types_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/healthchecker/types/types_test.go b/pkg/healthchecker/types/types_test.go index d8c9b1a1..007f79c5 100644 --- a/pkg/healthchecker/types/types_test.go +++ b/pkg/healthchecker/types/types_test.go @@ -157,7 +157,7 @@ func TestKubeEndpointConfiguration(t *testing.T) { name: "HOST_ADDRESS, KUBELET_PORT and KUBEPROXY_PORT override supplied", envConfig: map[string]string{ "HOST_ADDRESS": "10.0.10.1", - "KUBELET_PROXY": "12345", + "KUBELET_PORT": "12345", "KUBEPROXY_PORT": "12346", }, expectedKubeletEndpoint: "http://10.0.10.1:12345/healthz", From 706bf35086e5a2a8f6a35da281131ad07647f5db Mon Sep 17 00:00:00 2001 From: corneredrat Date: Thu, 9 Feb 2023 23:22:55 +0530 Subject: [PATCH 12/12] update defaultHost var name --- pkg/healthchecker/types/types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/healthchecker/types/types.go b/pkg/healthchecker/types/types.go index f17af30b..e7e7266c 100644 --- a/pkg/healthchecker/types/types.go +++ b/pkg/healthchecker/types/types.go @@ -44,7 +44,7 @@ const ( kubeletPortKey = "KUBELET_PORT" kubeProxyPortKey = "KUBEPROXY_PORT" - defaultHost = "127.0.0.1" + defaultHostAddress = "127.0.0.1" defaultKubeletPort = "10248" defaultKubeproxyPort = "10256" ) @@ -61,7 +61,7 @@ func init() { func setKubeEndpoints() { var o string - hostAddress := defaultHost + hostAddress := defaultHostAddress kubeletPort := defaultKubeletPort kubeProxyPort := defaultKubeproxyPort