-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add redshift database plugin #8299
Conversation
cb8f57a
to
e009e72
Compare
return nil, errors.New("username and password are required to rotate") | ||
} | ||
|
||
rotateStatents := statements |
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.
Looks like the var is misspelled, s/rotateStatents/rotateStatements/
.
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.
A transient artifact no less https://github.com/hashicorp/vault/blob/master/plugins/database/postgresql/postgresql.go#L452
I'll fix this and PR a fix in the original codebase too. Good catch, thanks!
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.
4a20e27
to
00726b4
Compare
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.
Looks great so far! Thanks for working on this!
return "", "", err | ||
} | ||
defer func() { | ||
_ = tx.Rollback() |
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.
_ = tx.Rollback() | |
tx.Rollback() |
Might as well just quietly drop the error, we do everywhere else. It would be super nice if we could log these, but alas, no logger!
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, I have a question about these Rollback statements. I see Rollback is called this way in the mysql
plugin. Is the idea basically that if we succeeded doing the transaction, then Rollback just won't work? I'm wondering if maybe we should add a guard that's like "success" that is false by default, and then it gets set to true if the whole transaction succeeded. Then inside the deferred function, it would be like "if !success, rollback" (pseudocode).
var lastStmtError error | ||
for _, query := range revocationStmts { | ||
if err := dbtxn.ExecuteDBQuery(ctx, db, nil, query); err != nil { | ||
lastStmtError = err |
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.
Might be nice to use go-multierror here to return more information about what did and didn't succeed. Commonly used in Vault.
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.
I'm also wondering about an edge case here. I do believe that revocations get retried if they return an error. So, if we got part way through here, returned an error below, and then a minute later restarted the logic from the top, could we get all the way down? I'm not sure we need to do somersaults to make it work - I notice the other plugins use simplistic logic, just something to think about.
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.
Do you have a good example of how this is implemented elsewhere? This plugin was largely inspired (and ripped off from) the PG secrets engine. If there's a simpler implementation you had in mind, would love to check it out.
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.
Sure, I think this is a nice example of it: https://github.com/hashicorp/vault/blob/master/plugins/database/influxdb/influxdb.go#L192
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 can also treat it like a regular error. So, for instance, in the example above, if right after the loop you wanted to do something like:
if result != nil {
return
}
... do more stuff
It would totally work like normal.
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.
Fixed
e0faa53
to
7707d80
Compare
Thanks @tyrannosaurus-becks - I got to everything but the final question you had in here. I force pushed over the existing commit, here's the results of testing with the latest changes:
|
589ef70
to
b5588df
Compare
Thanks for all your work on this so far! Would you be willing to merge in master so we can also get a clean look at the build before merging? Also, I notice there are some test failures related to |
b5588df
to
9d5e540
Compare
Awesome, thanks @tyrannosaurus-becks - added the plugin to the plugin predict test file and rebased on master. |
43a12ad
to
0497375
Compare
Thanks for the second pass @tyrannosaurus-becks ! I added the missing Latest test results with fixes and rebase:
|
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.
Nice! Thank you!
7ec264d
to
b95f8e3
Compare
Adds a database secrets engine for Redshift (postgres 8 compatible).
Because there are no local mocking methods available for Redshift, this plugin leverages a live Redshift cluster and enables test methods using the
VAULT_ACC
pattern. See comments in header toredshift_test.go
for a full disclosure of caveats and setup instructions to run these acceptance tests.Running these tests locally: