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

"Premature end of chunk coded message body: closing chunk expected" when using another plugin together #3564

Closed
raminqaf opened this issue Jan 20, 2022 · 1 comment

Comments

@raminqaf
Copy link

raminqaf commented Jan 20, 2022

Environment:

  • Jib version: 3.2.0

  • Build tool:

        Gradle 7.1
        
        Build time:   2021-06-14 14:47:26 UTC
        Revision:     989ccc9952b140ee6ab88870e8a12f1b2998369e
        
        Kotlin:       1.4.31
        Groovy:       3.0.7
        Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
        JVM:          11.0.12 (Oracle Corporation 11.0.12+7)
        OS:           Linux 5.11.0-44-generic amd64
    
  • OS: Ubuntu 20.04

Description of the issue:
Jib fails to download dependency from the private maven repository to images. In my project, I have two dependencies that are hosted in a private Google Artifact Registry. Locally I have authenticated myself through the gcloud SDK and can download and build the project locally. But whenever I run jib to build and push the images. Jib fails to download the dependencies and can not build the images.

Expected behavior:
That jib downloads the dependencies from the repository and builds the image.

Steps to reproduce:

  1. Add a dependency to your project that is hosted in a private maven repository
  2. run ./gradlew mymoduel:jib

jib-gradle-plugin Configuration:
I can paste a part of the config. I am using google.cloud.artifactregistry.gradle-plugin and there is also how I defined my repository:

id("com.google.cloud.artifactregistry.gradle-plugin") version "2.1.4"
...
repositories {
    mavenCentral()
    maven(url = "artifactregistry://us-central1-maven.pkg.dev/my-cluster/my-repository")
}

Log output:

Task :mymodule:jib

Containerizing application to us.gcr.io/my-cluster/my-application:0.0.3...
Base image 'eclipse-temurin:11-jre' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for eclipse-temurin:11-jre...
Using credentials from Docker config (~/.docker/config.json) for eclipse-temurin:11-jre
Using credentials from Docker config (~/.docker/config.json) for us.gcr.io/my-cluster/my-application:0.0.3
I/O error for image [us.gcr.io/my-cluster/my-application]:
    org.apache.http.ConnectionClosedException
    Premature end of chunk coded message body: closing chunk expected
I/O error for image [us.gcr.io/my-cluster/my-application]:
    org.apache.http.ConnectionClosedException
    Premature end of chunk coded message body: closing chunk expected
I/O error for image [us.gcr.io/my-cluster/my-application]:
    org.apache.http.ConnectionClosedException
    Premature end of chunk coded message body: closing chunk expected
I/O error for image [us.gcr.io/my-cluster/my-application]:
    org.apache.http.ConnectionClosedException
    Premature end of chunk coded message body: closing chunk expected
I/O error for image [us.gcr.io/my-cluster/my-application]:
    org.apache.http.ConnectionClosedException
    Premature end of chunk coded message body: closing chunk expected
Using base image with digest: sha256:83d92ee225e443580cc3685ef9574582761cf975abc53850c2bc44ec47d7d943
Executing tasks:
[============                  ] 41.7% complete
> checking base image layer sha256:ea362f368469...
> checking base image layer sha256:9b46d5d971fa...
> checking base image layer sha256:d5cc550bb6a0...
> checking base image layer sha256:bcc17963ea24...
> scheduling building manifests
> launching layer pushers
> scheduling pushing container configurations


> Task :mymodlue:jib FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mymodlue:jib'.
> com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException: Premature end of chunk coded message body: closing chunk expected
@raminqaf raminqaf changed the title Jib Fails to download dependency from private maven repository Jib fails to download dependency from private maven repository Jan 20, 2022
@chanseokoh
Copy link
Member

chanseokoh commented Jan 21, 2022

This has nothing to do with Maven repositories or pulling Maven dependencies.

Both the Jib plugin and the Google Artifact Registry (GAR) plugin depend on the Google HTTP Client library. By just declaring the GAR plugin, it naturally leads to a diamond dependency conflict, which is often fine regardless of what version is actually pulled in.

Unfortunately, there is a bug in some old but relatively recent Google HTTP Client library versions. It seems that a problematic version is being pulled in by the GAR plugin. That is, regardless of whether you configure the repositories {} block, as soon as you have the following line

  id("com.google.cloud.artifactregistry.gradle-plugin") version "2.1.4"

you run into the issue.

Recent Google HTTP Client library versions fixed the bug, so a workaround is to force using the latest version. The latest as of now is 1.41.0. For example,

buildscript {
  classpath('com.google.http-client:google-http-client:1.41.0') { force = true }
  classpath('com.google.http-client:google-http-client-apache-v2:1.41.0') { force = true }
  ...
}

Note this is for buildscript {} dependencies, not for the project app.

At the same time, I suggest you urge the maintainers of the GAR plugin to upgrade the Google HTTP library version to the latest.

Closing as a dup of #3409.

@chanseokoh chanseokoh changed the title Jib fails to download dependency from private maven repository "Premature end of chunk coded message body: closing chunk expected" when using another plugin together Jan 21, 2022
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