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

nydus-image: Fix blob unpacking bug in specified blob directory #1426

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

An-DJ
Copy link
Contributor

@An-DJ An-DJ commented Sep 17, 2023

Relevant Issue (if applicable)

Close #1340

Details

Fix the unpack bug in multi blobs situation. (Based on the unmerged work in #1338)

Types of changes

What types of changes does your PullRequest introduce? Put an x in all the boxes that apply:

  • 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

Go over all the following points, and put an x in all the boxes that apply.

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

@An-DJ An-DJ requested a review from a team as a code owner September 17, 2023 10:01
@An-DJ An-DJ requested review from bergwolf, liubin and adamqqqplay and removed request for a team September 17, 2023 10:01
@An-DJ An-DJ force-pushed the fix-blobs-unpack-bug branch 2 times, most recently from e8ee46d to be28740 Compare September 17, 2023 14:38
@codecov
Copy link

codecov bot commented Sep 17, 2023

Codecov Report

Merging #1426 (b48b662) into master (278915b) will decrease coverage by 0.02%.
The diff coverage is 31.48%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1426      +/-   ##
==========================================
- Coverage   46.45%   46.44%   -0.02%     
==========================================
  Files         123      123              
  Lines       38640    38702      +62     
  Branches    38640    38702      +62     
==========================================
+ Hits        17951    17975      +24     
- Misses      19714    19753      +39     
+ Partials      975      974       -1     
Files Changed Coverage Δ
rafs/src/metadata/cached_v5.rs 58.52% <0.00%> (-0.98%) ⬇️
rafs/src/metadata/direct_v5.rs 56.44% <ø> (ø)
rafs/src/metadata/direct_v6.rs 6.48% <0.00%> (-0.07%) ⬇️
rafs/src/metadata/inode.rs 47.50% <0.00%> (ø)
rafs/src/metadata/mod.rs 52.28% <ø> (-0.58%) ⬇️
rafs/src/mock/mock_inode.rs 0.00% <0.00%> (ø)
src/bin/nydus-image/main.rs 41.78% <0.00%> (-0.12%) ⬇️
src/bin/nydus-image/unpack/mod.rs 0.00% <0.00%> (ø)
src/bin/nydus-image/unpack/pax.rs 9.74% <62.96%> (+1.90%) ⬆️
src/bin/nydus-image/unpack/pax/test.rs 89.72% <100.00%> (+2.59%) ⬆️

... and 1 file with indirect coverage changes

@An-DJ
Copy link
Contributor Author

An-DJ commented Sep 17, 2023

Follow the steps in #1340 to reproduce that issue and verify if it is fixed:

  1. Prepare the data:
# create a directory to store only one file `echarts.png`
mkdir echarts

# create a directory to store two file `avatar.png` and `echarts.png`
mkdir echarts-add

# create a directory to store created images (meta, blob)
mkdir echarts-image

# download images
wget https://user-images.githubusercontent.com/1655233/249319028-009b32a0-1563-465c-867e-7623d1b9275d.png -O echarts/echarts.png
wget https://user-images.githubusercontent.com/1655233/249319027-5dcdaf14-631c-46c4-ac11-58b1d4c04a0f.png -O echarts-add/avatar.png
wget https://user-images.githubusercontent.com/1655233/249319028-009b32a0-1563-465c-867e-7623d1b9275d.png -O echarts-add/echarts.png
  1. Create the first one
./nydus-image create -v 5 -t dir-rafs -D echarts-image echarts
[2023-09-17 15:10:14.890232 +00:00] INFO successfully built RAFS filesystem:
meta blob path: echarts-image/59016ae5c245fd768f85cf6eeab74da0d88cd00d9f2df5d3627e6f0177ba38d9
data blob size: 0xc0e1
data blobs: ["fa964c10cd36503b3bbd0d8218ec03d132214a51b0e4b03d2684770290306bce"]
  1. Create the second one
./nydus-image create -v 5 -t dir-rafs --chunk-dict echarts-image/59016ae5c245fd768f85cf6eeab74da0d88cd00d9f2df5d3627e6f0177ba38d9 -D echarts-image echarts-add
[2023-09-17 15:12:04.145951 +00:00] INFO RAFS v5 super block features: HASH_BLAKE3 | EXPLICIT_UID_GID | COMPRESSION_ZSTD
[2023-09-17 15:12:04.153042 +00:00] INFO successfully built RAFS filesystem:
meta blob path: echarts-image/86235ef91901df9392244c0f973c118530519f5b932bed33671aa9775e45a5e9
data blob size: 0xc0e1
data blobs: ["5ee38535110c9470daeb434efbace48b15dfb7c08878cc9effa2bc0b29638a0d", "fa964c10cd36503b3bbd0d8218ec03d132214a51b0e4b03d2684770290306bce"]
  1. Do unpack
./nydus-image unpack --blob-dir echarts-image --output ./unpack-files.tar echarts-image/86235ef91901df9392244c0f973
c118530519f5b932bed33671aa9775e45a5e9
[2023-09-17 15:13:23.384728 +00:00] INFO RAFS v5 super block features: HASH_BLAKE3 | EXPLICIT_UID_GID | COMPRESSION_ZSTD
  1. Untar file and compare the checksum:
$ tar xvf unpack-files.tar
avatar.png
echarts.png

$ md5sum avatar.png
8d852403b0badc7731e8b5aa7bd3ad36  avatar.png
$ md5sum echarts-add/avatar.png
8d852403b0badc7731e8b5aa7bd3ad36  echarts-add/avatar.png

$ md5sum echarts.png
c747eb230ad3439052e001187b6a216d  echarts.png
$ md5sum echarts-add/echarts.png
c747eb230ad3439052e001187b6a216d  echarts-add/echarts.png

@An-DJ An-DJ changed the title [WIP] fix(nydus-image): fix blobs unpack bug fix(nydus-image): fix blobs unpack bug Sep 17, 2023
src/bin/nydus-image/main.rs Outdated Show resolved Hide resolved
@imeoer
Copy link
Collaborator

imeoer commented Sep 18, 2023

Great job, thanks for the PR!

@adamqqqplay adamqqqplay changed the title fix(nydus-image): fix blobs unpack bug nydus-image: Fix blob unpacking bug in specified blob directory Sep 18, 2023
Copy link
Member

@adamqqqplay adamqqqplay left a comment

Choose a reason for hiding this comment

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

Please organize your commits before merging. Our repo uses rebase merging, which will submit your original commit information to the master branch.

@An-DJ
Copy link
Contributor Author

An-DJ commented Sep 19, 2023

Please organize your commits before merging. Our repo uses rebase merging, which will submit your original commit information to the master branch.

@adamqqqplay Done.

src/bin/nydus-image/main.rs Outdated Show resolved Hide resolved
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.

others LGTM! Thanks!

@An-DJ An-DJ force-pushed the fix-blobs-unpack-bug branch 2 times, most recently from 9d6e9e0 to 1b4bb61 Compare September 21, 2023 03:35
@An-DJ An-DJ requested a review from imeoer September 22, 2023 06:03
Signed-off-by: Junduo Dong <dongjunduo.djd@antgroup.com>
@imeoer imeoer merged commit 0cdf472 into dragonflyoss:master Sep 25, 2023
24 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.

Some problems about Nydus unpack func supporting blob dir
3 participants