mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +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"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os/exec"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -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))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user