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

Improve the error message when pushing to a registry that does not support v2-2 #932

Merged
merged 3 commits into from
Sep 5, 2018

Conversation

briandealwis
Copy link
Member

Turns MANIFEST_INVALID / TAG_INVALID errors into slightly more helpful error messages:

Tried to push image manifest for localhost:5000/foo:bar but failed because: Registry does not support Image Manifest Version 2, Schema 2

Docker Registry 2.1, which returns a 400 / TAG_INVALID:

[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:0.9.11-SNAPSHOT:build (default-cli) on project first: Tried to push image manifest for localhost:5000/foo:bar but failed because: Registry does not support Image Manifest Version 2, Schema 2 | If this is a bug, please file an issue at https://github.com/GoogleContainerTools/jib/issues/new: 400 Bad Request
[ERROR] {"errors":[{"code":"TAG_INVALID","message":"manifest tag did not match URI"}]}
[ERROR] -> [Help 1]

Docker Registry 2.2, which returns a 400 / MANIFEST_INVALID:

[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:0.9.11-SNAPSHOT:build (default-cli) on project first: Tried to push image manifest for localhost:5000/foo:bar but failed because: Registry does not support Image Manifest Version 2, Schema 2 | If this is a bug, please file an issue at https://github.com/GoogleContainerTools/jib/issues/new: 400 Bad Request
[ERROR] {"errors":[{"code":"MANIFEST_INVALID","message":"manifest invalid","detail":{}}]}
[ERROR] -> [Help 1]

Pushing to quay.io, which returns a 415 / MANIFEST_INVALID (doesn't adhere to spec):

[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:0.9.11-SNAPSHOT:build (default-cli) on project first: Tried to push image manifest for quay.io/briandealwis/foo:popo but failed because: Registry does not support Image Manifest Version 2, Schema 2 | If this is a bug, please file an issue at https://github.com/GoogleContainerTools/jib/issues/new: 415 UNSUPPORTED MEDIA TYPE
[ERROR] {"errors":[{"code":"MANIFEST_INVALID","detail":{"message":"manifest schema version not supported"},"message":"manifest invalid"}]}
[ERROR] -> [Help 1]

Fixes #601

} catch (IOException ex) {
throw new RegistryErrorExceptionBuilder(getActionDescription(), httpResponseException)
.addReason("Failed to parse registry error response body")
.build();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should just throw httpResponseException? The rationale is that, if we didn't have this extra parsing at all like before, it would have thrown httpResponseException.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Will handle this in #937 as this is a lightly modified block taken from elsewhere.

// Did not get an error code back.
throw httpResponseException;
}
ErrorCodes errorCode = ErrorCodes.valueOf(errorCodeString);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed valueOf(String) will throw IllegalArgumentException if there is no matching enum, so I think we should catch that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Will handle this in #937 as this is a lightly modified block taken from elsewhere.

if (errorCode.equals(ErrorCodes.MANIFEST_INVALID)
|| errorCode.equals(ErrorCodes.TAG_INVALID)) {
throw new RegistryErrorExceptionBuilder(getActionDescription(), httpResponseException)
.addReason("Registry does not support Image Manifest Version 2, Schema 2")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's better to be a little bit less assertive with the claim, like "Registry may not be supporting ...". Just thinking TAG_INVALID might imply something different in some cases or there were genuinely other reasons (e.g., bugs) that produced an invalid manifest. WDYT?

Copy link
Contributor

@TadCordle TadCordle Sep 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, for example something like this would have been misleading for the artifactory errors, where the issue wasn't that they didn't support version 2 schema 2, the issue was that they were expecting fields we didn't provide.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Note that the original Artifactory error report seemed to be due to Artifactory not being configured to support v2-2 out of the box.

It's too bad the servers don't return any actionable information to identify the registry type. Docker Registry has the following headers:

{content-length=[79], content-type=[application/json; charset=utf-8], date=[Wed, 05 Sep 2018 18:12:25 GMT], docker-distribution-api-version=[registry/2.0], connection=[close]}

And quay.io has:

Headers: {content-length=[131], content-type=[application/json], date=[Wed, 05 Sep 2018 18:13:03 GMT], server=[nginx/1.14.0], connection=[keep-alive]}

@briandealwis briandealwis merged commit 90d9c10 into master Sep 5, 2018
@briandealwis briandealwis deleted the i601-invalid-manifest branch September 5, 2018 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants