-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Make server side error messages from vault more clearer #3968
Changes from 1 commit
71e4061
25b338b
f4a4685
d83ad72
a6ec63d
034db7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -854,6 +854,13 @@ func (r *TaskRunner) deriveVaultToken() (token string, exit bool) { | |
return tokens[r.task.Name], false | ||
} | ||
|
||
// Check if this is a server side error | ||
if structs.IsServerSide(err) { | ||
r.logger.Printf("[ERR] client: failed to derive Vault token for task %v on alloc %q: %v", | ||
r.task.Name, r.alloc.ID, err) | ||
r.Kill("vault", fmt.Sprintf("server error in deriving vault token: %v", err), true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
return "", true | ||
} | ||
// Check if we can't recover from the error | ||
if !structs.IsRecoverable(err) { | ||
r.logger.Printf("[ERR] client: failed to derive Vault token for task %v on alloc %q: %v", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1143,7 +1143,14 @@ func (n *Node) DeriveVaultToken(args *structs.DeriveVaultTokenRequest, | |
if e == nil { | ||
return | ||
} | ||
reply.Error = structs.NewRecoverableError(e, recoverable).(*structs.RecoverableError) | ||
re, ok := e.(structs.Recoverable) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assert to |
||
if ok { | ||
// No need to wrap if error already implements Recoverable | ||
reply.Error = re.(*structs.RecoverableError) | ||
} else { | ||
reply.Error = structs.NewRecoverableError(e, recoverable).(*structs.RecoverableError) | ||
} | ||
|
||
n.srv.logger.Printf("[ERR] nomad.client: DeriveVaultToken failed (recoverable %v): %v", recoverable, e) | ||
} | ||
|
||
|
@@ -1269,8 +1276,7 @@ func (n *Node) DeriveVaultToken(args *structs.DeriveVaultTokenRequest, | |
|
||
secret, err := n.srv.vault.CreateToken(ctx, alloc, task) | ||
if err != nil { | ||
wrapped := fmt.Sprintf("failed to create token for task %q on alloc %q: %v", task, alloc.ID, err) | ||
return structs.WrapRecoverable(wrapped, err) | ||
return err | ||
} | ||
|
||
results[task] = secret | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return the err not the resp error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also should it be marked as a server error? It is likely there is no valid server which is where the error is coming from since all errors other than network are returned via the
resp.Error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, this should not be marked as such, will fix