Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail back to hostname when hostname -f fails. #213

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions mesosutil/node.go
@@ -1,6 +1,7 @@
package mesosutil

import (
"os"
"os/exec"
"strings"

Expand All @@ -15,9 +16,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))
}