mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
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
This commit is contained in:
commit
b1f8ba9ddf
@ -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