jib icon indicating copy to clipboard operation
jib copied to clipboard

skipExistingImages not working correctly?

Open dsvensson opened this issue 4 months ago • 0 comments

Environment:

  • Jib version: 3.4.3
  • Build tool: gradle 8.10
  • OS: Linux/macOS

Description of the issue: skipExistingImages is supposed to make the error of having already pushed the image go away, but I still get:

Execution failed for task ':name:jib'.
> com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException: 
Tried to push image manifest for blablabla.amazonaws.com/some/name:theversion but failed because:
Registry may not support pushing OCI Manifest or Docker Image Manifest Version 2, Schema 2

I've verified that skipExistingImages is correctly set to true when gradle is invoked by adding the following print in one of my build.gradle.kts files:

println("skip-existing: ${JibSystemProperties.skipExistingImages()}")

This prints true.

The problem typically occurs if there's some flakiness in the CI so a few of the images get pushed successfully, which during a retry will cause a failure due to already pushed images.

The workaround is ofc to just commit something which changes the hash used as tag allowing the build to complete, but it's an inconvenience compared to just retry.

Expected behavior:

Complete silence and exit 0, or some log that says the image already exists.

Steps to reproduce:

  1. Create an immutable AWS ECR repository entry
  2. Run jib task to push
    • In my case this produces an Image Index with the tag, plus two untagged Image entries, one for each of arm64 and x64.
  3. Repeat 2.

jib-gradle-plugin Configuration:

println("skip-existing: ${JibSystemProperties.skipExistingImages()}")

jib {
	to {
		image = "...:$commitHash"
		credHelper.helper = "ecr-login"
	}
	from {
		image = "amazoncorretto:17"

		platforms {
			platform {
				architecture = "amd64"
				os = "linux"
			}
			platform {
				architecture = "arm64"
				os = "linux"
			}
		}
	}
	container {
		environment = mapOf(
			...,
		)
		entrypoint = listOf("...")
		labels.set(
			mapOf(
				"org.opencontainers.image.revision" to version,
				"org.opencontainers.image.source" to "...",
			),
		)
	}
	extraDirectories {
		paths {
			path {
				setFrom(layout.buildDirectory.dir("extra"))
				into = "/app"
			}
			...
		}
		permissions.set(mapOf(
			"..." to "755"
		))
	}

	pluginExtensions {
		pluginExtension {
			implementation = "com.google.cloud.tools.jib.gradle.extension.layerfilter.JibLayerFilterExtension"
			configuration(Action<com.google.cloud.tools.jib.gradle.extension.layerfilter.Configuration> {
				filters {
					filter {
						...
					}
					...
				}
			})
		}
	}
}

Log output:

Execution failed for task ':name:jib'.
> com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException: 
Tried to push image manifest for blablabla.amazonaws.com/some/name:theversion but failed because:
Registry may not support pushing OCI Manifest or Docker Image Manifest Version 2, Schema 2

Additional Information:

dsvensson avatar Sep 25 '24 10:09 dsvensson