Skip to content

Ensure that the rootfs dir is created in the bundle#3302

Merged
fuweid merged 1 commit intocontainerd:masterfrom
crosbymichael:mkroot
Jun 4, 2019
Merged

Ensure that the rootfs dir is created in the bundle#3302
fuweid merged 1 commit intocontainerd:masterfrom
crosbymichael:mkroot

Conversation

@crosbymichael
Copy link
Copy Markdown
Member

This fixes issues running gvisor on top of containerd without docker.

Signed-off-by: Michael Crosby [email protected]

@crosbymichael
Copy link
Copy Markdown
Member Author

@estesp this fixes the issue that you ran into on slack the other day

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented May 23, 2019

Build succeeded.

@codecov-io
Copy link
Copy Markdown

codecov-io commented May 23, 2019

Codecov Report

Merging #3302 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3302   +/-   ##
=======================================
  Coverage   44.66%   44.66%           
=======================================
  Files         112      112           
  Lines       12192    12192           
=======================================
  Hits         5445     5445           
  Misses       5913     5913           
  Partials      834      834
Flag Coverage Δ
#linux 48.56% <ø> (ø) ⬆️
#windows 39.94% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7451dd1...7531c66. Read the comment docs.

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

@Random-Liu
Copy link
Copy Markdown
Member

Random-Liu commented May 24, 2019

We removed this logic in c0f0b21.

If we add it back now, will it break them?

@crosbymichael
Copy link
Copy Markdown
Member Author

@georgethebeatle can you take a look at this?

@georgethebeatle
Copy link
Copy Markdown
Contributor

georgethebeatle commented May 30, 2019

@crosbymichael the idea of the linked commit was to make it possible to run containerd rootlessly. The main trick is that we will skip unmounting the rootfs when the rootfs dir does not exist:

if _, err := os.Stat(mount); os.IsNotExist(err) {
return nil
}

I don't think that this change will break our use case, because we are not yet using any snapshotter, so we do not have anything for containerd to unmount (we have worked arount the unmount in v1 by setting the rootfs to "" and most of the times it just log errors anyway). So I think we will work, but will have annoying EPERMS in the log.

One more thing - the newBundle method seems to have an analogue in v1: runtime/v1/linux/bundle.go and it might be a good idea that these two are in sync.

This fixes issues running gvisor on top of containerd without docker.

Signed-off-by: Michael Crosby <[email protected]>
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Jun 3, 2019

Build succeeded.

@crosbymichael
Copy link
Copy Markdown
Member Author

Updated to include v1

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

Thanks; still LGTM

@estesp
Copy link
Copy Markdown
Member

estesp commented Jun 3, 2019

Setting the cherry pick labels; please remove if not applicable

@crosbymichael
Copy link
Copy Markdown
Member Author

cherry-picks sound good

Copy link
Copy Markdown
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

@fuweid fuweid merged commit faa5f55 into containerd:master Jun 4, 2019
@fuweid
Copy link
Copy Markdown
Member

fuweid commented Jun 4, 2019

Hi @estesp

Both v2 and v1 in release/1.x have created rootfs. I think we can remove the cherry-pick label. :)

Release 1.2 - v2, v1

Release 1.1 - v1

@georgethebeatle
Copy link
Copy Markdown
Contributor

Hi @crosbymichael,

If you are bringing back bundle dir creation you can remove the code from the patch below:

diff --git a/mount/mount_linux.go b/mount/mount_linux.go
index 6bbc50bb..2cecff63 100644
--- a/mount/mount_linux.go
+++ b/mount/mount_linux.go
@@ -114,14 +114,10 @@ func unmount(target string, flags int) error {
 // UnmountAll all is noop when the first argument is an empty string.
 // This is done when the containerd client did not specify any rootfs
 // mounts (e.g. because the rootfs is managed outside containerd)
-// UnmountAll is noop when the mount path does not exist.
 func UnmountAll(mount string, flags int) error {
 	if mount == "" {
 		return nil
 	}
-	if _, err := os.Stat(mount); os.IsNotExist(err) {
-		return nil
-	}
 
 	for {
 		if err := unmount(mount, flags); err != nil {
diff --git a/runtime/v1/shim/service.go b/runtime/v1/shim/service.go
index 6e87f052..af83ee81 100644
--- a/runtime/v1/shim/service.go
+++ b/runtime/v1/shim/service.go
@@ -127,9 +127,6 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (_ *
 	rootfs := ""
 	if len(mounts) > 0 {
 		rootfs = filepath.Join(r.Bundle, "rootfs")
-		if err := os.Mkdir(rootfs, 0711); err != nil && !os.IsExist(err) {
-			return nil, err
-		}
 	}
 
 	config := &proc.CreateConfig{
diff --git a/runtime/v2/runc/container.go b/runtime/v2/runc/container.go
index ae8fb004..6c417dbf 100644
--- a/runtime/v2/runc/container.go
+++ b/runtime/v2/runc/container.go
@@ -21,7 +21,6 @@ package runc
 import (
 	"context"
 	"io/ioutil"
-	"os"
 	"path/filepath"
 	"sync"
 
@@ -68,9 +67,6 @@ func NewContainer(ctx context.Context, platform rproc.Platform, r *task.CreateTa
 	rootfs := ""
 	if len(mounts) > 0 {
 		rootfs = filepath.Join(r.Bundle, "rootfs")
-		if err := os.Mkdir(rootfs, 0711); err != nil && !os.IsExist(err) {
-			return nil, err
-		}
 	}
 
 	config := &proc.CreateConfig{

The Mkdir calls in shim service and container.go are redundant and so is the mount point existence check. I tested that the empty string check is enough for our use case to work, the rest was done so that we do not get false positive logs.

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.

7 participants