Skip to content

Commit

Permalink
Fail back to hostname when hostname -f fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
tnachen committed Nov 30, 2015
1 parent 657252e commit 142db7d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mesosutil/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ func GetHostname(hostnameOverride string) string {
// want the FQDN, and this is the easiest way to get it.
fqdn, err := exec.Command("hostname", "-f").Output()
if err != nil {
log.Fatalf("Couldn't determine hostname: %v", err)
log.Errorf("Couldn't determine hostname fqdn, failing back to hostname: %v", err)
hostname, err := os.Hostname()
if err != nil {
log.Fatalf("Error getting hostname: %v", err)
}
} else {
hostname = fqdn
}
hostname = fqdn
}
return strings.TrimSpace(string(hostname))
}

0 comments on commit 142db7d

Please sign in to comment.