1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Change default values for devicemapper as variable instead of env

This commit is contained in:
Guillaume J. Charmes 2013-10-16 20:42:50 +00:00 committed by Solomon Hykes
parent 1da335f784
commit 3a246ac3d1
2 changed files with 16 additions and 35 deletions

View file

@ -17,9 +17,9 @@ import (
) )
var ( var (
defaultDataLoopbackSize int64 = 100 * 1024 * 1024 * 1024 DefaultDataLoopbackSize int64 = 100 * 1024 * 1024 * 1024
defaultMetaDataLoopbackSize int64 = 2 * 1024 * 1024 * 1024 DefaultMetaDataLoopbackSize int64 = 2 * 1024 * 1024 * 1024
defaultBaseFsSize uint64 = 10 * 1024 * 1024 * 1024 DefaultBaseFsSize uint64 = 10 * 1024 * 1024 * 1024
) )
type DevInfo struct { type DevInfo struct {
@ -47,30 +47,6 @@ type DeviceSetDM struct {
activeMounts map[string]int activeMounts map[string]int
} }
func init() {
var err error
rawMetaSize := os.Getenv("DOCKER_LOOPBACK_META_SIZE")
rawDataSize := os.Getenv("DOCKER_LOOPBACK_DATA_SIZE")
rawBaseFSSize := os.Getenv("DOCKER_BASE_FS_SIZE")
if rawMetaSize != "" {
if defaultMetaDataLoopbackSize, err = strconv.ParseInt(rawMetaSize, 0, 0); err != nil {
panic(err)
}
}
if rawDataSize != "" {
if defaultDataLoopbackSize, err = strconv.ParseInt(rawDataSize, 0, 0); err != nil {
panic(err)
}
}
if rawBaseFSSize != "" {
if defaultBaseFsSize, err = strconv.ParseUint(rawBaseFSSize, 0, 0); err != nil {
panic(err)
}
}
}
func getDevName(name string) string { func getDevName(name string) string {
return "/dev/mapper/" + name return "/dev/mapper/" + name
} }
@ -307,7 +283,8 @@ func (devices *DeviceSetDM) setupBaseImage() error {
return err return err
} }
info, err := devices.registerDevice(id, "", defaultBaseFsSize) utils.Debugf("Registering base device (id %v) with FS size %v", id, DefaultBaseFsSize)
info, err := devices.registerDevice(id, "", DefaultBaseFsSize)
if err != nil { if err != nil {
_ = deleteDevice(devices.getPoolDevName(), id) _ = deleteDevice(devices.getPoolDevName(), id)
utils.Debugf("\n--->Err: %s\n", err) utils.Debugf("\n--->Err: %s\n", err)
@ -416,13 +393,13 @@ begin:
/* If we create the loopback mounts we also need to initialize the base fs */ /* If we create the loopback mounts we also need to initialize the base fs */
createdLoopback := !devices.hasImage("data") || !devices.hasImage("metadata") createdLoopback := !devices.hasImage("data") || !devices.hasImage("metadata")
data, err := devices.ensureImage("data", defaultDataLoopbackSize) data, err := devices.ensureImage("data", DefaultDataLoopbackSize)
if err != nil { if err != nil {
utils.Debugf("Error device ensureImage (data): %s\n", err) utils.Debugf("Error device ensureImage (data): %s\n", err)
return err return err
} }
metadata, err := devices.ensureImage("metadata", defaultMetaDataLoopbackSize) metadata, err := devices.ensureImage("metadata", DefaultMetaDataLoopbackSize)
if err != nil { if err != nil {
utils.Debugf("Error device ensureImage (metadata): %s\n", err) utils.Debugf("Error device ensureImage (metadata): %s\n", err)
return err return err

View file

@ -28,6 +28,10 @@ const (
unitTestStoreBase = "/var/lib/docker/unit-tests" unitTestStoreBase = "/var/lib/docker/unit-tests"
testDaemonAddr = "127.0.0.1:4270" testDaemonAddr = "127.0.0.1:4270"
testDaemonProto = "tcp" testDaemonProto = "tcp"
unitTestDMDataLoopbackSize = 209715200 // 200MB
unitTestDMMetaDataLoopbackSize = 104857600 // 100MB
unitTestDMBaseFsSize = 157286400 // 150MB
) )
var ( var (
@ -152,9 +156,11 @@ func cleanupDevMapper() error {
func init() { func init() {
os.Setenv("TEST", "1") os.Setenv("TEST", "1")
os.Setenv("DOCKER_LOOPBACK_DATA_SIZE", "209715200") // 200MB // Set unit-test specific values
os.Setenv("DOCKER_LOOPBACK_META_SIZE", "104857600") // 100MB devmapper.DefaultDataLoopbackSize = unitTestDMDataLoopbackSize
os.Setenv("DOCKER_BASE_FS_SIZE", "157286400") // 150MB devmapper.DefaultMetaDataLoopbackSize = unitTestDMMetaDataLoopbackSize
devmapper.DefaultBaseFsSize = unitTestDMBaseFsSize
NetworkBridgeIface = unitTestNetworkBridge
// Hack to run sys init during unit testing // Hack to run sys init during unit testing
if selfPath := utils.SelfPath(); selfPath == "/sbin/init" || selfPath == "/.dockerinit" { if selfPath := utils.SelfPath(); selfPath == "/sbin/init" || selfPath == "/.dockerinit" {
@ -166,8 +172,6 @@ func init() {
log.Fatal("docker tests need to be run as root") log.Fatal("docker tests need to be run as root")
} }
NetworkBridgeIface = unitTestNetworkBridge
if err := cleanupDevMapper(); err != nil { if err := cleanupDevMapper(); err != nil {
log.Fatalf("Unable to cleanup devmapper: %s", err) log.Fatalf("Unable to cleanup devmapper: %s", err)
} }