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

feat: support local tarball for nydusify copy #1612

Merged
merged 4 commits into from
Sep 15, 2024

Conversation

BruceAko
Copy link
Contributor

@BruceAko BruceAko commented Aug 21, 2024

Relevant Issue

#1592

Details

proposal:
https://www.yuque.com/chongzhi-rrdux/qn22ch/rolbzm0xe00g1a3b

implement:
https://www.yuque.com/chongzhi-rrdux/qn22ch/tgg8w0rcazmyoo8f

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@BruceAko BruceAko requested a review from a team as a code owner August 21, 2024 08:58
@BruceAko BruceAko requested review from imeoer, jiangliu and Desiki-high and removed request for a team August 21, 2024 08:58
Copy link

codecov bot commented Aug 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.28%. Comparing base (6106fbc) to head (974b4a4).
Report is 4 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1612      +/-   ##
==========================================
- Coverage   61.29%   61.28%   -0.01%     
==========================================
  Files         146      146              
  Lines       48143    48143              
  Branches    46110    46110              
==========================================
- Hits        29509    29506       -3     
- Misses      17074    17075       +1     
- Partials     1560     1562       +2     

see 2 files with indirect coverage changes

source := sourceNamed.String()
target := targetNamed.String()
var source string
if strings.HasPrefix(opt.Source, "file:///") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use url.Parse here?

Copy link
Contributor Author

@BruceAko BruceAko Aug 28, 2024

Choose a reason for hiding this comment

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

When given an absolute path, if we use url.Parse, it incorrectly resolves it into URL.host instead of URL.path. So as an alternative, I've referenced helm and added a function getLocalPath(). A detailed description of this function is in the second commit.

return err
}
defer f.Close()
decompressor, err := compression.DecompressStream(f)
Copy link
Collaborator

Choose a reason for hiding this comment

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

decompressor should be closed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved.

}

if len(images) != 1 {
return "", errors.New("importing multiple images")
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should support multi platforms image.

Copy link
Contributor Author

@BruceAko BruceAko Sep 4, 2024

Choose a reason for hiding this comment

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

image

The length of images array represents the number of images in the tarball, not manifests. As shown in the figure, there are two images airpine and nginx in the tarball, each of which is multi platform image storing multiple manifests (linux/amd64 and linux/arm64/v8).

Since all of our exported tarball will only contain 1 image and it's manifests, it can be assumed that if the length of images in the tarball is greater than 1, the tarball is not formatted correctly.

So maybe this code doesn't need to be changed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the detail, LGTM.

@imeoer
Copy link
Collaborator

imeoer commented Aug 22, 2024

Please add test case in smoke/tests/nydusify_copy_test.go, thanks!

@imeoer
Copy link
Collaborator

imeoer commented Aug 22, 2024

Also add a doc about nydusify copy in docs/nydusify.md. :)

@BruceAko BruceAko changed the title feat: support local tarball for nydusify copy [WIP] feat: support local tarball for nydusify copy Aug 28, 2024
@BruceAko BruceAko force-pushed the master branch 4 times, most recently from 85d8fbe to 57740b6 Compare September 4, 2024 07:53
@BruceAko
Copy link
Contributor Author

BruceAko commented Sep 4, 2024

Also add a doc about nydusify copy in docs/nydusify.md. :)

Done.

@BruceAko
Copy link
Contributor Author

BruceAko commented Sep 4, 2024

Please add test case in smoke/tests/nydusify_copy_test.go, thanks!

The E2E test process is designed as follows:

  1. source is registry repository, target is local tarball, run nydusify copy to determine if the tarball was successfully exported;
  2. source is the just-exported tarball, target is remote reposiroty, perform another nydusify copy to determine whether the tarball was successfully imported;
  3. Run nydusify check to determine if the image which was just imported into reposiroty is correct.

@BruceAko BruceAko force-pushed the master branch 7 times, most recently from 1c012cb to 269831f Compare September 10, 2024 15:38
@BruceAko
Copy link
Contributor Author

Please add test case in smoke/tests/nydusify_copy_test.go, thanks!

Since smoke/tests/image_test.go already contained several test cases about nydusify copy, instead of creating a new file, I added a function testNydusifyCopy() to the image_test.go to refine the checking of the correctness of copy by different Nydus images.

@BruceAko BruceAko changed the title [WIP] feat: support local tarball for nydusify copy feat: support local tarball for nydusify copy Sep 11, 2024
@BruceAko BruceAko requested a review from imeoer September 11, 2024 08:57
Copy link
Collaborator

@imeoer imeoer left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the work.

@imeoer imeoer merged commit 9b4c272 into dragonflyoss:master Sep 15, 2024
25 checks passed
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.

2 participants