Commit b1f8ba9d authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #30014 from dims/remove-uname-dependency

Automatic merge from submit-queue Remove kubelet dependency on uname Let's avoid exec'ing stuff we don't have to. Related to #26093
parents e7d01097 83236344
...@@ -20,7 +20,7 @@ import ( ...@@ -20,7 +20,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"net" "net"
"os/exec" "os"
"strings" "strings"
"time" "time"
...@@ -31,13 +31,13 @@ import ( ...@@ -31,13 +31,13 @@ import (
) )
func GetHostname(hostnameOverride string) string { func GetHostname(hostnameOverride string) string {
hostname := hostnameOverride var hostname string = hostnameOverride
if string(hostname) == "" { if hostname == "" {
nodename, err := exec.Command("uname", "-n").Output() nodename, err := os.Hostname()
if err != nil { if err != nil {
glog.Fatalf("Couldn't determine hostname: %v", err) glog.Fatalf("Couldn't determine hostname: %v", err)
} }
hostname = string(nodename) hostname = nodename
} }
return strings.ToLower(strings.TrimSpace(hostname)) return strings.ToLower(strings.TrimSpace(hostname))
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment