mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Remove kubelet dependency on uname
This commit is contained in:
parent
804109d349
commit
832363442d
@ -20,7 +20,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"os/exec"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -31,13 +31,13 @@ import (
|
||||
)
|
||||
|
||||
func GetHostname(hostnameOverride string) string {
|
||||
hostname := hostnameOverride
|
||||
if string(hostname) == "" {
|
||||
nodename, err := exec.Command("uname", "-n").Output()
|
||||
var hostname string = hostnameOverride
|
||||
if hostname == "" {
|
||||
nodename, err := os.Hostname()
|
||||
if err != nil {
|
||||
glog.Fatalf("Couldn't determine hostname: %v", err)
|
||||
}
|
||||
hostname = string(nodename)
|
||||
hostname = nodename
|
||||
}
|
||||
return strings.ToLower(strings.TrimSpace(hostname))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user