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

Build arg regression with 0.44.0 #1756

Closed
mattnelson opened this issue Feb 20, 2024 · 12 comments · Fixed by #1759
Closed

Build arg regression with 0.44.0 #1756

mattnelson opened this issue Feb 20, 2024 · 12 comments · Fixed by #1759
Assignees
Labels

Comments

@mattnelson
Copy link
Contributor

Description

Build arg regression with 0.44.0, possibly from #1731

Caused by: com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonArray
    at com.google.gson.internal.bind.TypeAdapters$33$1.read (TypeAdapters.java:869)
    at com.google.gson.Gson.fromJson (Gson.java:963)
    at com.google.gson.Gson.fromJson (Gson.java:928)
    at com.google.gson.Gson.fromJson (Gson.java:877)
    at com.google.gson.Gson.fromJson (Gson.java:848)
    at io.fabric8.maven.docker.util.JsonFactory.newJsonObject (JsonFactory.java:18)
    at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.getImageId (DockerAccessWithHcClient.java:478)
    at io.fabric8.maven.docker.service.QueryService.getImageId (QueryService.java:135)
    at io.fabric8.maven.docker.service.BuildService.autoPullBaseImage (BuildService.java:385)
    at io.fabric8.maven.docker.service.BuildService.buildImage (BuildService.java:69)
    at io.fabric8.maven.docker.BuildMojo.proceedWithDockerBuild (BuildMojo.java:106)
    at io.fabric8.maven.docker.BuildMojo.proceedWithBuildProcess (BuildMojo.java:89)
    at io.fabric8.maven.docker.BuildMojo.buildAndTag (BuildMojo.java:82)
    at io.fabric8.maven.docker.BuildMojo.processImageConfig (BuildMojo.java:159)
    at io.fabric8.maven.docker.BuildMojo.executeInternal (BuildMojo.java:71)
    at io.fabric8.maven.docker.AbstractDockerMojo.execute (AbstractDockerMojo.java:295)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)

Info

  • docker-maven-plugin version : 0.44.0

  • Maven version (mvn -v) : 3.9.6

  • Docker version : Docker version 24.0.7-rd, build 72ffacf

  • If it's a bug, how to reproduce :

Have a dockerfile that uses a build arg for the FROM image.

ARG FROM_IMAGE
FROM ${FROM_IMAGE} AS jlink

Flex that build arg via the plugin configuration stanzas.

<plugin>
  <groupId>io.fabric8</groupId>
  <artifactId>docker-maven-plugin</artifactId>
  <configuration>
    <images>
      <image>
        <name>myimage:21</name>
        <build>
          <args>
            <FROM_IMAGE>openjdk:21</FROM_IMAGE>
          </args>
        </build>
      </image>
      <image>
        <name>myimage:17</name>
        <build>
          <args>
            <FROM_IMAGE>openjdk:17</FROM_IMAGE>
          </args>
        </build>
      </image>
    </images>
  </configuration>
</plugin>

Partial Workaround

Running the build with mvn package -DFROM_IMAGE=openjdk:21 works, but is only a viable workaround when building a single image for the entire build.

@rohanKanojia
Copy link
Member

@mattnelson : Thanks for reporting, I can reproduce this issue. I'll try to fix it .

@rohanKanojia
Copy link
Member

In #1731 source of buildArgs was changed to use build args from maven/system properties. But using that dropped the source from build configuration, which caused this regession.

@rohanKanojia rohanKanojia self-assigned this Feb 23, 2024
rohanKanojia added a commit to rohanKanojia/docker-maven-plugin that referenced this issue Feb 23, 2024
…ile pulling images (fabric8io#1756)

Fixes regression introduced by fabric8io#1731

In fabric8io#1731, we added support for specifying docker build args from
maven/system properties. However, I missed it in review that build args
specified in plugin image build configuration are no longer passed to
autoPullBaseImage.

Ensure we merge image build configuration build args with args provided
via maven/system properties before passing them to autoPullBaseImage

Signed-off-by: Rohan Kumar <[email protected]>
rohanKanojia added a commit to rohanKanojia/docker-maven-plugin that referenced this issue Feb 23, 2024
…ile pulling images (fabric8io#1756)

Fixes regression introduced by fabric8io#1731

In fabric8io#1731, we added support for specifying docker build args from
maven/system properties. However, I missed it in review that build args
specified in plugin image build configuration are no longer passed to
autoPullBaseImage.

Ensure we merge image build configuration build args with args provided
via maven/system properties before passing them to autoPullBaseImage

Signed-off-by: Rohan Kumar <[email protected]>
rohanKanojia added a commit to rohanKanojia/docker-maven-plugin that referenced this issue Feb 24, 2024
…ile pulling images (fabric8io#1756)

Fixes regression introduced by fabric8io#1731

In fabric8io#1731, we added support for specifying docker build args from
maven/system properties. However, I missed it in review that build args
specified in plugin image build configuration are no longer passed to
autoPullBaseImage.

Ensure we merge image build configuration build args with args provided
via maven/system properties before passing them to autoPullBaseImage

Signed-off-by: Rohan Kumar <[email protected]>
rohanKanojia added a commit that referenced this issue Feb 24, 2024
…ile pulling images (#1756)

Fixes regression introduced by #1731

In #1731, we added support for specifying docker build args from
maven/system properties. However, I missed it in review that build args
specified in plugin image build configuration are no longer passed to
autoPullBaseImage.

Ensure we merge image build configuration build args with args provided
via maven/system properties before passing them to autoPullBaseImage

Signed-off-by: Rohan Kumar <[email protected]>
@rohanKanojia
Copy link
Member

@mattnelson : I've merged changes that are supposed to fix this issue.

Could you please try out Docker Maven Plugin Snapshots and see if it fixes your issue.

poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Mar 26, 2024
We need to downgrade to 0.43.4 again because of this regression: fabric8io/docker-maven-plugin#1756
Once they release a new version, try again.
@poikilotherm
Copy link
Contributor

Fixes it for me.

Before:

[INFO] DOCKER> [gdcc/configbaker:unstable] "dev_bootstrap": Created docker-build.tar in 25 milliseconds
[ERROR] DOCKER> Unable to inspect image [solr:] : {"message":"invalid reference format"} (Bad Request: 400) [{"message":"invalid reference format"} (Bad Request: 400)]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  15.175 s
[INFO] Finished at: 2024-04-12T13:36:10+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.44.0:build (default-build) on project dataverse: Unable to inspect image [solr:] : {"message":"invalid reference format"} (Bad Request: 400) -> [Help 1]

With 0.45-SNAPSHOT:

[INFO] DOCKER> [gdcc/configbaker:unstable] "dev_bootstrap": Built image sha256:6c72fdb9d53b0065597c409e54c599c11a91c56213c28e04136d9d7ef8eb9bd2
[INFO] DOCKER> gdcc/configbaker:unstable: Removed dangling image sha256:f9b1305613f99d577d81ed3e93739cdbb16a324b5b60d7800c0752d758d8f447
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  15.945 s
[INFO] Finished at: 2024-04-12T13:36:39+02:00
[INFO] ------------------------------------------------------------------------

@rohanKanojia
Copy link
Member

@poikilotherm : Thanks for trying it out. I also need to check #1778 if it's related, then I'll try to cut a new release.

@ggjulio
Copy link

ggjulio commented Jun 19, 2024

Same regression from 0.43.0 to 0.44.0.

Can the issue be reopened ?

EDIT:
The last release is from Feb 17 and the PR fixing the issue has been merged on Feb 24.
What is the next release date ? Maybe could we get a release patch 0.44.1 ?

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.fabric8:docker-maven-plugin:0.44.0:build (default) on project [PROJECT_NAME]: Execution default of goal io.fabric8:docker-maven-plugin:0.44.0:build failed: Expected a com.google.gson.JsonObject but was com.google.gson.JsonArray
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
	at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal io.fabric8:docker-maven-plugin:0.44.0:build failed: Expected a com.google.gson.JsonObject but was com.google.gson.JsonArray
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	... 21 more
Caused by: com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonArray
	at com.google.gson.internal.bind.TypeAdapters$33$1.read(TypeAdapters.java:869)
	at com.google.gson.Gson.fromJson(Gson.java:963)
	at com.google.gson.Gson.fromJson(Gson.java:928)
	at com.google.gson.Gson.fromJson(Gson.java:877)
	at com.google.gson.Gson.fromJson(Gson.java:848)
	at io.fabric8.maven.docker.util.JsonFactory.newJsonObject(JsonFactory.java:18)
	at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.getImageId(DockerAccessWithHcClient.java:478)
	at io.fabric8.maven.docker.service.QueryService.getImageId(QueryService.java:135)
	at io.fabric8.maven.docker.service.BuildService.autoPullBaseImage(BuildService.java:385)
	at io.fabric8.maven.docker.service.BuildService.buildImage(BuildService.java:69)
	at io.fabric8.maven.docker.BuildMojo.proceedWithDockerBuild(BuildMojo.java:106)
	at io.fabric8.maven.docker.BuildMojo.proceedWithBuildProcess(BuildMojo.java:89)
	at io.fabric8.maven.docker.BuildMojo.buildAndTag(BuildMojo.java:82)
	at io.fabric8.maven.docker.BuildMojo.processImageConfig(BuildMojo.java:159)
	at io.fabric8.maven.docker.BuildMojo.executeInternal(BuildMojo.java:71)
	at io.fabric8.maven.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:295)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	... 22 more

@rohanKanojia
Copy link
Member

@ggjulio : I haven't released a new version since this change got merged.

You might want to verify on 0.45-SNAPSHOT ( try Docker Maven Plugin Snapshots and see if it fixes your issue.)

@ggjulio
Copy link

ggjulio commented Jun 19, 2024

Nice, it fixes the issue. Thank you !

@rohanKanojia
Copy link
Member

@ggjulio : Sorry for the delay, I'll try to cut 0.45.0 by the end of this month.

@ggjulio
Copy link

ggjulio commented Jul 15, 2024

Hi @rohanKanojia, do you have a new estimated date for the next release ?
Thanks !

@rohanKanojia
Copy link
Member

@ggjulio : I'm really sorry for the delay. I will try to cut a release this week.

@rohanKanojia
Copy link
Member

@ggjulio : : I have released 0.45.0 . Could you please check if everything is working as expected in your project and provide feedback?

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