GoogleContainerTools / GoogleContainerTools/jib
Make the ManifestChecker more flexible to accept NAME_UNKNOWN
- Dominant language
- Java
- Stars
- 14.5k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Environment**:
- *Jib version:* 0.28.1
- *Build tool:* Maven and Gradle
- *OS:* All
**Description of the issue**:
In the case of [OpenShift image registry](https://docs.okd.io/4.15/registry/configuring-registry-operator.html) 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 = 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**:
Contributor guide
Research direction
Start at RegistryClient#checkManifest and the ManifestChecker handling for the MANIFEST_UNKNOWN error code. Reproduce the missing-image request described in the issue, then verify that both MANIFEST_UNKNOWN and NAME_UNKNOWN produce Optional.empty() rather than RegistryErrorException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 74/100