Skip to content

Commit

Permalink
CB-14659. Remove saltboot fingerprint computation via salt-call 'local'
Browse files Browse the repository at this point in the history
The current fingerprint via salt-call mechanism does not work (--local
instead of -local). The additional find /opt tends to take a fair amount
of time to execute.
  • Loading branch information
sidseth authored and keyki committed Oct 27, 2021
1 parent 99ce4cc commit 57d130e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BINARY=salt-bootstrap

VERSION=0.13.4
VERSION=0.13.5
BUILD_TIME=$(shell date +%FT%T)
LDFLAGS=-ldflags "-X github.com/hortonworks/salt-bootstrap/saltboot.Version=${VERSION} -X github.com/hortonworks/salt-bootstrap/saltboot.BuildTime=${BUILD_TIME}"
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*")
Expand Down
40 changes: 0 additions & 40 deletions saltboot/fingerprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,46 +115,6 @@ func distributeFingerprintImpl(distributeRequest func([]string, string, string,
return result
}

func getMinionFingerprintFromSaltCall() (model.Response, error) {
log.Println("[getMinionFingerprintFromSaltCall] get minion fingerprint using salt-call")

saltLocation := SaltLocation
out, err := ExecCmd("find", saltLocation, "-name", "salt-call")
if err != nil {
log.Printf("[getMinionFingerprintFromSaltCall] cannot execute find command, err: %s", err.Error())
return model.Response{}, err
}

var saltCallLocation string
for _, findResult := range strings.Split(out, "\n") {
if strings.Contains(findResult, "salt-call") {
saltCallLocation = findResult
break
}
}
if len(saltCallLocation) == 0 {
log.Printf("[getMinionFingerprintFromSaltCall] cannot find salt-call executable at %s", saltLocation)
return model.Response{}, errors.New("cannot find salt-call executable")
}
log.Printf("[getMinionFingerprintFromSaltCall] found salt-call at %s", saltCallLocation)

out, err = ExecCmd(saltCallLocation, "-local", "key.finger")
if err != nil {
log.Printf("[getMinionFingerprintFromSaltCall] cannot execute salt-call command, err: %s", err.Error())
return model.Response{}, err
}
fingerLines := strings.Split(out, "\n")
if len(fingerLines) != 2 {
log.Printf("[getMinionFingerprintFromSaltCall] unknown result returned from salt-call: %s", out)
return model.Response{}, errors.New("unknown result returned from salt-call")
}

fingerprint := strings.Trim(fingerLines[1], " ")
log.Printf("[getMinionFingerprintFromSaltCall] fingerprint: %s", fingerprint)

return model.Response{Status: fingerprint}, nil
}

func getMinionFingerprintFromPrivateKey() model.Response {
keyLocation := MinionKey
log.Println("[getMinionFingerprintFromPrivateKey] generate the fingerprint from the minion's private key: " + keyLocation)
Expand Down
7 changes: 1 addition & 6 deletions saltboot/salt.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,7 @@ func SaltMinionStopRequestHandler(w http.ResponseWriter, req *http.Request) {

func SaltMinionKeyHandler(w http.ResponseWriter, req *http.Request) {
log.Println("[SaltMinionKeyHandler] fetch the salt-minion's fingerprint")

fingerprint, err := getMinionFingerprintFromSaltCall()
if err != nil {
log.Println("[SaltMinionKeyHandler] fall back to calculate the fingerprint from the private key")
fingerprint = getMinionFingerprintFromPrivateKey()
}
fingerprint := getMinionFingerprintFromPrivateKey()
fingerprint.WriteHttp(w)
}

Expand Down

0 comments on commit 57d130e

Please sign in to comment.