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

Introduce new tarfs mode to Nydus #1147

Merged
merged 5 commits into from
Mar 16, 2023
Merged

Conversation

jiangliu
Copy link
Collaborator

When using containerd overlayfs snapshotter to handle OCIv1 images, it works as below:

  • download compressed blobs from registry
  • uncompress compressed blobs into tar streams/files
  • unpack tar streams to directories on local filesystem
  • mount multiple directories into a container rootfs by overlayfs

Here we introduce a new work mode to nydus, called as TARFS, which works as below:

  • download compressed blobs from registry
  • uncompress compressed blobs into tar streams/files
  • build RAFS/EROFS meta blob from tar streams/files
  • optionally merge multiple RAFS/EROFS meta blobs into one
  • mount the generated RAFS filesystem by mount.erofs

By introducing TARFS mode to RAFS, it helps to avoid generating a bunch of small files by untar, which speeds up image preparation and garbage collection. It may also help to reduce levels of overlayfs by merging multiple image layers into one final RAFS filesystem.

The TARFS mode of RAFS filesystem has several special behavior, compared to current RAFS, as below:

  • Instead of generating RAFS data blob, it directly use tar files as RAFS data blob.
  • Tar files are uncompressed, so data blobs for TARFS mode are uncompressed.
  • Tar files will also be directly used as local cache files.
  • There's no chunk compression info, chunk digest, TOC etc, generated for TARFS mode.
  • Block size is 512 bytes instead of 4K, because tar files are 512 bytes aligned.

Now we have three ways to make of OCIv1 images:

Mode TAR-TARFS TARGZ-REF TARGZ-RAFS
Generate meta blob? Y Y Y
Generate chunk data? N N Y
Generate blob.meta? N Y Y
Generate data blobs? N Y(for blob.meta) Y
Data in data blobs? Not generated blob.meta chunk data & blob.meta
Chunk alignment? 512 4096 4096
Chunk dedup? N Y Y
Lazy loading? N Y Y
Note: RAFS in TARFS mode is designed to be used locally only. In other words, it's a way to implement snapshotter, instead of an image format for sharing.

@jiangliu jiangliu requested a review from a team as a code owner March 13, 2023 03:42
@jiangliu jiangliu requested review from liubin, luodw and adamqqqplay and removed request for a team March 13, 2023 03:42
@anolis-bot
Copy link
Collaborator

@jiangliu , a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/55999

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

@anolis-bot
Copy link
Collaborator

@jiangliu , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/56000

@anolis-bot
Copy link
Collaborator

@jiangliu , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/56001

@jiangliu jiangliu changed the title Tarfs Introduce new tarfs mode to Nydus Mar 13, 2023
@anolis-bot
Copy link
Collaborator

@jiangliu , the title has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/56002

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd❌ FAIL

Sorry, your test job failed. Please get the details in the link.

@anolis-bot
Copy link
Collaborator

@jiangliu , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/56003

@anolis-bot
Copy link
Collaborator

@jiangliu , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/56004

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

Introduce fake TarfsChunkInfo to provide ChunkInfo TARFS.
The TarfsChunkInfo acts as follow:
1) all TARFS chunks are uncompressed, because the tar file is in
   plaintext.
2) chunk digests of TarfsChunkInfo are all zero, so they are fake.

Also add constants and helpers to support 512-bytes block.

Signed-off-by: Jiang Liu <[email protected]>
Add method to enable/disable hash value computation for BufReaderInfo.

Signed-off-by: Jiang Liu <[email protected]>
@anolis-bot
Copy link
Collaborator

@jiangliu , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/56559

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

@anolis-bot
Copy link
Collaborator

@jiangliu , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/56747

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd❌ FAIL

Sorry, your test job failed. Please get the details in the link.

When using containerd overlayfs snapshotter to handle OCIv1 images,
it works as below:
- download compressed blobs from registry
- uncompress compressed blobs into tar streams/files
- unpack tar streams to directories on local filesystem
- mount multiple directories into a container rootfs by overlayfs

Here we introduce a new work mode to nydus, called as TARFS, which
works as below:
- download compressed blobs from registry
- uncompress compressed blobs into tar streams/files
- build RAFS/EROFS meta blob from tar streams/files
- optionally merge multiple RAFS/EROFS meta blobs into one
- mount the generated RAFS filesystem by mount.erofs

By introducing TARFS mode to RAFS, it helps to avoid generating a bunch
of small files by `untar`, which speeds up image preparation and garbage
collection. It may also help to reduce levels of overlayfs by merging
multiple image layers into one final RAFS filesystem.

The TARFS mode of RAFS filesystem has several special behavior, compared
to current RAFS, as below:
1) Instead of generating RAFS data blob, it directly use tar files as
   RAFS data blob.
2) Tar files are uncompressed, so data blobs for TARFS mode are
   uncompressed.
3) Tar files will also be directly used as local cache files.
4) There's no chunk compression info, chunk digest, TOC etc, generated
   for TARFS mode.
5) Block size is 512 bytes instead of 4K, because tar files are 512
   bytes aligned.

Now we have three ways to make of OCIv1 images:
Mode            		TAR-TARFS		TARGZ-REF		TARGZ-RAFS
Generate meta blob?		Y			Y			Y
Generate chunk data?		N			N			Y
Generate blob.meta?		N			Y			Y
Generate data blobs?		N			Y(for blob.meta)	Y
Data in data blobs?		Not generated		blob.meta		chunk data & blob.meta
Chunk alignment?		512			4096			4096
Chunk dedup?			N			Y			Y
Lazy loading?			N			Y			Y

Note, RAFS in TARFS mode is designed to be used locally only. In other
words, it's a way to implement snapshotter, instead of an image format
for sharing.

Signed-off-by: Jiang Liu <[email protected]>
A RAFS filesystem in TARFS mode directly use tar files/streams as data
blobs. A RAFS filesystem in TARFS mode contains a RAFS meta blob and
one or more tar files. There's no blob meta, such as compression info
array, chunk digest, TOC etc, in the tar files. So there's no support
of lazy loading, chunk dedup, chunk validation etc.

So assume that the snapshotter will prepare meta blob and tar files
before mounting the RAFS filesystem. Enhance the filecache module to
support tar files without lazy-loading, chunk dedup and chunk
validation.

Signed-off-by: Jiang Liu <[email protected]>
Enhance block device to support block size of 512, in addition to 4096,
so we can expose RAFS filesystems in TARFS mode as block device.

Signed-off-by: Jiang Liu <[email protected]>
@anolis-bot
Copy link
Collaborator

@jiangliu , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/56753

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

@imeoer imeoer merged commit c9d9b43 into dragonflyoss:master Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants