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

The token caching does not seem to work (at least not when using the plugin for allprojects from init.gradle.kts) #224

Open
lestephane opened this issue Sep 17, 2021 · 2 comments

Comments

@lestephane
Copy link

From looking at your code, I could see you intended to cache tokens for the lifetime of the plugin.
But it seems that, despite the gradle daemon staying around, the plugin instance does not.

To test the hypothesis, I ran the same command twice, and expected the second one to not output anything (ie. no GetAuthorization, because the token from the first one is not expired yet).

$ gradle build --debug | grep "/v1/authorization-token"
2021-09-17T13:12:28.564+0200 [DEBUG] [software.amazon.awssdk.request] Sending Request: DefaultSdkHttpFullRequest(httpMethod=POST, protocol=https, host=codeartifact.eu-central-1.amazonaws.com, encodedPath=/v1/authorization-token, headers=[amz-sdk-invocation-id, User-Agent], queryParameters=[domain, domain-owner])
2021-09-17T13:12:28.674+0200 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request POST /v1/authorization-token?domain=SCRUBBED&domain-owner=411628588745 HTTP/1.1
2:17
$ gradle build --debug | grep "/v1/authorization-token"
2021-09-17T13:12:34.989+0200 [DEBUG] [software.amazon.awssdk.request] Sending Request: DefaultSdkHttpFullRequest(httpMethod=POST, protocol=https, host=codeartifact.eu-central-1.amazonaws.com, encodedPath=/v1/authorization-token, headers=[amz-sdk-invocation-id, User-Agent], queryParameters=[domain, domain-owner])
2021-09-17T13:12:35.107+0200 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request POST /v1/authorization-token?domain=SCRUBBED&domain-owner=411628588745 HTTP/1.1
@jerolba
Copy link
Collaborator

jerolba commented Sep 19, 2021

The intention of the plugin is just to reuse the token during the life of a command. Reuse the token in multiple references to the same repository.

I my experience using codeartifact, there is no problem in creating new tokens for each command execution (apart from the time taken to perform authentication).

We don't know how to reuse this information via Gradle daemon. Do you have experience?

@lestephane
Copy link
Author

We don't know how to reuse this information via Gradle daemon. Do you have experience?

Unfortunately no. In the past I myself would export a code artifact token as environment variable through direnv's .envrc, so as to only generate one per shell lifetime, and I would start the IDE from that shell.

I'm indeed worried about potential request throttling. Time will tell.

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

No branches or pull requests

2 participants