mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon: remove graphdriver indexing by OS (used for LCOW)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
b57e71941e
commit
076d9c6037
2 changed files with 67 additions and 101 deletions
146
daemon/daemon.go
146
daemon/daemon.go
|
@ -84,30 +84,28 @@ var (
|
||||||
|
|
||||||
// Daemon holds information about the Docker daemon.
|
// Daemon holds information about the Docker daemon.
|
||||||
type Daemon struct {
|
type Daemon struct {
|
||||||
ID string
|
ID string
|
||||||
repository string
|
repository string
|
||||||
containers container.Store
|
containers container.Store
|
||||||
containersReplica container.ViewDB
|
containersReplica container.ViewDB
|
||||||
execCommands *exec.Store
|
execCommands *exec.Store
|
||||||
imageService *images.ImageService
|
imageService *images.ImageService
|
||||||
idIndex *truncindex.TruncIndex
|
idIndex *truncindex.TruncIndex
|
||||||
configStore *config.Config
|
configStore *config.Config
|
||||||
statsCollector *stats.Collector
|
statsCollector *stats.Collector
|
||||||
defaultLogConfig containertypes.LogConfig
|
defaultLogConfig containertypes.LogConfig
|
||||||
RegistryService registry.Service
|
RegistryService registry.Service
|
||||||
EventsService *events.Events
|
EventsService *events.Events
|
||||||
netController libnetwork.NetworkController
|
netController libnetwork.NetworkController
|
||||||
volumes *volumesservice.VolumesService
|
volumes *volumesservice.VolumesService
|
||||||
discoveryWatcher discovery.Reloader
|
discoveryWatcher discovery.Reloader
|
||||||
root string
|
root string
|
||||||
seccompEnabled bool
|
seccompEnabled bool
|
||||||
apparmorEnabled bool
|
apparmorEnabled bool
|
||||||
shutdown bool
|
shutdown bool
|
||||||
idMapping *idtools.IdentityMapping
|
idMapping *idtools.IdentityMapping
|
||||||
// TODO: move graphDrivers field to an InfoService
|
graphDriver string // TODO: move graphDriver field to an InfoService
|
||||||
graphDrivers map[string]string // By operating system
|
PluginStore *plugin.Store // TODO: remove
|
||||||
|
|
||||||
PluginStore *plugin.Store // todo: remove
|
|
||||||
pluginManager *plugin.Manager
|
pluginManager *plugin.Manager
|
||||||
linkIndex *linkIndex
|
linkIndex *linkIndex
|
||||||
containerdCli *containerd.Client
|
containerdCli *containerd.Client
|
||||||
|
@ -251,8 +249,7 @@ func (daemon *Daemon) restore() error {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Ignore the container if it does not support the current driver being used by the graph
|
// Ignore the container if it does not support the current driver being used by the graph
|
||||||
currentDriverForContainerOS := daemon.graphDrivers[c.OS]
|
if (c.Driver == "" && daemon.graphDriver == "aufs") || c.Driver == daemon.graphDriver {
|
||||||
if (c.Driver == "" && currentDriverForContainerOS == "aufs") || c.Driver == currentDriverForContainerOS {
|
|
||||||
rwlayer, err := daemon.imageService.GetLayerByID(c.ID, c.OS)
|
rwlayer, err := daemon.imageService.GetLayerByID(c.ID, c.OS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("failed to load container mount")
|
log.WithError(err).Error("failed to load container mount")
|
||||||
|
@ -872,27 +869,19 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Windows we don't support the environment variable, or a user supplied graphdriver
|
|
||||||
// as Windows has no choice in terms of which graphdrivers to use. It's a case of
|
|
||||||
// running Windows containers on Windows - windowsfilter, running Linux containers on Windows,
|
|
||||||
// lcow. Unix platforms however run a single graphdriver for all containers, and it can
|
|
||||||
// be set through an environment variable, a daemon start parameter, or chosen through
|
|
||||||
// initialization of the layerstore through driver priority order for example.
|
|
||||||
d.graphDrivers = make(map[string]string)
|
|
||||||
layerStores := make(map[string]layer.Store)
|
|
||||||
if isWindows {
|
if isWindows {
|
||||||
d.graphDrivers[runtime.GOOS] = "windowsfilter"
|
// On Windows we don't support the environment variable, or a user supplied graphdriver
|
||||||
if system.LCOWSupported() {
|
d.graphDriver = "windowsfilter"
|
||||||
d.graphDrivers["linux"] = "lcow"
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
driverName := os.Getenv("DOCKER_DRIVER")
|
// Unix platforms however run a single graphdriver for all containers, and it can
|
||||||
if driverName == "" {
|
// be set through an environment variable, a daemon start parameter, or chosen through
|
||||||
driverName = config.GraphDriver
|
// initialization of the layerstore through driver priority order for example.
|
||||||
|
if drv := os.Getenv("DOCKER_DRIVER"); drv != "" {
|
||||||
|
d.graphDriver = drv
|
||||||
|
logrus.Infof("Setting the storage driver from the $DOCKER_DRIVER environment variable (%s)", drv)
|
||||||
} else {
|
} else {
|
||||||
logrus.Infof("Setting the storage driver from the $DOCKER_DRIVER environment variable (%s)", driverName)
|
d.graphDriver = config.GraphDriver // May still be empty. Layerstore init determines instead.
|
||||||
}
|
}
|
||||||
d.graphDrivers[runtime.GOOS] = driverName // May still be empty. Layerstore init determines instead.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d.RegistryService = registryService
|
d.RegistryService = registryService
|
||||||
|
@ -985,42 +974,39 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for operatingSystem, gd := range d.graphDrivers {
|
layerStore, err := layer.NewStoreFromOptions(layer.StoreOptions{
|
||||||
layerStores[operatingSystem], err = layer.NewStoreFromOptions(layer.StoreOptions{
|
Root: config.Root,
|
||||||
Root: config.Root,
|
MetadataStorePathTemplate: filepath.Join(config.Root, "image", "%s", "layerdb"),
|
||||||
MetadataStorePathTemplate: filepath.Join(config.Root, "image", "%s", "layerdb"),
|
GraphDriver: d.graphDriver,
|
||||||
GraphDriver: gd,
|
GraphDriverOptions: config.GraphOptions,
|
||||||
GraphDriverOptions: config.GraphOptions,
|
IDMapping: idMapping,
|
||||||
IDMapping: idMapping,
|
PluginGetter: d.PluginStore,
|
||||||
PluginGetter: d.PluginStore,
|
ExperimentalEnabled: config.Experimental,
|
||||||
ExperimentalEnabled: config.Experimental,
|
OS: runtime.GOOS,
|
||||||
OS: operatingSystem,
|
})
|
||||||
})
|
if err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// As layerstore initialization may set the driver
|
|
||||||
d.graphDrivers[operatingSystem] = layerStores[operatingSystem].DriverName()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure and validate the kernels security support. Note this is a Linux/FreeBSD
|
|
||||||
// operation only, so it is safe to pass *just* the runtime OS graphdriver.
|
|
||||||
if err := configureKernelSecuritySupport(config, d.graphDrivers[runtime.GOOS]); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
imageRoot := filepath.Join(config.Root, "image", d.graphDrivers[runtime.GOOS])
|
// As layerstore initialization may set the driver
|
||||||
|
d.graphDriver = layerStore.DriverName()
|
||||||
|
|
||||||
|
// Configure and validate the kernels security support. Note this is a Linux/FreeBSD
|
||||||
|
// operation only, so it is safe to pass *just* the runtime OS graphdriver.
|
||||||
|
if err := configureKernelSecuritySupport(config, d.graphDriver); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
imageRoot := filepath.Join(config.Root, "image", d.graphDriver)
|
||||||
ifs, err := image.NewFSStoreBackend(filepath.Join(imageRoot, "imagedb"))
|
ifs, err := image.NewFSStoreBackend(filepath.Join(imageRoot, "imagedb"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
lgrMap := make(map[string]image.LayerGetReleaser)
|
// TODO remove multiple imagestores map now that LCOW is no more
|
||||||
for los, ls := range layerStores {
|
imageStore, err := image.NewImageStore(ifs, map[string]image.LayerGetReleaser{
|
||||||
lgrMap[los] = ls
|
runtime.GOOS: layerStore,
|
||||||
}
|
})
|
||||||
imageStore, err := image.NewImageStore(ifs, lgrMap)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1098,7 +1084,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
|
||||||
DistributionMetadataStore: distributionMetadataStore,
|
DistributionMetadataStore: distributionMetadataStore,
|
||||||
EventsService: d.EventsService,
|
EventsService: d.EventsService,
|
||||||
ImageStore: imageStore,
|
ImageStore: imageStore,
|
||||||
LayerStores: layerStores,
|
LayerStores: map[string]layer.Store{runtime.GOOS: layerStore}, // TODO remove multiple LayerStores map now that LCOW is no more
|
||||||
MaxConcurrentDownloads: *config.MaxConcurrentDownloads,
|
MaxConcurrentDownloads: *config.MaxConcurrentDownloads,
|
||||||
MaxConcurrentUploads: *config.MaxConcurrentUploads,
|
MaxConcurrentUploads: *config.MaxConcurrentUploads,
|
||||||
MaxDownloadAttempts: *config.MaxDownloadAttempts,
|
MaxDownloadAttempts: *config.MaxDownloadAttempts,
|
||||||
|
@ -1156,20 +1142,10 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
|
||||||
engineCpus.Set(float64(info.NCPU))
|
engineCpus.Set(float64(info.NCPU))
|
||||||
engineMemory.Set(float64(info.MemTotal))
|
engineMemory.Set(float64(info.MemTotal))
|
||||||
|
|
||||||
gd := ""
|
|
||||||
for os, driver := range d.graphDrivers {
|
|
||||||
if len(gd) > 0 {
|
|
||||||
gd += ", "
|
|
||||||
}
|
|
||||||
gd += driver
|
|
||||||
if len(d.graphDrivers) > 1 {
|
|
||||||
gd = fmt.Sprintf("%s (%s)", gd, os)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"version": dockerversion.Version,
|
"version": dockerversion.Version,
|
||||||
"commit": dockerversion.GitCommit,
|
"commit": dockerversion.GitCommit,
|
||||||
"graphdriver(s)": gd,
|
"graphdriver": d.graphDriver,
|
||||||
}).Info("Docker daemon")
|
}).Info("Docker daemon")
|
||||||
|
|
||||||
return d, nil
|
return d, nil
|
||||||
|
|
|
@ -143,24 +143,14 @@ func (daemon *Daemon) fillClusterInfo(v *types.Info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (daemon *Daemon) fillDriverInfo(v *types.Info) {
|
func (daemon *Daemon) fillDriverInfo(v *types.Info) {
|
||||||
var ds [][2]string
|
switch daemon.graphDriver {
|
||||||
drivers := ""
|
case "aufs", "devicemapper", "overlay":
|
||||||
statuses := daemon.imageService.LayerStoreStatus()
|
v.Warnings = append(v.Warnings, fmt.Sprintf("WARNING: the %s storage-driver is deprecated, and will be removed in a future release.", daemon.graphDriver))
|
||||||
for os, gd := range daemon.graphDrivers {
|
|
||||||
ds = append(ds, statuses[os]...)
|
|
||||||
drivers += gd
|
|
||||||
if len(daemon.graphDrivers) > 1 {
|
|
||||||
drivers += fmt.Sprintf(" (%s) ", os)
|
|
||||||
}
|
|
||||||
switch gd {
|
|
||||||
case "aufs", "devicemapper", "overlay":
|
|
||||||
v.Warnings = append(v.Warnings, fmt.Sprintf("WARNING: the %s storage-driver is deprecated, and will be removed in a future release.", gd))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
drivers = strings.TrimSpace(drivers)
|
|
||||||
|
|
||||||
v.Driver = drivers
|
statuses := daemon.imageService.LayerStoreStatus()
|
||||||
v.DriverStatus = ds
|
v.Driver = daemon.graphDriver
|
||||||
|
v.DriverStatus = statuses[runtime.GOOS]
|
||||||
|
|
||||||
fillDriverWarnings(v)
|
fillDriverWarnings(v)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue