From 71204eff3d13551375ad31cd44e8ad06ae0c087e Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Sat, 31 Jul 2021 22:22:50 +0000 Subject: [PATCH] Convert NodeName obtained from env var to lowercase on Windows. Currently, the startup scripts force an environment variable to have lowercase node name. This gets complex once we add support to native windows services as they don't get env variables from local shell. An example of startup script is function: Start-AntreaAgent in https://raw.githubusercontent.com/antrea-io/antrea/v1.2.0/hack/windows/Helper.psm1 Signed-off-by: Gurucharan Shetty --- pkg/util/env/env.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/util/env/env.go b/pkg/util/env/env.go index 70e0fd454e0..69f5dd5d47d 100644 --- a/pkg/util/env/env.go +++ b/pkg/util/env/env.go @@ -16,7 +16,9 @@ package env import ( "os" + "runtime" "strconv" + "strings" "k8s.io/klog/v2" ) @@ -48,6 +50,9 @@ func GetNodeName() (string, error) { klog.Errorf("Failed to get local hostname: %v", err) return "", err } + if runtime.GOOS == "windows" { + return strings.ToLower(nodeName), nil + } return nodeName, nil }