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

Cherrypick overlay2 support for docker into v0.25 #1803

Merged
merged 3 commits into from
Nov 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions container/docker/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const (
devicemapperStorageDriver storageDriver = "devicemapper"
aufsStorageDriver storageDriver = "aufs"
overlayStorageDriver storageDriver = "overlay"
overlay2StorageDriver storageDriver = "overlay2"
zfsStorageDriver storageDriver = "zfs"
)

Expand Down
10 changes: 7 additions & 3 deletions container/docker/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ import (

const (
// The read write layers exist here.
aufsRWLayer = "diff"
aufsRWLayer = "diff"
overlay2RWLayer = "diff"

// Path to the directory where docker stores log files if the json logging driver is enabled.
pathToContainersDir = "containers"
)
Expand Down Expand Up @@ -177,7 +179,9 @@ func newDockerContainerHandler(
case aufsStorageDriver:
rootfsStorageDir = path.Join(storageDir, string(aufsStorageDriver), aufsRWLayer, rwLayerID)
case overlayStorageDriver:
rootfsStorageDir = path.Join(storageDir, string(overlayStorageDriver), rwLayerID)
rootfsStorageDir = path.Join(storageDir, string(storageDriver), rwLayerID)
case overlay2StorageDriver:
rootfsStorageDir = path.Join(storageDir, string(storageDriver), rwLayerID, overlay2RWLayer)
case devicemapperStorageDriver:
status, err := Status()
if err != nil {
Expand Down Expand Up @@ -359,7 +363,7 @@ func (self *dockerContainerHandler) getFsStats(stats *info.ContainerStats) error
// Device has to be the pool name to correlate with the device name as
// set in the machine info filesystems.
device = self.poolName
case aufsStorageDriver, overlayStorageDriver, zfsStorageDriver:
case aufsStorageDriver, overlayStorageDriver, overlay2StorageDriver, zfsStorageDriver:
deviceInfo, err := self.fsInfo.GetDirFsDevice(self.rootfsStorageDir)
if err != nil {
return fmt.Errorf("unable to determine device info for dir: %v: %v", self.rootfsStorageDir, err)
Expand Down
2 changes: 1 addition & 1 deletion fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func getDockerImagePaths(context Context) map[string]struct{} {

// TODO(rjnagal): Detect docker root and graphdriver directories from docker info.
dockerRoot := context.Docker.Root
for _, dir := range []string{"devicemapper", "btrfs", "aufs", "overlay", "zfs"} {
for _, dir := range []string{"devicemapper", "btrfs", "aufs", "overlay", "overlay2", "zfs"} {
dockerImagePaths[path.Join(dockerRoot, dir)] = struct{}{}
}
for dockerRoot != "/" && dockerRoot != "." {
Expand Down
21 changes: 21 additions & 0 deletions fs/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,27 @@ func TestAddDockerImagesLabel(t *testing.T) {
},
expectedDockerDevice: "/dev/sda1",
},
{
name: "[overlay2] root fs inside container - /var/lib/docker bindmount",
mounts: []*mount.Info{
{
Source: "overlay",
Mountpoint: "/",
Fstype: "overlay",
},
{
Source: "/dev/sdb1",
Mountpoint: "/var/lib/docker",
Fstype: "ext4",
},
{
Source: "/dev/sdb2",
Mountpoint: "/var/lib/docker/overlay2",
Fstype: "ext4",
},
},
expectedDockerDevice: "/dev/sdb2",
},
}

for _, tt := range tests {
Expand Down
9 changes: 3 additions & 6 deletions integration/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func New(t *testing.T) Framework {
const (
Aufs string = "aufs"
Overlay string = "overlay"
Overlay2 string = "overlay2"
DeviceMapper string = "devicemapper"
Unknown string = ""
)
Expand Down Expand Up @@ -276,12 +277,8 @@ func (self dockerActions) StorageDriver() string {
idx := strings.LastIndex(line, ": ") + 2
driver := line[idx:]
switch driver {
case Aufs:
return Aufs
case Overlay:
return Overlay
case DeviceMapper:
return DeviceMapper
case Aufs, Overlay, Overlay2, DeviceMapper:
return driver
default:
return Unknown
}
Expand Down
2 changes: 1 addition & 1 deletion integration/tests/api/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func TestDockerFilesystemStats(t *testing.T) {
}
needsBaseUsageCheck := false
switch storageDriver {
case framework.Aufs, framework.Overlay, framework.DeviceMapper:
case framework.Aufs, framework.Overlay, framework.Overlay2, framework.DeviceMapper:
needsBaseUsageCheck = true
}
pass := false
Expand Down
16 changes: 8 additions & 8 deletions pages/static/assets.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pages/templates.go

Large diffs are not rendered by default.