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

Enhance localdisk storage backend to manually add blob objects #1337

Merged
merged 3 commits into from
Jul 18, 2023

Conversation

jiangliu
Copy link
Collaborator

Relevant Issue (if applicable)

If there are Issues related to this PullRequest, please list it.

Details

Enhance the localdisk storage backend, so we can manually add blob
objects in the disk, in addition to discovering blob objects by
scanning GPT partition table.

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.

@jiangliu jiangliu requested a review from a team as a code owner June 21, 2023 08:25
@jiangliu jiangliu requested review from liubogithub, imeoer and hsiangkao and removed request for a team June 21, 2023 08:25
@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/80071

@adamqqqplay adamqqqplay self-requested a review June 21, 2023 08:27
@codecov
Copy link

codecov bot commented Jun 21, 2023

Codecov Report

Merging #1337 (c1b1c7c) into master (4e3c954) will increase coverage by 0.15%.
The diff coverage is 53.43%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1337      +/-   ##
==========================================
+ Coverage   46.01%   46.16%   +0.15%     
==========================================
  Files         122      122              
  Lines       37807    37913     +106     
  Branches    37807    37913     +106     
==========================================
+ Hits        17396    17503     +107     
+ Misses      19501    19490      -11     
- Partials      910      920      +10     
Impacted Files Coverage Δ
api/src/config.rs 70.56% <ø> (ø)
storage/src/cache/worker.rs 62.25% <ø> (ø)
storage/src/backend/localdisk.rs 48.10% <53.43%> (+31.35%) ⬆️

... and 2 files with indirect coverage changes

@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/80080

@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!

@adamqqqplay
Copy link
Member

@jiangliu Unit tests on older versions of the localdisk image have passed, which means your code is compatible. For the test code, please refer to https://github.com/adamqqqplay/image-service/tree/localdisk-test

Regarding the review of the code itself, I still need some time. Thanks for your work!

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.

Thanks for your work, I made some small comments on the code changes, mainly focusing on the maintainability of the module.

@@ -45,7 +45,8 @@ tar = "0.4.38"
regex = "1.7.0"

[features]
backend-localdisk = ["gpt"]
backend-localdisk = []
backend-localdisk-gpt = ["gpt", "backend-localdisk"]
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused about this new feature, can you explain what it's for? I only see one feature on other backends.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's to support localdisk without gpt. Gpt is just one way to discover nydus blobs inside a disk, but not the only way.

Copy link
Member

Choose a reason for hiding this comment

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

OK, got it.

storage/src/backend/localdisk.rs Outdated Show resolved Hide resolved
storage/src/backend/localdisk.rs Outdated Show resolved Hide resolved
storage/src/backend/localdisk.rs Outdated Show resolved Hide resolved
} else {
v.name.clone() + guid.to_simple().to_string().as_str() // The 64-byte blob_id is stored in two parts
// The 64-byte blob_id is stored in two parts
Copy link
Member

Choose a reason for hiding this comment

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

I think this case should also belong to gpt mode.

The reason for the judgment of part_type_guid above comes from a compatibility issue.

  1. When part_type_guid == gpt::partition_types::BASIC, the blob_id only exists in the name field of the partition.
  2. When part_type_guid == gpt::partition_types::LINUX_FS, the blob_id exists in the name field and in the guid field.

For the corresponding changes, please refer to: adamqqqplay/nydus-localdisk@4812dcb . BTW, the design of the image building did have some hacks before. If you have any suggestions, I could refactor them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I missed your point here. This piece of code is enabled for gpt only.
For the backward compatibility, it would be better to remove if we can.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, I will refactor this part later. Now, I think the code might look like this to be compatible.

let name = if v.part_type_guid == gpt::partition_types::BASIC {
                is_gpt_mode = true;
                // Compatible with old versions of localdisk image
                v.name.clone()
} else if v.part_type_guid == gpt::partition_types::LINUX_FS {
                is_gpt_mode = true;
                // The 64-byte blob_id is stored in two parts
                v.name.clone() + guid.to_simple().to_string().as_str()
} else {      // **Your new code block. The part_type_guid not found** 
                // The 64-byte blob_id is stored in two parts
                v.name.clone() + guid.to_simple().to_string().as_str()
}

storage/src/backend/localdisk.rs Show resolved Hide resolved
@@ -443,6 +443,9 @@ pub struct LocalDiskConfig {
/// Mounted block device path or original localdisk image file path.
#[serde(default)]
pub device_path: String,
/// Disable discover blob objects by scanning GPT table.
#[serde(default)]
pub disable_gpt: bool,
Copy link
Member

Choose a reason for hiding this comment

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

The variable disable_gpt has been used here to control the localdisk mode. Is it necessary to use the feature backend-localdisk-gpt for conditional compilation at the same time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's keep it for simplicity?

Copy link
Member

Choose a reason for hiding this comment

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

OK

@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/81810

@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!

@adamqqqplay
Copy link
Member

I have no other comments, @imeoer please take a look. Thanks!

Introduce feature `backend-localdisk-gpt` for localdisk storage backend,
so it can be optionally disabled.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
Use File instead of RawFd in struct LocalDiskBlob to avoid possible
race conditions.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
Enhance the localdisk storage backend, so we can manually add blob
objects in the disk, in addition to discovering blob objects by
scanning GPT partition table.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
@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/85262

@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 be52ebd into dragonflyoss:master Jul 18, 2023
24 checks passed
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.

None yet

4 participants