8000 Fix intermittent auth failure to artifactory from Jenkins by retronym · Pull Request #9658 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Fix intermittent auth failure to artifactory from Jenkins #9658

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

Merged
merged 1 commit into from
Jun 7, 2021

Conversation

retronym
Copy link
Member
@retronym retronym commented Jun 7, 2021

In 41e376a, the build was updated to support publishing from
Travis CI.

However, on Jenkins, the old means of supplying the publish
credentials to pr-validation snapshots was retained, it has
a ~/.credentials file. So we provided two credentials for the
same host/realm to SBT, and on Jenkins the DirectCredentials
contains an empty password.

Which one of these would SBT pick?

sbt 'setupPublishCore https://scala-ci.typesafe.com/artifactory/scala-pr-validation-snapshots/' 'show credentials'
[info] compiler / credentials
[info] 	List(DirectCredentials("Artifactory Realm", "scala-ci.typesafe.com", "scala-ci", ****), FileCredentials("/Users/jz/.credentials"))
[info] scalap / credentials
[info] 	List(DirectCredentials("Artifactory Realm", "scala-ci.typesafe.com", "scala-ci", ****), FileCredentials("/Users/jz/.credentials"))
...    <10 more like this>
[info] credentials
[info] 	List(DirectCredentials("Artifactory Realm", "scala-ci.typesafe.com", "scala-ci", ****))

The ivySbt task in SBT registers the credentials in order in a global map
in Ivy (CredentialStore). So on Jenkins, the invalid DirectCredentials
would be overwritten in the map by he FileCredentials.

But the fact that this is global state in Ivy appears to be a source of cross
talk between the configured credentials for different modules in the build.
Even though the publish task is serialized through the ivy lock, this lock
does not enclose the previous execution of the ivySbt which sets up the
credentials in CredentialStore.

In our build, notice that the root project does not have the
FileCredentials set. So if the ivySBT task for this project runs last,
the global map will have the incorrect DirectCredentials.

The fix in our build is easy, avoid configuring the DirectCredentials if the
environment variables are absent. We can also standardize on using
Global/credentials := .

The principled fix in SBT would be to thread the credentials down to the HTTP
client without using global state. It could also emit a warning if conflicting
credentials are configured for a given host/realm.

@scala-jenkins scala-jenkins added this to the 2.13.7 milestone Jun 7, 2021
@retronym retronym added internal not resulting in user-visible changes (build changes, tests, internal cleanups) backport candidate labels Jun 7, 2021
@retronym
Copy link
Member Author
retronym commented Jun 7, 2021

Reported the bug to SBT: sbt/sbt#6533

In 41e376a, the build was updated to support publishing from
Travis CI.

However, on Jenkins, the old means of supplying the publish
credentials to pr-validation snapshots was retained, it has
a ~/.credentials file. So we provided two credentials for the
same host/realm to SBT, and on Jenkins the DirectCredentials
contains an empty password.

Which one of these would SBT pick?

```
sbt 'setupPublishCore https://scala-ci.typesafe.com/artifactory/scala-pr-validation-snapshots/' 'show credentials'
[info] compiler / credentials
[info] 	List(DirectCredentials("Artifactory Realm", "scala-ci.typesafe.com", "scala-ci", ****), FileCredentials("/Users/jz/.credentials"))
[info] scalap / credentials
...    <10 more like this>
[info] credentials
[info] 	List(DirectCredentials("Artifactory Realm", "scala-ci.typesafe.com", "scala-ci", ****))
```

The `ivySbt` task in SBT registers the credentials in order in a global map
in Ivy (`CredentialStore`). So on Jenkins, the invalid `DirectCredentials`
would be overwritten in the map by he `FileCredentials`.

But the fact that this is global state in Ivy appears to be a source of cross
talk between the configured credentials for different modules in the build.
Even though the publish task is serialized through the ivy lock, this lock
does not enclose the previous execution of the `ivySbt` which sets up the
credentials in `CredentialStore`.

In our build, notice that the root project does _not_ have the
`FileCredentials` set. So if the `ivySBT` task for this project runs last,
the global map will have the incorrect `DirectCredentials`.

The fix in our build is easy, avoid configuring the `DirectCredentials` if the
environment variables are absent. We can also standardize on using
`Global/credentials := `.

The principled fix in SBT would be to thread the credentials down to the HTTP
client without using global state. It could also emit a warning if conflicting
credentials are configured for a given host/realm.
@retronym retronym force-pushed the topic/credentials branch from 170dfee to a8ec10d Compare June 7, 2021 06:41
@retronym retronym merged commit c7debd6 into scala:2.13.x Jun 7, 2021
@retronym retronym deleted the topic/credentials branch June 7, 2021 08:26
@SethTisue SethTisue mentioned this pull request Sep 13, 2021
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal not resulting in user-visible changes (build changes, tests, internal cleanups)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0