Cache separate vault clients for each namespace if necessary#4706
Conversation
e602ae4 to
aa1f091
Compare
|
this approach looks solid to me - plus all the checks are already passing 😄 |
|
/ok-to-test sha=aa1f0914de8fe8e828250d7ff82449a12e18b93d |
|
I think this looks good @ChristianCiach . We just need to maybe improve the test coverage by adding a test case with a different namespace on Then, this will look very good. |
I will see what I can do. I still struggle with unit testing in Go, since it works very differently than the testing frameworks of Java and Python that I am familiar with. It may take a few days, but I will come back to you. If you don't want to wait, feel free to add a test by yourself :) |
4f1497e to
25307c3
Compare
|
Alright, this took a while and I struggled quite a bit. At first I tried to integrate the the new tests into the existing test cases, but this was not really possible:
Instead of configuring a There was also a "condition is always false" warning when comparing an |
this skip adding tokens to cache was done for a reason. When users are sending out tokens to external-secrets, we are considering them to be possible batch tokens (subject to being revoked), and we shouldn't absolutely do that. See #1537 (comment) for more context. |
1c96dfa to
c762836
Compare
Signed-off-by: Christian Ciach <christian.ciach@gmail.com>
Signed-off-by: Christian Ciach <christian.ciach@gmail.com>
Signed-off-by: Christian Ciach <christian.ciach@gmail.com>
Signed-off-by: Christian Ciach <christian.ciach@gmail.com>
c762836 to
9b874e6
Compare
I think you've got this backwards. Batch-tokens cannot be revoked (they don't have an associated session in Vault, which is the point). You are probably talking about service-tokens. I agree that these shouldn't be revoked, but IMHO that's not a very good argument to not cache the vault client. Anyway, I don't really care either way, so I've removed this commit from this PR :) |
|
/ok-to-test sha=9b874e6ed80fa5a42b638f58431d44a42939587c |
|
Looks good to me :) just waiting to see if CI/CD & e2e tests pass and this is good to go IMO :) I like the small tweaks you did to make the codebase better! much more maintainable now, thanks! |
|
thanks for your contribution @ChristianCiach ! 🥳 |
|



Problem Statement
When enabling
--experimental-enable-vault-token-cacheI encountered persisting 403 status errors when connecting to our Vault server. Please read the thread starting at https://github.com/external-secrets/external-secrets/discussions/3132#discussioncomment-12605322 to catch up with the discussion around this issue.While debugging this, I realized that this issue only appears when using a ClusterSecretStore that references a namespaced auth-token where the namespace is not fixed, like this:
^ Note that the
serviceAccountRefdoes not state a fixednamespace. The namespace of thedefaultservice account is decided later, based on the namespace of theExternalSecretthat uses thisClusterSecretStore.When configuring it like this, ESO will currently generate the same cache key for every namespace, because it currently uses the namespace of the
ClusterSecretStore(which is obviously always the empty string), even though the auth-token needs to be different for every namespace that contains ExternalSecrets.Thanks to @gusfcarvalho who encouraged me to create this PR.
Related Issue
No issue yet. See the linked discussion above. Please let be know if you absolutely need an issue for tracking this PR.
Proposed Changes
In
pkg/provider/vault/provider.goI found the existing functionisReferentSpecthat I think does exactly what I needed to fix this: This function seems to return "true" in cases where the configured vault-auth is referencing an auth-token that is based on the namespace of the referencing ExternalSecret.If this function returns true, I just use namespace of the requesting ExternalSecret object as part of the cache-key.
Checklist
git commit --signoffmake testmake reviewable