-
Notifications
You must be signed in to change notification settings - Fork 54
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
Excessive amount of Credentials Lookups when contributing environment variables #967
Comments
Valid problem, complicated to solve in the OTel plugin. Question:
Workaround ideas:
|
Its @jenkinsci/credentials-plugin-developers most likely @jtnord From my memory remote credentials themselves aren't supposed to be cached.
@Dohbedoh / @cyrille-leclerc do you know where the code is thats causing this problem? If this is just for the otel credential I would expect it to be loaded once for the run and cached for the duration of the run, (could be convinced for a longer cache) |
The following pipeline causes the same behavior without having the OpenTelemetry plugin installed; there is no TTL for the credentials, and they are always requested to the provider, which can cause quota exhaustion on some providers; the solution is a TTL in the credentials provider to fix the issue for all use cases. Implementing something in the OpenTelemetry plugin does not make sense because it does not resolve the real issue; it only patches it for a single plugin. node {
def stages = [:]
for(int i=0; i<1000; i++) {
stages[i] = {
def secrets = [
[path: 'secret/token_secret', engineVersion: 1, secretValues: [
[envVar: 'token', vaultKey: 'value_one']]],
]
def configuration = [vaultUrl: 'http://my-very-other-vault-url.com',
vaultCredentialId: 'my-vault-cred-id',
engineVersion: 1]
withVault([configuration: configuration, vaultSecrets: secrets]) {
curl -H "Token: $token" https: //some.api/
}
}
}
parallel stages
} |
Yes but most plugins won't call it on every step they'll only call it once... |
I support @kuisathaverat 's points:
|
There is another use case that causes the same behavior. If you configure OpenTelemetry plugin to use Vault credentials and you spin up 100, 200, 300, or 500 jobs, you will make the same amount of requests to the Vault even though you did not enable the |
Hello :) Whilst credential providers could cache, I would consider it bad form. I'm not sure why OTEL is using a credential here and for what means. Without exporing the why, a credential should only be used when it is to be shared (re-used) accross different "things" with various different things, for something specific to one piece of code a Secret used in plugins (global) configuration should be used.
you are only trading one issue for another. The pipeline is abusing a system, as per above caching (introducing a TTL) could introduce random failures, by failing to connect to the service for Whilst any credential provider could choose to implement this, to not have random failures of CI (which is just a very bad thing) the only possible value would be |
having said that if whatever external provider has some ability to support caching itself (e.g. a |
Maybe once, these days credentials API is used for most secrets. It allows treating all secrets the same and using external providers to store and rotate these credentials, I wouldn't go down the Secret approach in plugins these days, its very rare to see that now. |
Another use case that could cause the same behavior is when you configure the logs backend in the OpenTelemetry plugin and use an external credentials provider. When you have 100-500 users checking logs, you will have a request per user to get the credentials from the external provider every time the user requests a log page. This could be a lot more problematic than the other two use cases. We all know the F5 Users and the GB console logs. So, for large systems, I would not recommend using external credentials to configure any plugin that could trigger hundreds of requests on user iterattion. |
But wouldn't the credential just be retrieved once to view the logs? and potentially retrieved again on unauthorised? |
retrieved again |
use CasC for secret rotation (with ability to link to Vault etc). The use case for Secrets is real as per this (ab)use of an API |
Please explain how a cache in the credentials provider would work here without giving these 100-500 users 403 errors and the inability to view logs for the cache period? |
If a secret's TTL is 1 minute, you would reduce the number of requests for that secret to one per minute. So, if you have 500 user requests for logs, you will only make one request to the external service; without that TTL, you will make 500. |
A TTL of a few dozens of seconds would make sense to me. |
FWIW, I think Open Telemetry was an obvious culprit because it retrieve credentials details on every single step execution. Which can easily reach a high rate in Jenkins. I don't think any other plugin I have seen do that. I agree that Credentials Provider should probably implements TTL solution. But what is concerning is the fact that it takes one plugin setup, like Open Telemetry, to realize that a remote credentials provider needs a TTL implementation. Why a Jenkins integration with a Remote Credentials Provider be fine until you integrate with Open Telemetry. As if you need to pass the "Open Telemetry test" to validate your remote credentials provider implementation if you know what I mean :/ |
Any plugin configured to use an external credentials provider can trigger the same. You only need to trigger parallel stuff, and you make a mess, so it is too easy to abuse. Indeed, I stopped using the Vault plugin because of that. For example, for the SSH build agent, if you configure the credentials in an external provider and you request 100 agents (I said 100 because it is not much), you will make 100 requests to the external provider.
At the end, it is something that depends on your infrastructure, if you can make 10000000000 requests without issues and it is not a big deal for you, you can configure it, but if you can only make 100 requests per minute (or something like that) you should know that you should configure other kinds of credentials or it will cause issues. Putting a warning on the credentials configuration dropdown could be easy to warm users up and let them decide (it's up to you). |
Jenkins and plugins versions report
When the option
Export OpenTelemetry configuration as environment variables
is enabled, every single pipeline step will cause a credentials lookup to happen. This might seem insignificant but when using External Credentials system (such as the Hashicorp Vault Credentials Provider) the results in very excessive fetch requests.While the credentials provider could be blamed for .. maybe implementing a cache.. Open Telemetry seem to be abusing the credentials API at every single step when that option is enabled.
Environment
What Operating System are you using (both controller, and any agents involved in the problem)?
UBI docker images
Reproduction steps
Export OpenTelemetry configuration as environment variables
Disable Export OpenTelemetry configuration as environment variables
Expected Results
The external Credentials provider not be hammered with credentials fetching requests
Actual Results
The external Credentials provider not be hammered with credentials fetching requests
Anything else?
No response
Are you interested in contributing a fix?
No response
The text was updated successfully, but these errors were encountered: