Chapter 7. Known issues affecting required infrastructure components

  • Fabric8 Maven Plugin Issue #1640: Pushing an image into a custom repository during an s2i build with FMP 4.1.0 results in a DuplicateKeyException.

    Affected components and component versions
    This issues affects Fabric8 Maven Plugin 4.1.0.
    Description
    Fabric8 Maven Plugin does not process ImageConfiguration unless ImageConfiguration also contains a BuildImageConfiguration. Without a recognizable BuildImageConfiguration, Fabric8 Maven Plugin repeatedly calls the s2i image generators to create another default ImageConfiguration that contains the expected BuildImageConfiguration. This results in more than one ImageConfiguration being specified for the given s2i build, which in turn results in a DuplicateKeyException when FMP attempts to push the image to the registry specified in the pom.xml configuration file. This leads to image build failures when a new image build is triggered by a change in the deployment configuration of a pod on OpenShift.
    Workaround

    To prevent Fabric8 Maven Plugin form generating a duplicate ImageConfiguration, place the image configuration inside a build section in the pom.xml configuration file of your project, as shown in the examples below. This in turn prevents the DuplicateKeyException when new image build is triggered by a change in the deployment configuration of the pod.

    <configuration>
      <images>
        <image>
          <name>
            artifactrepository.somecompany.com:18444/demo-boot/demo-boot:1.0
          </name>
            <build>
              <from>
                fabric8/S2I_BASE_IMAGE_NAME
              </from>
              <assembly>
                <basedir>
                  /deployments
                </basedir>
                <descriptorRef>
                  artifact-with-dependencies
                </descriptorRef>
              </assembly>
              <env>
                <JAVA_LIB_DIR>
                  /deployments
                </JAVA_LIB_DIR>
                <JAVA_MAIN_CLASS>
                  org.example.class.name.Main
                </JAVA_MAIN_CLASS>
              </env>
            </build>
          ...
        </image>
      </images>
      ...
    </configurtation>