-
Notifications
You must be signed in to change notification settings - Fork 371
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
GitHubAppCredentials.writeReplace to avoid recalculating tokens #302
GitHubAppCredentials.writeReplace to avoid recalculating tokens #302
Conversation
There are code paths in this plugin that depend on the type of credentials used being |
Checked, and they are. On the agent side, you are just interested in a An alternative fix would be to create a |
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.
This definitely seems better to me. Thanks!
Now we just need a test for 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.
Looks ok, I've never seen writeReplace before this PR though
See the before state in jenkinsci/ssh-credentials-plugin@18b3121. |
I suppose you are talking about some |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@jglick Even comments in the code about why it is needed would be start. |
Added comments. As previously mentioned, while I believe it would be straightforward to add test coverage for node('remote') {
withCredentials([usernameColonPassword(credentialsId: 'ghapp', variable: 'AUTH')]) {
sh 'curl -f -u $AUTH $ENDPOINT/api/v3/app'
}
} will not cut it, because |
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.
Okay, this sounds reasonable to me.
Despite #291, using app authentication made checkouts on agents really slow. On a server I tested with using the
kubernetes
plugin, this reduces the time taken bycheckout scm
on a tiny github.com repo from 46s to 26s. Otherwise agent stack traces during checkout show lots of delays likebecause not only is the token generated on the master not being reused, the agent is loading a ton of additional classes.
Note that the poor design of
git-client-api
still results in plenty of overhead; you would expect the master to just issue some/usr/bin/git
commands to the agent, but instead a lot of classes are transferred to the agent and computation done there. See JENKINS-30600.Note that https://github.com/jenkinsci/credentials-plugin/blob/6f710a7e30156e94aff8a3c6c6799cef04ad35df/docs/implementation.adoc#additional-concerns suggests using
CredentialsSnapshotTaker
. After jenkinsci/ssh-credentials-plugin@18b3121 there seems to be no implementation in a widely used credentials type. I did not see any particular benefit to using this extension point since you need to implement your ownwriteReplace
anyway—may as well inline the snapshotting (no reason for it to be extensible).