Skip to content
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

VAULT-528 Fix issue with consul-template not rendering secrets with delete_version_after set on them #1879

Merged
merged 3 commits into from
Feb 13, 2024

Conversation

VioletHynes
Copy link
Contributor

Some background:

Initially, Vault secrets would only have deletion_time set on them if they'd been deleted. Since then, it has become possible to set deletion time in the future, using delete_version_after to indicate that a secret 'will' be deleted. As a result, the old logic to assume a secret is deleted if it has a deletion time has become naive.

Resolves #1789
Resolves #1778
Resolves https://discuss.hashicorp.com/t/consul-template-not-returning-vault-kv-items-with-deletion-time-set/55763

@@ -5,6 +5,7 @@ NEW FEATURES:

BUG FIXES:
* Fetch services query not overriding opts correctly [NET-7571](https://hashicorp.atlassian.net/browse/NET-7571)
* Consul-template now correctly renders KVv2 secrets with `delete_version_after` set [NET-3777](https://hashicorp.atlassian.net/browse/NET-3777)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spotted this as part of researching the bug. I've been doing the work under VAULT-528, but I'm happy to close NET-3777 as a duplicate or something once I merge this. However you folks want to handle it and whatever best fits your process!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do close NET-3777, this essentially fixes what has been reported.

return md["deletion_time"] != ""
deletionTime, ok := md["deletion_time"].(string)
if !ok {
// Not a string, end early
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Not a string, end early
// key not present, end early

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're casting to a string, we'll only go down the !ok codepath will only be gone down if the key isn't present or the value isn't a string. I'll improve the comment to show that it could be both :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated! Please let me know if there's anything else you'd need before approving :)

Copy link

@marcboudreau marcboudreau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I did leave a suggestion for 2 additional test cases for your consideration.

"deletion_time": "foo",
},
},
}))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add two more tests that confirm:

  1. that if metadata is missing, false is returned from deletedKVv2
  2. that if metadata's type is something other than map[string]interface{}, false is returned from deletedKVv2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Added both :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants