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

Nydusify: support "view" subcommand to view Nydus image #603

Merged
merged 1 commit into from
Jul 21, 2022

Conversation

YushuoEdge
Copy link
Contributor

Nydusify provides a fsViewer to view the file system in the Nydus image.
The fsViewer will pull image's bootstrap according to its url, and it
will mount the file system to pointed path.

Users can view the file system then. For example, they can ran
$ trivy fs mount-path
to scan the whole image.

Signed-off-by: YushuoEdge y-shuo@sjtu.edu.cn

@yqleng1987
Copy link
Contributor

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

@yqleng1987
Copy link
Contributor

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

Test CaseTest Result
merge-target-branch✅ SUCCESS
build-docker-image✅ SUCCESS
compile-nydus✅ SUCCESS
compile-ctr-remote✅ SUCCESS
compile-nydus-snapshotter✅ SUCCESS
start-nydus-snapshotter-config-containerd✅ SUCCESS
run-container-with-nydus-image✅ SUCCESS

Congratulations, your test job passed!

@yqleng1987
Copy link
Contributor

@YushuoEdge , 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/13446

@yqleng1987
Copy link
Contributor

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

Test CaseTest Result
merge-target-branch✅ SUCCESS
build-docker-image✅ SUCCESS
compile-nydus✅ SUCCESS
compile-ctr-remote✅ SUCCESS
compile-nydus-snapshotter✅ SUCCESS
start-nydus-snapshotter-config-containerd✅ SUCCESS
run-container-with-nydus-image✅ SUCCESS

Congratulations, your test job passed!


&cli.StringFlag{Name: "mount-path", Value: "./image-fs", Usage: "The Path for the file system to mount on", EnvVars: []string{"MOUNT_PATH"}},
&cli.StringFlag{Name: "platform", Value: "linux/" + runtime.GOARCH, Usage: "Let nydusify choose image of specified platform from manifest index. Possible value is `amd64` or `arm64`"},
&cli.StringFlag{Name: "work-dir", Value: "./tmp", Usage: "Work directory path for image check, will be cleaned before checking", EnvVars: []string{"WORK_DIR"}},
Copy link
Collaborator

Choose a reason for hiding this comment

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

will be cleaned before viewing

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,maybe we should give a hint?

&cli.StringFlag{Name: "platform", Value: "linux/" + runtime.GOARCH, Usage: "Let nydusify choose image of specified platform from manifest index. Possible value is `amd64` or `arm64`"},
&cli.StringFlag{Name: "work-dir", Value: "./tmp", Usage: "Work directory path for image check, will be cleaned before checking", EnvVars: []string{"WORK_DIR"}},
&cli.StringFlag{Name: "nydusd", Value: "nydusd", Usage: "The nydusd binary path, if unset, search in PATH environment", EnvVars: []string{"NYDUSD"}},
&cli.StringFlag{Name: "backend-type", Value: "", Usage: "Specify Nydus blob storage backend type, will check file data in Nydus image if specified", EnvVars: []string{"BACKEND_TYPE"}},
Copy link
Collaborator

Choose a reason for hiding this comment

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

will allow viewing file data in Nydus image if specified

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we specify a specific backend type here?

@@ -203,11 +205,14 @@ func (nydusd *Nydusd) Mount() error {
return nil
}

func (nydusd *Nydusd) Umount() error {
func (nydusd *Nydusd) Umount(mountFlag bool) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to use silent bool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK!

return errors.Wrap(err, "clean up work directory error")
}

if err := os.MkdirAll(filepath.Join(fsViewer.WorkDir, "fs"), 0755); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Using 0750 is safer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK!

func (fsViewer *FsViewer) MountImage() error {
logrus.Infof("Mounting Nydus image to %s", fsViewer.NydusdConfig.MountPath)

if err := os.MkdirAll(fsViewer.NydusdConfig.BlobCacheDir, 0755); err != nil {
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
Contributor Author

Choose a reason for hiding this comment

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

OK!

return errors.Wrap(err, "create blob cache directory for Nydusd error")
}

if err := os.MkdirAll(fsViewer.NydusdConfig.MountPath, 0755); err != nil {
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
Contributor Author

Choose a reason for hiding this comment

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

OK!


go func() {
sig := <-sigs
fmt.Println("Received Signal: ", sig)
Copy link
Collaborator

Choose a reason for hiding this comment

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

logrus.Infof("Received Signal: %s", sig) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK!

done <- true
}()

fmt.Println("Please send signal SIGINT/SIGTERM to umount the file system")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto, use logrus.Info.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK!

@@ -397,6 +398,58 @@ func main() {
return checker.Check(context.Background())
},
},
{
Name: "view",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can add an alias Aliases: []string{"mount"},.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK!

@yqleng1987
Copy link
Contributor

@YushuoEdge , 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/15298

@yqleng1987
Copy link
Contributor

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

Test CaseTest Result
merge-target-branch✅ SUCCESS
build-docker-image✅ SUCCESS
compile-nydus✅ SUCCESS
compile-ctr-remote✅ SUCCESS
compile-nydus-snapshotter✅ SUCCESS
start-nydus-snapshotter-config-containerd✅ SUCCESS
run-container-with-nydus-image✅ SUCCESS

Congratulations, your test job passed!

Nydusify provides a fsViewer to view the file system in the Nydus image.
The fsViewer will pull image's bootstrap according to its url, and it
will mount the file system to pointed path.

Users can view the file system then. For example, they can ran
`$ trivy fs mount-path`
to scan the whole image.

Signed-off-by: YushuoEdge <y-shuo@sjtu.edu.cn>
@yqleng1987
Copy link
Contributor

@YushuoEdge , 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/15299

@yqleng1987
Copy link
Contributor

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

Test CaseTest Result
merge-target-branch✅ SUCCESS
build-docker-image✅ SUCCESS
compile-nydus✅ SUCCESS
compile-ctr-remote✅ SUCCESS
compile-nydus-snapshotter✅ SUCCESS
start-nydus-snapshotter-config-containerd✅ SUCCESS
run-container-with-nydus-image✅ SUCCESS

Congratulations, your test job passed!

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!

@imeoer imeoer merged commit e8a4b8f into dragonflyoss:master Jul 21, 2022
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.

3 participants