Skip to content

Commit f8a9305

Browse files
author
Tamas Bihari
committed
Merge branch '0.3'
2 parents bc80df3 + 52bd332 commit f8a9305

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BINARY=salt-bootstrap
22

3-
VERSION=0.10.2
3+
VERSION=0.10.3
44
BUILD_TIME=$(shell date +%FT%T)
55
LDFLAGS=-ldflags "-X github.com/hortonworks/salt-bootstrap/saltboot.Version=${VERSION} -X github.com/hortonworks/salt-bootstrap/saltboot.BuildTime=${BUILD_TIME}"
66
GOFILES = $(shell find . -type f -name '*.go')

saltboot/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (clients *Clients) DistributeHostnameRequest(user string, pass string) (res
3535

3636
func ClientHostnameHandler(w http.ResponseWriter, req *http.Request) {
3737
log.Printf("[ClientHostnameHandler] get FQDN")
38-
fqdn, err := getHostName()
38+
fqdn, err := getFQDN()
3939
if err != nil {
4040
log.Printf("[ClientHostnameHandler] failed to retrieve FQDN")
4141
model.Response{Status: err.Error(), StatusCode: http.StatusInternalServerError}.WriteHttp(w)

saltboot/hostname.go

+22-17
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,36 @@ func getIpv4Address() (string, error) {
1313
return ExecCmd("hostname", "-i")
1414
}
1515

16-
func getHostName() (string, error) {
16+
func getFQDN() (string, error) {
1717
return ExecCmd("hostname", "-f")
1818
}
1919

20+
func getHostName() (string, error) {
21+
return ExecCmd("hostname", "-s")
22+
}
23+
24+
func getDomain() (string, error) {
25+
return ExecCmd("hostname", "-d")
26+
}
27+
2028
// This is required due to: https://github.com/saltstack/salt/issues/32719
21-
func ensureIpv6Resolvable(domain string) error {
22-
fqdn, err := getHostName()
23-
log.Printf("[ensureIpv6Resolvable] fqdn: %s", fqdn)
24-
if err != nil {
25-
return err
29+
func ensureIpv6Resolvable(customDomain string) error {
30+
hostname, hostNameErr := getHostName()
31+
log.Printf("[ensureIpv6Resolvable] hostName: %s", hostname)
32+
if hostNameErr != nil {
33+
return hostNameErr
2634
}
27-
if !strings.Contains(fqdn, ".") {
28-
// only fqdn does not contain domain
29-
if domain != "" {
30-
updateIpv6HostName(fqdn, domain)
31-
} else {
32-
//if there is no domain, we need to add one since ambari fails without domain, actually it does nothing just hangs..
33-
updateIpv6HostName(fqdn, DEFAULT_DOMAIN)
35+
36+
domain, domainError := getDomain()
37+
log.Printf("[ensureIpv6Resolvable] origin domain: %s", domain)
38+
if customDomain == "" {
39+
if domainError != nil || domain == "" {
40+
domain = DEFAULT_DOMAIN
3441
}
3542
} else {
36-
if domain != "" {
37-
hostName := strings.Split(fqdn, ".")[0]
38-
updateIpv6HostName(hostName, domain)
39-
}
43+
domain = customDomain
4044
}
45+
updateIpv6HostName(hostname, domain)
4146

4247
return nil
4348
}

saltboot/salt_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func TestSaltServerRunRequestHandler(t *testing.T) {
151151

152152
SaltServerRunRequestHandler(w, req)
153153

154-
pattern := "^hostname -f:hostname -i:grep saltuser /etc/passwd:adduser --no-create-home -G wheel -s /sbin/nologin --password \\$6\\$([a-zA-Z\\$0-9/.]+) saltuser:ps aux:/sbin/service salt-master start:/sbin/chkconfig salt-master on:ps aux:/sbin/service salt-api start:/sbin/chkconfig salt-api on:$"
154+
pattern := "^hostname -s:hostname -d:hostname -i:grep saltuser /etc/passwd:adduser --no-create-home -G wheel -s /sbin/nologin --password \\$6\\$([a-zA-Z\\$0-9/.]+) saltuser:ps aux:/sbin/service salt-master start:/sbin/chkconfig salt-master on:ps aux:/sbin/service salt-api start:/sbin/chkconfig salt-api on:$"
155155
if m, err := regexp.MatchString(pattern, os.Getenv(EXECUTED_COMMANDS)); m == false || err != nil {
156156
t.Errorf("wrong commands were executed: %s", os.Getenv(EXECUTED_COMMANDS))
157157
}

0 commit comments

Comments
 (0)