Skip to content

Commit

Permalink
Merge pull request #2267 from BSick7/b/panic-startup
Browse files Browse the repository at this point in the history
Preventing panics of RecoverableError casts
  • Loading branch information
schmichael committed Feb 1, 2017
2 parents 6e16262 + e887e80 commit 811f759
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nomad/node_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,9 @@ func (n *Node) DeriveVaultToken(args *structs.DeriveVaultTokenRequest,
// setErr is a helper for setting the recoverable error on the reply and
// logging it
setErr := func(e error, recoverable bool) {
if e == nil {
return
}
reply.Error = structs.NewRecoverableError(e, recoverable).(*structs.RecoverableError)
n.srv.logger.Printf("[ERR] nomad.client: DeriveVaultToken failed (recoverable %v): %v", recoverable, e)
}
Expand Down Expand Up @@ -1133,7 +1136,7 @@ func (n *Node) DeriveVaultToken(args *structs.DeriveVaultTokenRequest,

if rerr, ok := createErr.(*structs.RecoverableError); ok {
reply.Error = rerr
} else {
} else if err != nil {
reply.Error = structs.NewRecoverableError(createErr, false).(*structs.RecoverableError)
}

Expand Down

0 comments on commit 811f759

Please sign in to comment.