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: refactor unpack/compact cli interface #1606

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

SToPire
Copy link
Contributor

@SToPire SToPire commented Jul 30, 2024

Since unpack and compact subcommands does not need the entire nydusd configuration file, let's refactor their cli interface and directly take backend configuration file.

Specifically, we introduce --backend-type, --backend-config and --backend-config-file options to specify the backend type and remove --config option.

Fixes: #1602

Relevant Issue (if applicable)

#1602

Details

Introduce --backend-type, --backend-config and --backend-config-file options for unpack and compact subcommands in nydus-image.

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.

@SToPire SToPire requested a review from a team as a code owner July 30, 2024 17:15
@SToPire SToPire requested review from bergwolf, hsiangkao and Desiki-high and removed request for a team July 30, 2024 17:15
@SToPire
Copy link
Contributor Author

SToPire commented Jul 30, 2024

As it may break the existing usage of nydus-image unpack, I hope to take more advices for this PR. Then I will add the corresponding tests and update the doc.

Copy link

codecov bot commented Jul 30, 2024

Codecov Report

Attention: Patch coverage is 0% with 157 lines in your changes missing coverage. Please review.

Project coverage is 61.28%. Comparing base (3eb5c7b) to head (4ad1e46).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/bin/nydus-image/main.rs 0.00% 110 Missing ⚠️
storage/src/factory.rs 0.00% 47 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1606      +/-   ##
==========================================
- Coverage   61.42%   61.28%   -0.14%     
==========================================
  Files         146      146              
  Lines       48040    48143     +103     
  Branches    46007    46110     +103     
==========================================
- Hits        29510    29506       -4     
- Misses      16971    17075     +104     
- Partials     1559     1562       +3     
Files with missing lines Coverage Δ
storage/src/factory.rs 37.94% <0.00%> (-12.06%) ⬇️
src/bin/nydus-image/main.rs 0.63% <0.00%> (-0.03%) ⬇️

... and 3 files with indirect coverage changes

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 LGMT, thanks!

The cleanup of new registry is invalid as TestMain() calls os.Exit()
and will not run defer functions. This patch fixes the issue by
doing the cleanup explicitly.

Signed-off-by: Yifan Zhao <zhaoyifan@sjtu.edu.cn>
@@ -245,6 +248,43 @@ impl BlobFactory {
}
}

pub fn new_backend_from_json(
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 reuse new_backend here? we can also reuse the handle of #[cfg(feature = "backend-xxx")].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for I don't understand how to reuse new_backend as it takes BackendConfigV2 parameter and we need json string here?

Yes. The #[cfg(feature = "backend-xxx")] macro should be reused.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, let's only add the feature flag. :)

smoke/tests/main_test.go Show resolved Hide resolved
.required(true),
Arg::new("backend-type")
.long("backend-type")
.help("Type of backend [possible values: localdisk, s3, oss, registry, http-proxy]")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe provide a list method of backend types in storage/src/factory.rs and use it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will try it.

.arg(
Arg::new("backend-type")
.long("backend-type")
.help("Type of backend [possible values: localdisk, s3, oss, registry, http-proxy]")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto.

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!

Since unpack and compact subcommands does not need the entire nydusd
configuration file, let's refactor their cli interface and directly
take backend configuration file.

Specifically, we introduce `--backend-type`, `--backend-config` and
`--backend-config-file` options to specify the backend type and remove
`--config` option.

Signed-off-by: Yifan Zhao <zhaoyifan@sjtu.edu.cn>

Fixes: dragonflyoss#1602
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!

@imeoer imeoer merged commit d89410f into dragonflyoss:master Sep 10, 2024
25 checks passed
@SToPire SToPire deleted the image-fix-cli branch September 10, 2024 08:47
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.

Weird cli interface of nydus-image unpack (and also compact)
2 participants