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

Regression HTTPS verification javax.net.ssl.SSLPeerUnverifiedException on docker layer pull #3058

Closed
daxroc opened this issue Feb 15, 2021 · 29 comments · Fixed by #3415
Closed

Comments

@daxroc
Copy link

daxroc commented Feb 15, 2021

On upgrade to 2.7.1 a dependency change breaks host verification for docker pull

Change seen within the http request trace

2.7.0  => User-Agent: jib 2.7.0 jib-gradle-plugin Google-HTTP-Java-Client/1.34.0 (gzip)
2.7.1   => User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)

This is possibly a host verification regression.

Environment:

  • *Jib version: 2.7.1
  • *Build tool: Gradle v6.7.1
  • *OS: Ubuntu-16.04 + Ubuntu 20.04
  • *JAVA 8, JAVA 11

Description of the issue:
Pulling of image fails on hostname verification

The base image requires auth. Trying again for amazon/aws-lambda-java:11...
No credentials could be retrieved for registry-1.docker.io/amazon/aws-lambda-java
Using base image with digest: sha256:801e43678e238903893085c6e9105a0e9d7efc379b6d2a38752a6a16ff96b83a
I/O error for image [registry-1.docker.io/amazon/aws-lambda-java]:
    javax.net.ssl.SSLPeerUnverifiedException
    Certificate for <docker-images-prod.s3.amazonaws.com> doesn't match any of the subject alternative names: [*.s3.amazonaws.com, s3.amazonaws.com]
com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException: com.google.cloud.tools.jib.api.InsecureRegistryException: Failed to verify the server at https://registry-1.docker.io/v2/amazon/aws-lambda-java/blobs/sha256:382c81da26b147bcaa0e0a46640a30f9f65364c380cc7c30336acccc1d29eb74 because only secure connections are allowed.

Plugin version and jib configuration required

plugins {
    id("com.google.cloud.tools.jib") version "2.7.1" // 2.7.0 works
}
jib {
    to.image = "${project.name}-lambda"
    from.image = "amazon/aws-lambda-java:11"
}

Log output:

./gradlew -g localcache --no-daemon <projectNameRedacted> -x build -x test -x check --info -Djava.util.logging.config.file=logging.properties -Djib.serialize=true

## OUTPUT is redacted of keys/tokens
> pulling base image manifest

-------------- REQUEST  --------------
GET https://registry-1.docker.io/v2/amazon/aws-lambda-java/manifests/11
Accept: application/vnd.oci.image.manifest.v1+json,application/vnd.docker.distribution.manifest.v2+json,application/vnd.docker.distribution.manifest.v1+json,application/vnd.docker.distribution.manifest.list.v2+json
Accept-Encoding: gzip
User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)

curl -v --compressed -H 'Accept: application/vnd.oci.image.manifest.v1+json,application/vnd.docker.distribution.manifest.v2+json,application/vnd.docker.distribution.manifest.v1+json,application/vnd.docker.distribution.manifest.list.v2+json' -H 'Accept-Encoding: gzip' -H 'User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)' -- 'https://registry-1.docker.io/v2/amazon/aws-lambda-java/manifests/11'
-------------- RESPONSE --------------
HTTP/1.1 401 Unauthorized
Content-Type: application/json
Docker-Distribution-Api-Version: registry/2.0
Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:amazon/aws-lambda-java:pull"
Date: Mon, 15 Feb 2021 15:46:13 GMT
Content-Length: 165
Strict-Transport-Security: max-age=31536000
The base image requires auth. Trying again for amazon/aws-lambda-java:11...
No credentials could be retrieved for registry-1.docker.io/amazon/aws-lambda-java
Executing tasks:
[                              ] 0.0% complete
> pulling base image manifest

-------------- REQUEST  --------------
GET https://auth.docker.io/token?service=registry.docker.io&scope=repository:amazon/aws-lambda-java:pull
Accept: */*
Accept-Encoding: gzip
User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)

curl -v --compressed -H 'Accept: */*' -H 'Accept-Encoding: gzip' -H 'User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)' -- 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:amazon/aws-lambda-java:pull'
-------------- RESPONSE --------------
HTTP/1.1 200 OK
Content-Type: application/json
Date: Mon, 15 Feb 2021 15:46:13 GMT
Transfer-Encoding: chunked
Strict-Transport-Security: max-age=31536000

Total: 4,370 bytes
{"token":"<redacted>","expires_in":300,"issued_at":"2021-02-15T15:46:13.26417122Z"}

-------------- REQUEST  --------------
GET https://registry-1.docker.io/v2/amazon/aws-lambda-java/manifests/11
Accept: application/vnd.oci.image.manifest.v1+json,application/vnd.docker.distribution.manifest.v2+json,application/vnd.docker.distribution.manifest.v1+json,application/vnd.docker.distribution.manifest.list.v2+json
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)

curl -v --compressed -H 'Accept: application/vnd.oci.image.manifest.v1+json,application/vnd.docker.distribution.manifest.v2+json,application/vnd.docker.distribution.manifest.v1+json,application/vnd.docker.distribution.manifest.list.v2+json' -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)' -- 'https://registry-1.docker.io/v2/amazon/aws-lambda-java/manifests/11'
-------------- RESPONSE --------------
HTTP/1.1 200 OK
Content-Length: 1580
Content-Type: application/vnd.docker.distribution.manifest.v2+json
Docker-Content-Digest: sha256:801e43678e238903893085c6e9105a0e9d7efc379b6d2a38752a6a16ff96b83a
Docker-Distribution-Api-Version: registry/2.0
Etag: "sha256:801e43678e238903893085c6e9105a0e9d7efc379b6d2a38752a6a16ff96b83a"
Date: Mon, 15 Feb 2021 15:46:13 GMT
Strict-Transport-Security: max-age=31536000
RateLimit-Limit: 100;w=21600
RateLimit-Remaining: 80;w=21600

Total: 1,580 bytes
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
   "config": {
      "mediaType": "application/vnd.docker.container.image.v1+json",
      "size": 2888,
      "digest": "sha256:382c81da26b147bcaa0e0a46640a30f9f65364c380cc7c30336acccc1d29eb74"
   },
   "layers": [
      {
         "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
         "size": 100753295,
         "digest": "sha256:5db394153f458493e9a627e2acbc32cb1f653e134f68c03870f164ff29a8a541"
      },
      {
         "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
         "size": 75012,
         "digest": "sha256:a361664b70ca6bf0a1d3c8b4a206a79855dc09b3a38f26a07519dc37ad936356"
      },
      {
         "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
         "size": 418,
         "digest": "sha256:3adf1af4c33c0b6807cfa453014cc7b72254907cdbc78c08aec6eb9cac7ae03c"
      },
      {
         "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
         "size": 3310349,
         "digest": "sha256:03ac043af787c8cb06d6a7f8289c62cf97e630b08011717197ab2adb087d061d"
      },
      {
         "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
         "size": 65193128,
         "digest": "sha256:0361b35e6e0203ab55683be6a6faa54581eeb5038b0beef46203cf505d4c8633"
      },
      {
         "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
         "size": 2716317,
Using base image with digest: sha256:801e43678e238903893085c6e9105a0e9d7efc379b6d2a38752a6a16ff96b83a
Executing tasks:
[                              ] 0.0% complete
> pulling base image manifest

-------------- REQUEST  --------------
GET https://registry-1.docker.io/v2/amazon/aws-lambda-java/blobs/sha256:382c81da26b147bcaa0e0a46640a30f9f65364c380cc7c30336acccc1d29eb74
Accept:
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)

curl -v --compressed -H 'Accept: ' -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)' -- 'https://registry-1.docker.io/v2/amazon/aws-lambda-java/blobs/sha256:382c81da26b147bcaa0e0a46640a30f9f65364c380cc7c30336acccc1d29eb74'
-------------- RESPONSE --------------
HTTP/1.1 307 Temporary Redirect
Content-Type: application/octet-stream
Docker-Distribution-Api-Version: registry/2.0
Location: https://docker-images-prod.s3.amazonaws.com/registry-v2/docker/registry/v2/blobs/sha256/38/382c81da26b147bcaa0e0a46640a30f9f65364c380cc7c30336acccc1d29eb74/data?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=<redacted>%2F20210215%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210215T154613Z&X-Amz-Expires=1200&X-Amz-Security-Token=<REDACTED_TOKEN>&X-Amz-SignedHeaders=host&X-Amz-Signature=7a2fdd56250cfb3f68f3fd2473b897cc64697e4436c6e583f34fc0df3edc1f47
Date: Mon, 15 Feb 2021 15:46:13 GMT
Content-Length: 0
Strict-Transport-Security: max-age=31536000

-------------- REQUEST  --------------
GET https://docker-images-prod.s3.amazonaws.com/registry-v2/docker/registry/v2/blobs/sha256/38/382c81da26b147bcaa0e0a46640a30f9f65364c380cc7c30336acccc1d29eb74/data?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=<redacted>%2F20210215%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210215T154613Z&X-Amz-Expires=1200&X-Amz-Security-Token=<REDACTED_TOKEN>&X-Amz-SignedHeaders=host&X-Amz-Signature=7a2fdd56250cfb3f68f3fd2473b897cc64697e4436c6e583f34fc0df3edc1f47
Accept:
Accept-Encoding: gzip
User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)

curl -v --compressed -H 'Accept: ' -H 'Accept-Encoding: gzip' -H 'User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)' -- 'https://docker-images-prod.s3.amazonaws.com/registry-v2/docker/registry/v2/blobs/sha256/38/382c81da26b147bcaa0e0a46640a30f9f65364c380cc7c30336acccc1d29eb74/data?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=<redacted>%2F20210215%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210215T154613Z&X-Amz-Expires=1200&X-Amz-Security-Token=<REDACTED> I/O error for image [registry-1.docker.io/amazon/aws-lambda-java]:
    javax.net.ssl.SSLPeerUnverifiedException
    Certificate for <docker-images-prod.s3.amazonaws.com> doesn't match any of the subject alternative names: [*.s3.amazonaws.com, s3.amazonaws.com]

Additional Information:

There was a similar verification issue encountered with apache-httpcomponents

@chanseokoh
Copy link
Member

chanseokoh commented Feb 17, 2021

@daxroc thanks for the report. But there's something that doesn't fit.

According to the Apache httpcomponents:httpclient release notes, 4.5.12 should fix the regression. (UPDATE: the regression and the bug fix in the release note below are about non-standard domains and private domains of PSL, which don't apply to ....s3.amazonaws.com.)

Apache HttpClient release notes
Release 4.5.12
-------------------

This is a maintenance release that fixes a regression introduced by the previous release
that caused rejection of certificates with non-standard domains.

Changelog:
-------------------

* HTTPCLIENT-2053: Add SC_PERMANENT_REDIRECT (308) to DefaultRedirectStrategy
  Contributed by Michael Osipov <michaelo at apache.org>

* HTTPCLIENT-2052: Fixed redirection of entity enclosing requests with non-repeatable entities
  Contributed by Oleg Kalnichevski <olegk at apache.org>

* HTTPCLIENT-2047: Fixed regression in DefaultHostnameVerifier causing rejection of certificates
  with non-standard domains.
  Contributed by Oleg Kalnichevski <olegk at apache.org>

* Bug fix: Fixed handling of private domains by PublicSuffixMatcher
  Contributed by Oleg Kalnichevski <olegk at apache.org>

And according to the google-http-java-client 1.35.0 release note, it upgraded the Apache httpclient to 4.5.12.

Dependencies

And I cannot reproduce the failure. With Jib 2.7.1 (using google-http-java-client 1.38.0), it has no problem interacting with https://docker-images-prod.s3.amazonaws.com:

log
16:21:32.935 [INFO] [com.google.api.client.http.HttpTransport] -------------- REQUEST  --------------
GET https://docker-images-prod.s3.amazonaws.com/v2/foo/bar/manifests/latest
Accept: application/vnd.oci.image.manifest.v1+json,application/vnd.docker.distribution.manifest.v2+json,application/vnd.docker.distribution.manifest.v1+json,application/vnd.docker.distribution.manifest.list.v2+json
Accept-Encoding: gzip
User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)

16:21:32.936 [INFO] [com.google.api.client.http.HttpTransport] curl -v --compressed -H 'Accept: application/vnd.oci.image.manifest.v1+json,application/vnd.docker.distribution.manifest.v2+json,application/vnd.docker.distribution.manifest.v1+json,application/vnd.docker.distribution.manifest.list.v2+json' -H 'Accept-Encoding: gzip' -H 'User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)' -- 'https://docker-images-prod.s3.amazonaws.com/v2/foo/bar/manifests/latest'
16:21:33.341 [INFO] [com.google.api.client.http.HttpTransport] -------------- RESPONSE --------------
HTTP/1.1 403 Forbidden
x-amz-request-id: E8625C07290C1F71
x-amz-id-2: 1QlrOhM6xudbR4vQBp6LVRaQkAKPKcNDGObubGWl6mo18zIiVhLRejkUeIa0SbOmYZKB6qvfQzs=
Content-Type: application/xml
Transfer-Encoding: chunked
Date: Wed, 17 Feb 2021 21:21:32 GMT
Server: AmazonS3

16:21:33.348 [INFO] [com.google.api.client.http.HttpTransport] Total: 243 bytes
16:21:33.348 [INFO] [com.google.api.client.http.HttpTransport] <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>E8625C07290C1F71</RequestId><HostId>1QlrOhM6xudbR4vQBp6LVRaQkAKPKcNDGObubGWl6mo18zIiVhLRejkUeIa0SbOmYZKB6qvfQzs=</HostId></Error>
16:21:33.377 [INFO] [com.google.api.client.http.HttpTransport] -------------- REQUEST  --------------
GET https://docker-images-prod.s3.amazonaws.com/v2/
Accept:
Accept-Encoding: gzip
User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)

16:21:33.377 [INFO] [com.google.api.client.http.HttpTransport] curl -v --compressed -H 'Accept: ' -H 'Accept-Encoding: gzip' -H 'User-Agent: jib 2.7.1 jib-gradle-plugin Google-HTTP-Java-Client/1.38.0 (gzip)' -- 'https://docker-images-prod.s3.amazonaws.com/v2/'
16:21:33.519 [INFO] [com.google.api.client.http.HttpTransport] -------------- RESPONSE --------------
HTTP/1.1 403 Forbidden
x-amz-request-id: BC2B2F102757EBE8
x-amz-id-2: To+3S6+PvsyodNrAp9341Y/Y8uMGO0+LzY7r3JnzCvNbW1fudCqOmgKHuYjJAJCWuDv5rwNiJuE=
Content-Type: application/xml
Transfer-Encoding: chunked
Date: Wed, 17 Feb 2021 21:21:33 GMT
Server: AmazonS3

It makes me suspect that your build environment inadvertently pulls in an old version of Apache httpclient. In my case, ./gradlew buildEnv shows Jib 2.7.1 brings in Apache HttpClient 4.5.13.

@chanseokoh
Copy link
Member

Actually, what you see from ./gradlew buildEnv can be deceptive. Is this a multi-module project? If so, also check out this FAQ, and ensure that the latest transitively dependency versions are pulled in.

@chanseokoh
Copy link
Member

@daxroc any update on this? We plan to make a release soon, and so far, it doesn't seem like we need to downgrade the Google HTTP Client with the new release. This looks like a project configuration issue in your project.

@daxroc
Copy link
Author

daxroc commented Feb 19, 2021 via email

@chanseokoh
Copy link
Member

chanseokoh commented Feb 22, 2021

Maybe you can even start with a simple hello world app on the build env to see if it's a project configuration issue.

It is odd local builds succeed

UPDATE(8/20/2021): now I start to think a regional location may be a factor to this.

@chanseokoh
Copy link
Member

Any update on this?

@paulolieuthier
Copy link

paulolieuthier commented Mar 5, 2021

Hi @chanseokoh, I can reproduce the problem on my build servers, just like @daxroc described, using 2.7.1 or 2.8.0. 2.7.0 works fine. This is the result of ./gradlew buildEnv:

2.7.1 ./gradlew buildEnv (click to expand)
> Task :buildEnvironment

------------------------------------------------------------
Root project 'xxxxx'
------------------------------------------------------------

classpath
+--- com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:6.1.0
|    \--- com.github.jengelman.gradle.plugins:shadow:6.1.0
|         +--- org.jdom:jdom2:2.0.6
|         +--- org.ow2.asm:asm:9.0
|         +--- org.ow2.asm:asm-commons:9.0
|         |    +--- org.ow2.asm:asm:9.0
|         |    +--- org.ow2.asm:asm-tree:9.0
|         |    |    \--- org.ow2.asm:asm:9.0
|         |    \--- org.ow2.asm:asm-analysis:9.0
|         |         \--- org.ow2.asm:asm-tree:9.0 (*)
|         +--- commons-io:commons-io:2.5 -> 2.6
|         +--- org.apache.ant:ant:1.9.7
|         |    \--- org.apache.ant:ant-launcher:1.9.7
|         +--- org.codehaus.plexus:plexus-utils:3.0.24
|         +--- org.apache.logging.log4j:log4j-core:2.13.3
|         |    \--- org.apache.logging.log4j:log4j-api:2.13.3
|         \--- org.vafer:jdependency:2.1.1
|              \--- commons-io:commons-io:2.6
+--- de.undercouch.download:de.undercouch.download.gradle.plugin:4.1.1
|    \--- de.undercouch:gradle-download-task:4.1.1
+--- com.google.cloud.tools.jib:com.google.cloud.tools.jib.gradle.plugin:2.7.1
|    \--- gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:2.7.1
|         +--- com.google.http-client:google-http-client:1.38.0
|         |    +--- org.apache.httpcomponents:httpclient:4.5.13
|         |    |    +--- org.apache.httpcomponents:httpcore:4.4.13
|         |    |    +--- commons-logging:commons-logging:1.2
|         |    |    \--- commons-codec:commons-codec:1.11
|         |    +--- org.apache.httpcomponents:httpcore:4.4.13
|         |    +--- com.google.code.findbugs:jsr305:3.0.2
|         |    +--- com.google.guava:guava:30.0-android -> 30.1-jre
|         |    |    +--- com.google.guava:failureaccess:1.0.1
|         |    |    +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
|         |    |    +--- com.google.code.findbugs:jsr305:3.0.2
|         |    |    +--- org.checkerframework:checker-qual:3.5.0
|         |    |    +--- com.google.errorprone:error_prone_annotations:2.3.4
|         |    |    \--- com.google.j2objc:j2objc-annotations:1.3
|         |    +--- com.google.j2objc:j2objc-annotations:1.3
|         |    +--- io.opencensus:opencensus-api:0.24.0
|         |    |    \--- io.grpc:grpc-context:1.22.1
|         |    \--- io.opencensus:opencensus-contrib-http-util:0.24.0
|         |         +--- io.opencensus:opencensus-api:0.24.0 (*)
|         |         \--- com.google.guava:guava:26.0-android -> 30.1-jre (*)
|         +--- com.google.http-client:google-http-client-apache-v2:1.38.0
|         |    +--- com.google.http-client:google-http-client:1.38.0 (*)
|         |    +--- org.apache.httpcomponents:httpclient:4.5.13 (*)
|         |    \--- org.apache.httpcomponents:httpcore:4.4.13
|         +--- com.google.auth:google-auth-library-oauth2-http:0.22.2
|         |    +--- com.google.auto.value:auto-value-annotations:1.7.4
|         |    +--- com.google.code.findbugs:jsr305:3.0.2
|         |    +--- com.google.auth:google-auth-library-credentials:0.22.2
|         |    +--- com.google.http-client:google-http-client:1.38.0 (*)
|         |    +--- com.google.http-client:google-http-client-jackson2:1.38.0
|         |    |    +--- com.google.http-client:google-http-client:1.38.0 (*)
|         |    |    \--- com.fasterxml.jackson.core:jackson-core:2.11.3 -> 2.12.0
|         |    |         \--- com.fasterxml.jackson:jackson-bom:2.12.0
|         |    |              +--- com.fasterxml.jackson.core:jackson-annotations:2.12.0 (c)
|         |    |              +--- com.fasterxml.jackson.core:jackson-core:2.12.0 (c)
|         |    |              +--- com.fasterxml.jackson.core:jackson-databind:2.12.0 (c)
|         |    |              \--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.0 (c)
|         |    \--- com.google.guava:guava:30.0-android -> 30.1-jre (*)
|         +--- org.apache.commons:commons-compress:1.20
|         +--- com.google.guava:guava:30.1-jre (*)
|         +--- com.fasterxml.jackson.core:jackson-databind:2.12.0
|         |    +--- com.fasterxml.jackson.core:jackson-annotations:2.12.0
|         |    |    \--- com.fasterxml.jackson:jackson-bom:2.12.0 (*)
|         |    +--- com.fasterxml.jackson.core:jackson-core:2.12.0 (*)
|         |    \--- com.fasterxml.jackson:jackson-bom:2.12.0 (*)
|         +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.0
|         |    +--- com.fasterxml.jackson.core:jackson-annotations:2.12.0 (*)
|         |    +--- com.fasterxml.jackson.core:jackson-core:2.12.0 (*)
|         |    +--- com.fasterxml.jackson.core:jackson-databind:2.12.0 (*)
|         |    \--- com.fasterxml.jackson:jackson-bom:2.12.0 (*)
|         +--- org.ow2.asm:asm:9.0
|         +--- com.google.cloud.tools:jib-build-plan:0.4.0
|         +--- com.google.cloud.tools:jib-plugins-extension-common:0.2.0
|         \--- com.google.cloud.tools:jib-gradle-plugin-extension-api:0.4.0
|              +--- com.google.cloud.tools:jib-build-plan:0.4.0
|              \--- com.google.cloud.tools:jib-plugins-extension-common:0.2.0
+--- com.google.protobuf:com.google.protobuf.gradle.plugin:0.8.12
|    \--- gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.12
|         +--- com.google.guava:guava:27.0.1-jre -> 30.1-jre (*)
|         +--- com.google.gradle:osdetector-gradle-plugin:1.6.2
|         |    \--- kr.motd.maven:os-maven-plugin:1.6.2
|         |         \--- com.google.code.findbugs:jsr305:3.0.2
|         \--- commons-lang:commons-lang:2.6
\--- com.diffplug.spotless:com.diffplug.spotless.gradle.plugin:5.10.1
     \--- com.diffplug.spotless:spotless-plugin-gradle:5.10.1
          +--- com.diffplug.spotless:spotless-lib:2.12.0
          +--- com.diffplug.spotless:spotless-lib-extra:2.12.0
          |    +--- com.diffplug.spotless:spotless-lib:2.12.0
          |    +--- com.diffplug.durian:durian-core:1.2.0
          |    +--- com.diffplug.durian:durian-collect:1.2.0
          |    |    \--- com.diffplug.durian:durian-core:1.2.0
          |    +--- org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r
          |    |    +--- com.googlecode.javaewah:JavaEWAH:1.1.7
          |    |    \--- org.slf4j:slf4j-api:1.7.30
          |    +--- com.googlecode.concurrent-trees:concurrent-trees:2.6.1
          |    \--- org.codehaus.groovy:groovy-xml:3.0.7
          |         \--- org.codehaus.groovy:groovy:3.0.7
          +--- com.diffplug.durian:durian-core:1.2.0
          +--- com.diffplug.durian:durian-io:1.2.0
          |    +--- com.diffplug.durian:durian-core:1.2.0
          |    \--- com.diffplug.durian:durian-collect:1.2.0 (*)
          +--- com.diffplug.durian:durian-collect:1.2.0 (*)
          \--- org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r (*)

(c) - dependency constraint
(*) - dependencies omitted (listed previously)

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 5s
1 actionable task: 1 executed

@chanseokoh
Copy link
Member

Can you also share the output when it is 2.7.0?

And is this a multi-module project? If so, can you share your build.gradle files?

@paulolieuthier
Copy link

paulolieuthier commented Mar 6, 2021

And is this a multi-module project? If so, can you share your build.gradle files?

settings.gradle
pluginManagement {
    repositories {
        gradlePluginPortal()
        mavenCentral()
    }
}

rootProject.name="<redacted>"

include 'api'
include 'common'
include 'consumer'
include 'db'
api/build.gradle
mainClassName = '<redacted>'

ext {
    dockerBasicImageName = "<redacted>"
}

sourceSets {
    main {
        proto.srcDir "${project.rootDir}/<redacted>/proto"
    }
}

dependencies {
    implementation project(":common")
    implementation project(":db")
}

jib {
    to.image = "${dockerBasicImageName}"
}
build.gradle
plugins {
    id "com.github.johnrengelman.shadow" version "6.1.0" apply false
    id "de.undercouch.download" version "4.1.1"
    id 'com.google.cloud.tools.jib' version '2.8.0' apply false
    id 'java'
    id 'com.google.protobuf' version '0.8.12' apply false
    id "com.diffplug.spotless" version "5.10.1" apply false
}

version = "0.1.0"

allprojects {
    repositories {
        ...
    }
}

ext {
    raygunVersion = '[2.0.0,3.0.0)'
    micronautProjects = ['api', 'consumer', 'common', 'db']
    micronautCassandraProjects = ['api', 'consumer', 'db']
    micronautGrpcProjects = ['api']
    executableProjects = ['api', 'consumer']
    glowrootVersion = "0.13.5"
    glowrootUrl = "https://github.com/glowroot/glowroot/releases/download/v$glowrootVersion/glowroot-$glowrootVersion-dist.zip"
}

def getGitHash = { ->
    def stdout = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'rev-parse', '--short', 'HEAD'
        standardOutput = stdout
    }
    return stdout.toString().trim()
}

task downloadApmAgent(type: Download) {
    src glowrootUrl
    dest "${buildDir}/glowroot_agent.zip"
    overwrite false
}

configure(subprojects.findAll{it.name in micronautProjects}) {
    apply plugin: 'java'
    apply plugin: 'com.github.johnrengelman.shadow'
    apply plugin: 'com.diffplug.spotless'

    sourceCompatibility = 11
    targetCompatibility = 11

    ext {
        micronautVersion='2.3.3'
    }

    configurations {
        testCompileOnly.extendsFrom compileOnly
        testAnnotationProcessor.extendsFrom annotationProcessor
    }

    dependencies {
        compileOnly "org.projectlombok:lombok"
        annotationProcessor "org.projectlombok:lombok"

        annotationProcessor platform("io.micronaut:micronaut-bom:$micronautVersion")
        annotationProcessor "io.micronaut:micronaut-inject-java"
        annotationProcessor "io.micronaut:micronaut-validation"
        implementation platform("io.micronaut:micronaut-bom:$micronautVersion")
        implementation "io.micronaut:micronaut-inject"
        implementation "io.micronaut:micronaut-validation"
        implementation "io.micronaut:micronaut-runtime"
        implementation "io.micronaut:micronaut-management"
        implementation "io.micronaut.micrometer:micronaut-micrometer-registry-prometheus"

        implementation "com.mindscapehq:core:$raygunVersion"
        implementation "com.mindscapehq:raygun4java:$raygunVersion"

        <redacted>

        runtimeOnly "ch.qos.logback:logback-classic:1.2.3"

        testAnnotationProcessor platform("io.micronaut:micronaut-bom:$micronautVersion")
        testAnnotationProcessor "io.micronaut:micronaut-inject-java"
        testImplementation platform("io.micronaut:micronaut-bom:$micronautVersion")
        testImplementation "org.junit.jupiter:junit-jupiter-api"
        testImplementation "org.junit.jupiter:junit-jupiter-params"
        testImplementation "io.micronaut.test:micronaut-test-junit5"
        testImplementation "org.assertj:assertj-core"
        testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
        testImplementation "org.mockito:mockito-core"
        testImplementation "org.mockito:mockito-junit-jupiter:3.6.28"
    }

    test {
        useJUnitPlatform()
        testLogging {
            exceptionFormat = 'full'
        }
    }

    spotless {
        java {
            googleJavaFormat()
            targetExclude(fileTree("$buildDir/generated") { include("**/*.java") })
        }
    }

    tasks.withType(JavaCompile) {
        options.encoding = "UTF-8"
        options.compilerArgs.add('-parameters')
    }

    shadowJar {
        mergeServiceFiles()
    }
}

configure(subprojects.findAll{it.name in executableProjects}) {
    apply plugin: 'com.google.cloud.tools.jib'
    apply plugin: 'application'

    ext.getGitHash = getGitHash

    dependencies {
        implementation 'io.micronaut:micronaut-http-server-netty'
    }

    ext {
        agentLocation = "/opt/glowroot"
        jibExtraDirectory = "${buildDir}/jib-agents"
    }

    task extractApmAgent(dependsOn: downloadApmAgent, type: Copy) {
        from zipTree(downloadApmAgent.dest)
        into "${jibExtraDirectory}/${agentLocation}"
    }

    jib {
        from.image = 'adoptopenjdk:11-jre-hotspot'
        extraDirectories.paths = [file(jibExtraDirectory)]
        container {
            jvmFlags = [
                    '-XX:InitialRAMPercentage=60.0',
                    '-XX:MaxRAMPercentage=60.0',
                    '-javaagent:' + agentLocation + '/glowroot/glowroot.jar'
            ]
        }
    }
    tasks.jib.dependsOn extractApmAgent
    tasks.jibDockerBuild.dependsOn extractApmAgent
    tasks.jibBuildTar.dependsOn extractApmAgent
}

configure(subprojects.findAll{it.name in micronautCassandraProjects}) {
    ext {
        scyllaDriverVersion = '4.9.0-scylla-0'
    }

    dependencies {
        implementation group: 'com.scylladb', name: 'java-driver-core', version: scyllaDriverVersion
        implementation group: 'com.scylladb', name: 'java-driver-query-builder', version: scyllaDriverVersion
        implementation group: 'com.scylladb', name: 'java-driver-metrics-micrometer', version: scyllaDriverVersion
        implementation 'ch.hsr:geohash:1.3.0'

        implementation("io.micronaut.cassandra:micronaut-cassandra") {
            exclude group: "com.datastax.oss", module: "java-driver-core"
            exclude group: "com.datastax.oss", module: "java-driver-mapper-processor"
        }
    }
}

configure(subprojects.findAll{it.name in micronautGrpcProjects}) {
    apply plugin: "com.google.protobuf"
    ext {
        protocVersion = "3.15.4"
        grpcVersion = "1.33.1"
    }

    sourceSets {
        main {
            java {
                srcDirs 'build/generated/source/proto/main/grpc'
                srcDirs 'build/generated/source/proto/main/java'
            }
        }
    }

    dependencies {
        implementation("com.google.protobuf:protobuf-java:${protocVersion}")
        implementation("io.micronaut:micronaut-http-server-netty")
        implementation("io.micronaut.grpc:micronaut-grpc-runtime")
        implementation("me.dinowernli:java-grpc-prometheus:0.3.0") {
            exclude group: "io.grpc", module: "grpc-rls"
            exclude group: "io.grpc", module: "grpc-netty-shaded"
            exclude group: "io.grpc", module: "grpc-xds"
        }
    }
    configurations.testImplementation {
        exclude group: "io.grpc", module: "grpc-okhttp"
    }

    protobuf {
        protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" }
        plugins {
            grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
        }
        generateProtoTasks {
            all()*.plugins { grpc {} }
        }
    }
}

java {
    sourceCompatibility = JavaVersion.toVersion("11")
    targetCompatibility = JavaVersion.toVersion("11")
}

wrapper {
    gradleVersion = '6.9'
    // waiting for https://github.com/gradle/gradle/pull/15333 to be released
    distributionUrl = '<redacted>'
}
consumer/build.gradle
import com.github.davidmc24.gradle.plugin.avro.GenerateAvroJavaTask

plugins {
    id "com.github.davidmc24.gradle.plugin.avro" version "1.0.0"
}

mainClassName = '<redacted>'

sourceSets {
    main {
        java {
            srcDir "${buildDir.absolutePath}/generated/sources/avro/main/java"
        }
    }
    test {
        java {
            srcDir "${buildDir.absolutePath}/generated/sources/avro/main/java"
        }
    }
}

task generateAvro(type: GenerateAvroJavaTask) {
    source("${project.rootDir}/<redacted>/avro/")
    outputDir = file("${buildDir.absolutePath}/generated/sources/avro/main/java")
}

compileJava.source(generateAvro.outputs)

ext {
    dockerBasicImageName = "<redacted>"
}

dependencies {
    implementation project(":db")
    implementation project(":common")

    implementation("io.confluent:kafka-avro-serializer:5.4.1")
    implementation("io.micronaut.kafka:micronaut-kafka")
    implementation("org.apache.avro:avro:1.10.1")
    implementation("com.inloco:kafka-auth-k8s:0.0.3")

    testImplementation project(':db').sourceSets.test.output
}

jib {
    to.image = "${dockerBasicImageName}"
}
db/build.gradle
dependencies {
    implementation project(":common")
}

Can you also share the output when it is 2.7.0?

2.7.0 ./gradlew buildEnv
> Task :buildEnvironment

------------------------------------------------------------
Root project '<redacted>'
------------------------------------------------------------

classpath
+--- com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:6.1.0
|    \--- com.github.jengelman.gradle.plugins:shadow:6.1.0
|         +--- org.jdom:jdom2:2.0.6
|         +--- org.ow2.asm:asm:9.0
|         +--- org.ow2.asm:asm-commons:9.0
|         |    +--- org.ow2.asm:asm:9.0
|         |    +--- org.ow2.asm:asm-tree:9.0
|         |    |    \--- org.ow2.asm:asm:9.0
|         |    \--- org.ow2.asm:asm-analysis:9.0
|         |         \--- org.ow2.asm:asm-tree:9.0 (*)
|         +--- commons-io:commons-io:2.5 -> 2.6
|         +--- org.apache.ant:ant:1.9.7
|         |    \--- org.apache.ant:ant-launcher:1.9.7
|         +--- org.codehaus.plexus:plexus-utils:3.0.24
|         +--- org.apache.logging.log4j:log4j-core:2.13.3
|         |    \--- org.apache.logging.log4j:log4j-api:2.13.3
|         \--- org.vafer:jdependency:2.1.1
|              \--- commons-io:commons-io:2.6
+--- de.undercouch.download:de.undercouch.download.gradle.plugin:4.1.1
|    \--- de.undercouch:gradle-download-task:4.1.1
+--- com.google.cloud.tools.jib:com.google.cloud.tools.jib.gradle.plugin:2.7.0
|    \--- gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:2.7.0
|         +--- com.google.http-client:google-http-client:1.34.0
|         |    +--- org.apache.httpcomponents:httpclient:4.5.10
|         |    |    +--- org.apache.httpcomponents:httpcore:4.4.12
|         |    |    +--- commons-logging:commons-logging:1.2
|         |    |    \--- commons-codec:commons-codec:1.11
|         |    +--- org.apache.httpcomponents:httpcore:4.4.12
|         |    +--- com.google.code.findbugs:jsr305:3.0.2
|         |    +--- com.google.guava:guava:28.1-android -> 30.0-jre
|         |    |    +--- com.google.guava:failureaccess:1.0.1
|         |    |    +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
|         |    |    +--- com.google.code.findbugs:jsr305:3.0.2
|         |    |    +--- org.checkerframework:checker-qual:3.5.0
|         |    |    +--- com.google.errorprone:error_prone_annotations:2.3.4
|         |    |    \--- com.google.j2objc:j2objc-annotations:1.3
|         |    +--- com.google.j2objc:j2objc-annotations:1.3
|         |    +--- io.opencensus:opencensus-api:0.24.0
|         |    |    \--- io.grpc:grpc-context:1.22.1
|         |    \--- io.opencensus:opencensus-contrib-http-util:0.24.0
|         |         +--- io.opencensus:opencensus-api:0.24.0 (*)
|         |         \--- com.google.guava:guava:26.0-android -> 30.0-jre (*)
|         +--- com.google.http-client:google-http-client-apache-v2:1.34.0
|         |    +--- com.google.http-client:google-http-client:1.34.0 (*)
|         |    +--- org.apache.httpcomponents:httpclient:4.5.10 (*)
|         |    \--- org.apache.httpcomponents:httpcore:4.4.12
|         +--- com.google.auth:google-auth-library-oauth2-http:0.18.0
|         |    +--- com.google.auto.value:auto-value-annotations:1.6.6
|         |    +--- com.google.code.findbugs:jsr305:3.0.2
|         |    +--- com.google.auth:google-auth-library-credentials:0.18.0
|         |    +--- com.google.http-client:google-http-client:1.32.1 -> 1.34.0 (*)
|         |    +--- com.google.http-client:google-http-client-jackson2:1.32.1
|         |    |    +--- com.google.http-client:google-http-client:1.32.1 -> 1.34.0 (*)
|         |    |    \--- com.fasterxml.jackson.core:jackson-core:2.9.9 -> 2.11.3
|         |    \--- com.google.guava:guava:28.1-android -> 30.0-jre (*)
|         +--- org.apache.commons:commons-compress:1.20
|         +--- com.google.guava:guava:30.0-jre (*)
|         +--- com.fasterxml.jackson.core:jackson-databind:2.11.3
|         |    +--- com.fasterxml.jackson.core:jackson-annotations:2.11.3
|         |    \--- com.fasterxml.jackson.core:jackson-core:2.11.3
|         +--- org.ow2.asm:asm:9.0
|         +--- com.google.cloud.tools:jib-build-plan:0.4.0
|         +--- com.google.cloud.tools:jib-plugins-extension-common:0.2.0
|         \--- com.google.cloud.tools:jib-gradle-plugin-extension-api:0.4.0
|              +--- com.google.cloud.tools:jib-build-plan:0.4.0
|              \--- com.google.cloud.tools:jib-plugins-extension-common:0.2.0
+--- com.google.protobuf:com.google.protobuf.gradle.plugin:0.8.12
|    \--- gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.12
|         +--- com.google.guava:guava:27.0.1-jre -> 30.0-jre (*)
|         +--- com.google.gradle:osdetector-gradle-plugin:1.6.2
|         |    \--- kr.motd.maven:os-maven-plugin:1.6.2
|         |         \--- com.google.code.findbugs:jsr305:3.0.2
|         \--- commons-lang:commons-lang:2.6
\--- com.diffplug.spotless:com.diffplug.spotless.gradle.plugin:5.10.1
     \--- com.diffplug.spotless:spotless-plugin-gradle:5.10.1
          +--- com.diffplug.spotless:spotless-lib:2.12.0
          +--- com.diffplug.spotless:spotless-lib-extra:2.12.0
          |    +--- com.diffplug.spotless:spotless-lib:2.12.0
          |    +--- com.diffplug.durian:durian-core:1.2.0
          |    +--- com.diffplug.durian:durian-collect:1.2.0
          |    |    \--- com.diffplug.durian:durian-core:1.2.0
          |    +--- org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r
          |    |    +--- com.googlecode.javaewah:JavaEWAH:1.1.7
          |    |    \--- org.slf4j:slf4j-api:1.7.30
          |    +--- com.googlecode.concurrent-trees:concurrent-trees:2.6.1
          |    \--- org.codehaus.groovy:groovy-xml:3.0.7
          |         \--- org.codehaus.groovy:groovy:3.0.7
          +--- com.diffplug.durian:durian-core:1.2.0
          +--- com.diffplug.durian:durian-io:1.2.0
          |    +--- com.diffplug.durian:durian-core:1.2.0
          |    \--- com.diffplug.durian:durian-collect:1.2.0 (*)
          +--- com.diffplug.durian:durian-collect:1.2.0 (*)
          \--- org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r (*)

(*) - dependencies omitted (listed previously)

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 27s
1 actionable task: 1 executed

@chanseokoh
Copy link
Member

@paulolieuthier thank you very much for the info. Out of an abundance of caution, I think we should revert upgrading Google HTTP Client. But I should ask this last question: is it technically possible that you can reproduce the error with this hello-world example in your environment? (I guess you can just edit jib.from.image or jib.to.image in build.gradle to use a host that you have trouble verifying with.) The result will tell us a lot and help us file a bug against either Google HTTP Client or Apache HttpClient.

And is it possible to share the hostname in question so that we can also try accessing it on our side?

@paulolieuthier
Copy link

I just tested with the example project and the jib task run successfully with the same from image and same-host to image as my failing project. I even turned it into a simple multi-project setup and it worked as well... Unfortunately I don't have time to bitsect it.

I'm pushing to AWS' ECR.

@chanseokoh
Copy link
Member

chanseokoh commented Mar 8, 2021

Hmm... that gives more weight to a configuration issue in your project. (UPDATE: I lost the confidence in what I said.)

@paulolieuthier @daxroc @tburch there is an ultimate and indisputable workaround where you can force a particular dependency version used for the build script classpath. At the top of the root build.gradle, explicitly force (note force = true below) the desired Google HTTP Client and Apache HttpClient versions. Place them before any other dependencies, just in case. By doing so, I expect that you should be able to make Jib 2.7.1 or 2.8.0 work.

All of the 2.8.0, 2.7.1, and 2.7.0 dependencies should just work, so it's worth testing out all. (UPDATE: a user reported that only 2.7.0 dependencies worked.)

  • 2.7.0 dependencies
buildscript {
    repositories {
        mavenCentral()
        ...
    }
    dependencies {
        // note force = true below
        classpath('org.apache.httpcomponents:httpcore:4.4.12') { force = true }
        classpath('org.apache.httpcomponents:httpclient:4.5.10') { force = true }
        classpath('com.google.http-client:google-http-client:1.34.0') { force = true }
        classpath('com.google.http-client:google-http-client-apache-v2:1.34.0') { force = true }
        ...
    }
}
  • 2.7.1 dependencies
buildscript {
    repositories {
        mavenCentral()
        ...
    }
    dependencies {
        // note force = true below
        classpath('org.apache.httpcomponents:httpcore:4.4.13') { force = true }
        classpath('org.apache.httpcomponents:httpclient:4.5.13') { force = true }
        classpath('com.google.http-client:google-http-client:1.38.0') { force = true }
        classpath('com.google.http-client:google-http-client-apache-v2:1.38.0') { force = true }
        ...
    }
}
  • 2.8.0 dependencies
buildscript {
    repositories {
        mavenCentral()
        ...
    }
    dependencies {
        // note force = true below
        classpath('org.apache.httpcomponents:httpcore:4.4.14') { force = true }
        classpath('org.apache.httpcomponents:httpclient:4.5.13') { force = true }
        classpath('com.google.http-client:google-http-client:1.38.1') { force = true }
        classpath('com.google.http-client:google-http-client-apache-v2:1.38.1') { force = true }
        ...
    }
}

Running ./gradlew buildEnv should list these dependencies at the top. For example, when forcing 2.7.0 dependencies,

> Task :buildEnvironment

------------------------------------------------------------
Root project
------------------------------------------------------------

classpath
+--- org.apache.httpcomponents:httpcore:4.4.12
+--- org.apache.httpcomponents:httpclient:4.5.10
|    +--- org.apache.httpcomponents:httpcore:4.4.12
...
+--- com.google.http-client:google-http-client:1.34.0
|    +--- org.apache.httpcomponents:httpclient:4.5.10 (*)
|    +--- org.apache.httpcomponents:httpcore:4.4.12
...
+--- com.google.http-client:google-http-client-apache-v2:1.34.0
|    +--- com.google.http-client:google-http-client:1.34.0 (*)
|    +--- org.apache.httpcomponents:httpclient:4.5.10 (*)
|    \--- org.apache.httpcomponents:httpcore:4.4.12
\--- ...

@chanseokoh
Copy link
Member

@paulolieuthier @daxroc @tburch has anyone tried the workaround with all three version sets? It's a frequent Gradle issue that a Gradle build pulls in unintended dependency versions, and based on the observations so far, it still looks to me that it's a Gradle project configuration issue.

@chanseokoh
Copy link
Member

chanseokoh commented Mar 18, 2021

Closing due to inactivity. Based on the evidence so far, this doesn't seem like a regression. I'm suspecting a Gradle project dependency resolution issue, which is not uncommon.

For those who came here, the workaround in #3058 (comment) should work and allow you to move forward, but suggesting the workaround was mainly for verification purposes for us. (I'm still very much interested in hearing if all of the three version sets work or not.) If they do work, it implies that there's something going on with dependency version conflict and resolution in your project, and most likely, there will be a right way to configure it properly.

@mattupstate
Copy link

mattupstate commented Apr 27, 2021

I'm experiencing this with the v3.0.0 release. I've tried forcing dependency versions as described above but to no avail. I'm using the Kotlin DSL and I'm assuming this is the equivalent of the workaround above:

buildscript {
  repositories {
    mavenCentral()
  }
  configurations.classpath {
    resolutionStrategy {
      force("org.apache.httpcomponents:httpcore:4.4.13")
      force("org.apache.httpcomponents:httpclient:4.5.13")
      force("com.google.http-client:google-http-client:1.38.0")
      force("com.google.http-client:google-http-client-apache-v2:1.38.0")
    }
  }
}

If it's helpful, without trying to force the versions the build environment dep graph is:

buildEnvironment
> Task :buildEnvironment

------------------------------------------------------------
Root project 'acme'
------------------------------------------------------------

classpath
+--- org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.4.32
|    \--- org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32
|         +--- org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.4.32
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.32 -> 1.4.31
|         |         +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.4.31
|         |         \--- org.jetbrains:annotations:13.0
|         +--- org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.4.32
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.32 -> 1.4.31 (*)
|         +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.32 -> 1.4.31 (*)
|         +--- org.jetbrains.kotlin:kotlin-util-klib:1.4.32
|         |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.32 -> 1.4.31 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-util-io:1.4.32
|         |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.32 -> 1.4.31 (*)
|         +--- com.google.code.gson:gson:2.8.6
|         +--- de.undercouch:gradle-download-task:4.0.2 -> 4.0.4
|         +--- com.github.gundy:semver4j:0.16.4
|         |    \--- org.antlr:antlr4-runtime:4.5.2-1
|         +--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.4.32
|         |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.32 -> 1.4.31 (*)
|         |    +--- org.jetbrains.kotlin:kotlin-script-runtime:1.4.32
|         |    +--- org.jetbrains.kotlin:kotlin-reflect:1.4.32 -> 1.4.31
|         |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.31 (*)
|         |    +--- org.jetbrains.kotlin:kotlin-daemon-embeddable:1.4.32
|         |    \--- org.jetbrains.intellij.deps:trove4j:1.0.20181211
|         +--- org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.4.32
|         |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.32 -> 1.4.31 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.4.32 (*)
|         +--- org.jetbrains.kotlin:kotlin-android-extensions:1.4.32
|         |    \--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.4.32 (*)
|         +--- org.jetbrains.kotlin:kotlin-compiler-runner:1.4.32
|         |    +--- org.jetbrains.kotlin:kotlin-build-common:1.4.32
|         |    +--- org.jetbrains.kotlin:kotlin-daemon-client:1.4.32
|         |    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8
|         |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.71 -> 1.4.31 (*)
|         |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.71 -> 1.4.31
|         |    |    \--- org.jetbrains.kotlin:kotlin-reflect:1.4.32 -> 1.4.31 (*)
|         |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.4.32 (*)
|         +--- org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.4.32
|         |    +--- org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.4.32
|         |    |    +--- org.jetbrains.kotlin:kotlin-scripting-common:1.4.32
|         |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.32 -> 1.4.31 (*)
|         |    |    |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8 (*)
|         |    |    +--- org.jetbrains.kotlin:kotlin-scripting-jvm:1.4.32
|         |    |    |    +--- org.jetbrains.kotlin:kotlin-script-runtime:1.4.32
|         |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.32 -> 1.4.31 (*)
|         |    |    |    \--- org.jetbrains.kotlin:kotlin-scripting-common:1.4.32 (*)
|         |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.32 -> 1.4.31 (*)
|         |    |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.32 -> 1.4.31 (*)
|         +--- org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.4.32 (*)
|         \--- org.jetbrains.kotlin:kotlin-reflect:1.4.32 -> 1.4.31 (*)
+--- org.jetbrains.kotlin.plugin.serialization:org.jetbrains.kotlin.plugin.serialization.gradle.plugin:1.4.32
|    \--- org.jetbrains.kotlin:kotlin-serialization:1.4.32
|         \--- org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.4.32 (*)
+--- com.google.cloud.tools.jib:com.google.cloud.tools.jib.gradle.plugin:3.0.0
|    \--- gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:3.0.0
|         +--- com.google.http-client:google-http-client:1.38.1
|         |    +--- org.apache.httpcomponents:httpclient:4.5.13
|         |    |    +--- org.apache.httpcomponents:httpcore:4.4.13 -> 4.4.14
|         |    |    +--- commons-logging:commons-logging:1.2
|         |    |    \--- commons-codec:commons-codec:1.11
|         |    +--- org.apache.httpcomponents:httpcore:4.4.14
|         |    +--- com.google.code.findbugs:jsr305:3.0.2
|         |    +--- com.google.guava:guava:30.1-android -> 30.1-jre
|         |    |    +--- com.google.guava:failureaccess:1.0.1
|         |    |    +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
|         |    |    +--- com.google.code.findbugs:jsr305:3.0.2
|         |    |    +--- org.checkerframework:checker-qual:3.5.0
|         |    |    +--- com.google.errorprone:error_prone_annotations:2.3.4
|         |    |    \--- com.google.j2objc:j2objc-annotations:1.3
|         |    +--- com.google.j2objc:j2objc-annotations:1.3
|         |    +--- io.opencensus:opencensus-api:0.24.0
|         |    |    \--- io.grpc:grpc-context:1.22.1
|         |    \--- io.opencensus:opencensus-contrib-http-util:0.24.0
|         |         +--- io.opencensus:opencensus-api:0.24.0 (*)
|         |         \--- com.google.guava:guava:26.0-android -> 30.1-jre (*)
|         +--- com.google.http-client:google-http-client-apache-v2:1.38.1
|         |    +--- com.google.http-client:google-http-client:1.38.1 (*)
|         |    +--- org.apache.httpcomponents:httpclient:4.5.13 (*)
|         |    \--- org.apache.httpcomponents:httpcore:4.4.14
|         +--- com.google.auth:google-auth-library-oauth2-http:0.22.2
|         |    +--- com.google.auto.value:auto-value-annotations:1.7.4
|         |    +--- com.google.code.findbugs:jsr305:3.0.2
|         |    +--- com.google.auth:google-auth-library-credentials:0.22.2
|         |    +--- com.google.http-client:google-http-client:1.38.0 -> 1.38.1 (*)
|         |    +--- com.google.http-client:google-http-client-jackson2:1.38.0
|         |    |    +--- com.google.http-client:google-http-client:1.38.0 -> 1.38.1 (*)
|         |    |    \--- com.fasterxml.jackson.core:jackson-core:2.11.3 -> 2.12.1
|         |    |         \--- com.fasterxml.jackson:jackson-bom:2.12.1
|         |    |              +--- com.fasterxml.jackson.core:jackson-annotations:2.12.1 (c)
|         |    |              +--- com.fasterxml.jackson.core:jackson-core:2.12.1 (c)
|         |    |              +--- com.fasterxml.jackson.core:jackson-databind:2.12.1 (c)
|         |    |              \--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.1 (c)
|         |    \--- com.google.guava:guava:30.0-android -> 30.1-jre (*)
|         +--- org.apache.commons:commons-compress:1.20
|         +--- com.google.guava:guava:30.1-jre (*)
|         +--- com.fasterxml.jackson.core:jackson-databind:2.12.1
|         |    +--- com.fasterxml.jackson.core:jackson-annotations:2.12.1
|         |    |    \--- com.fasterxml.jackson:jackson-bom:2.12.1 (*)
|         |    +--- com.fasterxml.jackson.core:jackson-core:2.12.1 (*)
|         |    \--- com.fasterxml.jackson:jackson-bom:2.12.1 (*)
|         +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.1
|         |    +--- com.fasterxml.jackson.core:jackson-annotations:2.12.1 (*)
|         |    +--- com.fasterxml.jackson.core:jackson-core:2.12.1 (*)
|         |    +--- com.fasterxml.jackson.core:jackson-databind:2.12.1 (*)
|         |    \--- com.fasterxml.jackson:jackson-bom:2.12.1 (*)
|         +--- org.ow2.asm:asm:9.1
|         +--- com.google.cloud.tools:jib-build-plan:0.4.0
|         +--- com.google.cloud.tools:jib-plugins-extension-common:0.2.0
|         \--- com.google.cloud.tools:jib-gradle-plugin-extension-api:0.4.0
|              +--- com.google.cloud.tools:jib-build-plan:0.4.0
|              \--- com.google.cloud.tools:jib-plugins-extension-common:0.2.0
+--- org.jlleitschuh.gradle.ktlint:org.jlleitschuh.gradle.ktlint.gradle.plugin:10.0.0
|    \--- org.jlleitschuh.gradle:ktlint-gradle:10.0.0
|         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.30 -> 1.4.31
|              +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.31 (*)
|              \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31
|                   \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.31 (*)
+--- org.jlleitschuh.gradle.ktlint-idea:org.jlleitschuh.gradle.ktlint-idea.gradle.plugin:10.0.0
|    \--- org.jlleitschuh.gradle:ktlint-gradle:10.0.0 (*)
+--- de.undercouch.download:de.undercouch.download.gradle.plugin:4.0.4
|    \--- de.undercouch:gradle-download-task:4.0.4
+--- org.jetbrains.kotlin:kotlin-stdlib:{strictly 1.4.31} -> 1.4.31 (c)
+--- org.jetbrains.kotlin:kotlin-reflect:{strictly 1.4.31} -> 1.4.31 (c)
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:{strictly 1.4.31} -> 1.4.31 (c)
+--- org.jetbrains.kotlin:kotlin-stdlib-common:{strictly 1.4.31} -> 1.4.31 (c)
+--- org.jetbrains:annotations:{strictly 13.0} -> 13.0 (c)
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:{strictly 1.4.31} -> 1.4.31 (c)

@chanseokoh
Copy link
Member

@mattupstate seems like you tried 2.7.1 dependencies. What about 2.7.0 dependencies? The issue reported here is that 2.7.0 had been working, but it stopped working since 2.7.1.

@mattupstate
Copy link

@chanseokoh 🤦 thanks for that tip. That did the trick 🙇

@chanseokoh
Copy link
Member

chanseokoh commented Apr 27, 2021

Hmm... but that implies that Google HTTP Client dependencies above 2.7.0 do have a problem. I expected that forcing dependencies whether it's 2.7.0 or higher than that would resolve the issue. However, it seems not. :( Reopening for tracking.


BTW, for a multi-module Gradle project, the project should be set up in the way explained here to avoid using in unintended versions. That is, defining all of your plugins in the base project while applying them selectively in your subprojects as needed.

@chanseokoh chanseokoh reopened this Apr 27, 2021
@edgarvonk
Copy link

Just to note that we have the same issue with the 3.1.1 release. Downgrading the Google HTTP Client dependencies to 2.7.0 as per above works for us as well.

@evandroabukamel
Copy link

I'm using jib:3.1.2 with Kotlin and the code bellow solved for me. Thanks @mattupstate and @chanseokoh .

buildscript {
    repositories {
        mavenCentral()
    }
    configurations.classpath {
        resolutionStrategy {
            force("org.apache.httpcomponents:httpcore:4.4.12")
            force("org.apache.httpcomponents:httpclient:4.5.10")
            force("com.google.http-client:google-http-client:1.34.0")
            force("com.google.http-client:google-http-client-apache-v2:1.34.0")
        }
    }
}

@chanseokoh
Copy link
Member

chanseokoh commented Aug 11, 2021

@daxroc @paulolieuthier @tburch @adamthalhammer @mattupstate @edgarvonk @evandroabukamel FYI, we released Jib plugins 3.1.3 after upgrading Google HTTP Client to 1.39.2.

However, 1.39.2 doesn't seem to change the Apache HTTP Client versions from what they where in Jib 2.8.0 (which used Google HTTP Client 1.38.1), so I'm not too optimistic.

          +--- com.google.http-client:google-http-client:1.39.2                                                                                                                                                    
          |    +--- org.apache.httpcomponents:httpclient:4.5.13                                                                                                                                                    
          |    |    +--- org.apache.httpcomponents:httpcore:4.4.13 -> 4.4.14                                                                                                                                       
          ...
          |    +--- org.apache.httpcomponents:httpcore:4.4.14

          +--- com.google.http-client:google-http-client-apache-v2:1.39.2
          |    +--- com.google.http-client:google-http-client:1.39.2 (*)
          |    +--- org.apache.httpcomponents:httpclient:4.5.13 (*)  
          |    \--- org.apache.httpcomponents:httpcore:4.4.14 

Nonetheless, I wonder if 1.39.2 resolves the issue. Can anyone test out Jib 3.1.3? Also test forcing the following versions by Jib 3.1.3.

      org.apache.httpcomponents:httpcore:4.4.14
      org.apache.httpcomponents:httpclient:4.5.13
      com.google.http-client:google-http-client:1.39.2
      com.google.http-client:google-http-client-apache-v2:1.39.2

@racevedoo
Copy link

Tested with jib 3.1.3 without forcing dependencies, got the same problem.

@chanseokoh
Copy link
Member

Re-opening as the root cause is still unknown.

@chanseokoh chanseokoh reopened this Aug 13, 2021
@chanseokoh
Copy link
Member

chanseokoh commented Aug 17, 2021

@daxroc @racevedoo @paulolieuthier @tburch @adamthalhammer @mattupstate @edgarvonk @evandroabukamel

So we decided to downgrade Google HTTP libraries to 1.34.0. We just released Jib plugins 3.1.4 with the downgraded versions, which should avoid the issue (unless the libraries are still overridden by your Gradle project setup).

To signal that the latest Jib versions shouldn't hit this issue, I'll close this. #3416 is open for tracking.

@bplotnick
Copy link

I'm still seeing this issue on 3.1.4

@chanseokoh
Copy link
Member

chanseokoh commented Aug 18, 2021

@bplotnick 3.1.4 definitely pulls in HTTP library versions of Jib 2.7.0, so it must be that your project setup pulls in newer HTTP versions in your build environment. If that is the case, then for now, unfortunately you'll have to continue forcing 2.7.0 dependencies as above.

@racevedoo
Copy link

In my case, 3.1.4 worked fine. Thanks 😄

@chanseokoh
Copy link
Member

chanseokoh commented Aug 18, 2021

Thanks for the updates, folks. Downgrading HTTP libraries is only a temporary and incomplete solution (Gradle can still override old versions), so we think eventually this should be resolved.

Is there anyone who can consistently reproduce this issue (preferably a small sample you can share) and is willing to spend a good amount of their time to help us debugging this issue? If so, please contact us through our Gitter channel: https://gitter.im/google/jib

@chanseokoh
Copy link
Member

chanseokoh commented Aug 23, 2021

I suspect it is only Amazon that has this problem. Specifically, Amazon E3 (s3.amazonaws.com), which apparently stores blobs for container images. If there's anyone with this issue not using Amazon, let us know the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment