-
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
Fix a case where mounts could be duplicated #6771
Conversation
When unmounting, the router entry would be tainted, preventing routing. However, we would then unmount the router before clearing storage, so if an error occurred the router would have forgotten the path. For auth mounts this isn't a problem since they had a secondary check, but regular mounts didn't (not sure why, but this is true back to at least 0.2.0). This meant you could then create a duplicate mount using the same path which would then not conflict in the router until postUnseal. This adds the extra check to regular mounts, and also moves the location of the router unmount. This also ensures that on the next router.Mount, tainted is set to the mount entry's tainted status. Fixes #6769
Note for reviewers: The test case in external_tests is just for completeness. The main test is the modifications to the one in mount_test.go. I've exercised these individually to test that they fail without the changes and don't fail with by running this test with the rest of it |
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 spend some time reading this; LGTM.
The placement of Unmount is after writes to both "view"and to the MountTable. I think it should therefore handle errors in either place, but the unit test exercises only the first write failing.
@mgritter Yeah that's what I was getting at in my note above. I tested that manually by commenting out the code in the first check and it still guarded as intended. But without adding test flags or something pretty ugly there isn't a great way in tests to bypass that initial check. |
@jefferai please let me know if you appreciate some retests on our side with the fixes on this branch. I could check to get a test environment prepared. |
Sure, that would be great! |
Hi @jefferai The vault server log shows now:
The mount gets cleaned up properly. After recreating same PKI the restart of vault server is also successful (no duplicate mount error). Just one thing I forgot to mention in the ticket: terraform triggers multiple delete operations (I assume because of request timeout). I assume from vault perspective, proper timeouts should be used in order to prevent multiple delete calls? Thanks for the fix! |
@tstoermer Thanks for checking back! I think in the normal case the TF thing won't be a problem, just happened because you were in a weird state. |
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 reviewed these changes, and they LGTM
When unmounting, the router entry would be tainted, preventing routing. However, we would then unmount the router before clearing storage, so if an error occurred the router would have forgotten the path. For auth mounts this isn't a problem since they had a secondary check, but regular mounts didn't (not sure why, but this is true back to at least 0.2.0). This meant you could then create a duplicate mount using the same path which would then not conflict in the router until postUnseal. This adds the extra check to regular mounts, and also moves the location of the router unmount. This also ensures that on the next router.Mount, tainted is set to the mount entry's tainted status. Fixes #6769
When unmounting, the router entry would be tainted, preventing routing.
However, we would then unmount the router before clearing storage, so if
an error occurred the router would have forgotten the path. For auth
mounts this isn't a problem since they had a secondary check, but
regular mounts didn't (not sure why, but this is true back to at least
0.2.0). This meant you could then create a duplicate mount using the
same path which would then not conflict in the router until postUnseal.
This adds the extra check to regular mounts, and also moves the location
of the router unmount.
This also ensures that on the next router.Mount, tainted is set to the
mount entry's tainted status.
Fixes #6769