Merge pull request #7910 from yujuhong/hostname

Use the full hostname for mirror pod name.
This commit is contained in:
Victor Marmol
2015-05-07 14:43:16 -07:00
2 changed files with 10 additions and 16 deletions

View File

@@ -24,13 +24,16 @@ import (
)
func GetHostname(hostnameOverride string) string {
hostname := []byte(hostnameOverride)
hostname := hostnameOverride
if string(hostname) == "" {
fqdn, err := exec.Command("uname", "-n").Output()
nodename, err := exec.Command("uname", "-n").Output()
if err != nil {
glog.Fatalf("Couldn't determine hostname: %v", err)
}
hostname = fqdn
chunks := strings.Split(string(nodename), ".")
// nodename could be a fully-qualified domain name or not. Take the first
// word of nodename as the hostname for consistency.
hostname = chunks[0]
}
return strings.ToLower(strings.TrimSpace(string(hostname)))
return strings.ToLower(strings.TrimSpace(hostname))
}