Check for Vault API to be ready in Vault tests #21154
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Waiting for the container to start is not enough to be able to initialize the vault instance. We need to check that the API is ready as well.
In a slow environment, if we don't, we can get a read timeout on the first http request. Most likely vault has received it and processed it, but for some reason the client (i.e. vault test) does not receive the response. It is not clear why this happens. But to make tests more resilient we need to exercise the API before executing non idempotent calls. This can't be the
init(int,int)
service, because as soon as the vault is initialized, it cannot be reinitialized (if the first call went through), and the test cannot continue without the root token and unseal keys that come from theinit
call.This fix consists in trying out multiple times executing
sys/seal-status
until we get a valid response. Once this is done, we can continue the normal flow of vault initialization.Also changed the idle timeout to be 2 times the read timeout, otherwise we risk closing the connection before the
atMost
throws a timeout exception.Fixes #21095
With that we should not need anymore the increases read and connect timeouts that have been tried earlier to try fixing this issue.