Skip to content

Make the ManifestChecker more flexible to accept NAME_UNKNOWN #4521

Description

@essobedo

Environment:

  • Jib version: 0.28.1
  • Build tool: Maven and Gradle
  • OS: All

Description of the issue:

In the case of OpenShift image registry as target registry, if we try to check if a tag of a missing image exists using the method RegistryClient#checkManifest, we get a RegistryErrorException with the error code NAME_UNKNOWN

Expected behavior:

No exception is thrown by the ManifestChecker. In other words, I would expect the ManifestChecker to return Optional.empty() when the error code is MANIFEST_UNKNOWN or NAME_UNKNOWN

Steps to reproduce:

  1. Install OpenShift Local with openshift as preset or create an OpenShift cluster
  2. Port forward the registry service to local port 5000
  3. Check if a fake image name exists with:
  FailoverHttpClient httpClient = new FailoverHttpClient(true, JibSystemProperties.sendCredentialsOverHttp(), logEvent -> {});
  RegistryClient.Factory factory =
          RegistryClient.factory(EventHandlers.NONE, "localhost:5000", "openshift/ubi8-openjdk-17-foo", httpClient);
  factory.setCredential(Credential.from("kubeadmin", System.getenv("KUBE_ADMIN_PASSWORD")));
  RegistryClient registryClient = factory.newRegistryClient();
  registryClient.configureBasicAuth();
  registryClient.doPullBearerAuth();
  Optional<ManifestAndDigest<ManifestTemplate>> manifestAndDigest = registryClient.checkManifest("1.15");
  if (manifestAndDigest.isPresent()) {
      System.out.println("Manifest found: " + manifestAndDigest.get().getDigest());
  } else {
      System.out.println("Manifest not found");
  }

Log output:

Exception in thread "main" com.google.cloud.tools.jib.registry.RegistryErrorException: Tried to pull image manifest for localhost:5000/openshift/ubi8-openjdk-17-foo:1.15 but failed because: other: repository name not known to registry
	at com.google.cloud.tools.jib.registry.RegistryErrorExceptionBuilder.build(RegistryErrorExceptionBuilder.java:101)
	at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.newRegistryErrorException(RegistryEndpointCaller.java:212)
	at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:153)
	at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:114)
	at com.google.cloud.tools.jib.registry.RegistryClient.callRegistryEndpoint(RegistryClient.java:623)
	at com.google.cloud.tools.jib.registry.RegistryClient.checkManifest(RegistryClient.java:414)
	at org.talend.engine.commons.Main.main(Main.java:25)
Caused by: com.google.cloud.tools.jib.http.ResponseException: 404 Not Found
GET https://localhost:5000/v2/openshift/ubi8-openjdk-17-foo/manifests/1.15
{"errors":[{"code":"NAME_UNKNOWN","message":"repository name not known to registry"}]}

	at com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:355)
	at com.google.cloud.tools.jib.http.FailoverHttpClient.followFailoverHistory(FailoverHttpClient.java:312)
	at com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:260)
	at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:138)
	... 4 more
Caused by: com.google.api.client.http.HttpResponseException: 404 Not Found
GET https://localhost:5000/v2/openshift/ubi8-openjdk-17-foo/manifests/1.15
{"errors":[{"code":"NAME_UNKNOWN","message":"repository name not known to registry"}]}

	at com.google.api.client.http.HttpResponseException$Builder.build(HttpResponseException.java:293)
	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1118)
	at com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:349)
	... 7 more

Additional Information:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions