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

Fix media type on unpacking layer #257

Merged
merged 2 commits into from
Sep 12, 2016

Conversation

coolljt0725
Copy link
Member

Signed-off-by: Lei Jitang leijitang@huawei.com

The media type on unpacking layer should be MediaTypeImageLayer

@runcom
Copy link
Member

runcom commented Sep 5, 2016

would be great to have a test for this :( not sure how this got past CI or manual testing

@coolljt0725
Copy link
Member Author

@runcom Having a test for this is great, I'll try

@coolljt0725
Copy link
Member Author

@vbatts @runcom @philips PTAL, if it's ok, can we merge it first and then add test later? This block a lot of tests

@@ -89,7 +89,7 @@ func (m *manifest) validate(w walker) error {

func (m *manifest) unpack(w walker, dest string) error {
for _, d := range m.Layers {
if d.MediaType != string(schema.MediaTypeImageConfig) {
if d.MediaType != string(schema.MediaTypeImageLayer) {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be an error, not a continue. Changing this to an error fixes the “wrong media-type” issue discussed in #261 (but not currently fixed by that PR).

Copy link
Contributor

Choose a reason for hiding this comment

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

Although the spec does not currently say that layers MUST have a particular type, so this is currently an:

unimplemented: unpacking layer with media-type %q

I expect the spec should clarify if it places bounds (upper or lower) on manifest layer[] media types, and once that happens we can adjust this to match.

Copy link
Member Author

Choose a reason for hiding this comment

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

@wking if the layers MUST have a particular type is not said in the spec currently, I think we should make it clear in the spec first.

Copy link
Contributor

Choose a reason for hiding this comment

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

On Wed, Sep 07, 2016 at 04:58:52AM -0700, Lei Jitang wrote:

@@ -89,7 +89,7 @@ func (m *manifest) validate(w walker) error {

func (m *manifest) unpack(w walker, dest string) error {
for _, d := range m.Layers {

  •   if d.MediaType != string(schema.MediaTypeImageConfig) {
    
  •   if d.MediaType != string(schema.MediaTypeImageLayer) {
        continue
    

@wking if the layers MUST have a particular type is not said in the
spec currently, I think we should make it clear in the spec first.

If the layers MUST have a particular type, then you should error out
here with “your manifest is broken”. If the spec does not limit the
allowed types (like now), then you should error out here with
“unimplemented type”. In no case that I can see should we be silently
ignoring an unrecognized type.

Copy link
Member Author

Choose a reason for hiding this comment

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

@wking If the spec does not limit the allowed types, I don't think we should error out on unpacking, we should just
unpacking the allowed typed layers. But I think this is another issue we should discuss more not related to this pr

Copy link
Contributor

Choose a reason for hiding this comment

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

On Wed, Sep 07, 2016 at 08:46:36PM -0700, Lei Jitang wrote:

@@ -89,7 +89,7 @@ func (m *manifest) validate(w walker) error {

func (m *manifest) unpack(w walker, dest string) error {
for _, d := range m.Layers {

  •   if d.MediaType != string(schema.MediaTypeImageConfig) {
    
  •   if d.MediaType != string(schema.MediaTypeImageLayer) {
        continue
    

@wking If the spec does not limit the allowed types, I don't think
we should error out on unpacking, we should just unpacking the
allowed typed layers. But I think this is another issue we should
discuss more not related to this pr

If there's any confusion, I'm fine punting this to another PR. The
media type fix is critical and obviously right. The continue→error
fix only matters for oddball manifests, so it's much less important.

Copy link
Member

@runcom runcom Sep 9, 2016

Choose a reason for hiding this comment

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

Although the spec does not currently say that layers MUST have a particular type, so this is currently an:

unimplemented: unpacking layer with media-type %q
I expect the spec should clarify if it places bounds (upper or lower) on manifest layer[] media types, and once that happens we can adjust this to match.

is there an issue to clarify this aspect?

Copy link
Contributor

Choose a reason for hiding this comment

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

On Fri, Sep 09, 2016 at 03:07:52AM -0700, Antonio Murdaca wrote:

@@ -89,7 +89,7 @@ func (m *manifest) validate(w walker) error {

func (m *manifest) unpack(w walker, dest string) error {
for _, d := range m.Layers {

  •   if d.MediaType != string(schema.MediaTypeImageConfig) {
    
  •   if d.MediaType != string(schema.MediaTypeImageLayer) {
        continue
    

Although the spec does not currently say that layers MUST have a
particular type, so this is currently an:

unimplemented: unpacking layer with media-type %q

I expect the spec should clarify if it places bounds (upper or
lower) on manifest layer[] media types, and once that happens we
can adjust this to match.

is there an issue for this?

There are ~50 million open validation issues at the moment, so I
haven't opened up one specifically for this ;). I try and bring it up
where it impacts an existing issue/PR. Most recently in #286.

@wking
Copy link
Contributor

wking commented Sep 8, 2016 via email

@coolljt0725
Copy link
Member Author

test added

@@ -48,3 +64,60 @@ func TestUnpackLayerDuplicateEntries(t *testing.T) {
t.Fatalf("Expected to fail with duplicate entry, got %v", err)
}
}
func TestUnpackLayerRemovePartialyUnpackedFile(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing blank line before this function?

Signed-off-by: Lei Jitang <leijitang@huawei.com>
Signed-off-by: Lei Jitang <leijitang@huawei.com>
@coolljt0725
Copy link
Member Author

ping @philips @vbatts @stevvooe @s-urbaniak PTAL, we can't use unpack without this

@runcom
Copy link
Member

runcom commented Sep 9, 2016

ping @philips @vbatts @stevvooe @s-urbaniak PTAL, we can't use unpack without this

LGTM - received this very same bug report on IRC and was hoping for this to be merged soon(ish). We can address any outstanding issues around the test in a follow up I guess.

@philips
Copy link
Contributor

philips commented Sep 12, 2016

LGTM

We should fix up the test.tar thing and use a tmp dir; but we can do it on a followup.

Approved with PullApprove

@vbatts
Copy link
Member

vbatts commented Sep 12, 2016

LGTM

Approved with PullApprove

@vbatts vbatts merged commit 8d0ee71 into opencontainers:master Sep 12, 2016
@coolljt0725 coolljt0725 deleted the fix_media_type branch September 18, 2016 01:48
@coolljt0725 coolljt0725 restored the fix_media_type branch September 18, 2016 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants