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

Removing Custom Images support

Now that Windows base images can be loaded directly into docker via "docker load" of a specialized tar file (with docker pull support on the horizon) we no longer have need of the custom images code path that loads images from a shared central location.  Removing that code and it's call points.

Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
This commit is contained in:
Stefan J. Wernli 2016-07-07 14:21:56 -07:00
parent db67db98d8
commit 3e109f349f
4 changed files with 0 additions and 173 deletions

View file

@ -545,10 +545,6 @@ func NewDaemon(config *Config, registryService registry.Service, containerdRemot
return nil, fmt.Errorf("Couldn't create Tag store repositories: %s", err) return nil, fmt.Errorf("Couldn't create Tag store repositories: %s", err)
} }
if err := restoreCustomImage(d.imageStore, d.layerStore, referenceStore); err != nil {
return nil, fmt.Errorf("Couldn't restore custom images: %s", err)
}
migrationStart := time.Now() migrationStart := time.Now()
if err := v1.Migrate(config.Root, graphDriver, d.layerStore, d.imageStore, referenceStore, distributionMetadataStore); err != nil { if err := v1.Migrate(config.Root, graphDriver, d.layerStore, d.imageStore, referenceStore, distributionMetadataStore); err != nil {
logrus.Errorf("Graph migration failed: %q. Your old graph data was found to be too inconsistent for upgrading to content-addressable storage. Some of the old data was probably not upgraded. We recommend starting over with a clean storage directory if possible.", err) logrus.Errorf("Graph migration failed: %q. Your old graph data was found to be too inconsistent for upgrading to content-addressable storage. Some of the old data was probably not upgraded. We recommend starting over with a clean storage directory if possible.", err)

View file

@ -19,12 +19,10 @@ import (
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/container" "github.com/docker/docker/container"
"github.com/docker/docker/image" "github.com/docker/docker/image"
"github.com/docker/docker/layer"
"github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/docker/pkg/parsers/kernel"
"github.com/docker/docker/pkg/sysinfo" "github.com/docker/docker/pkg/sysinfo"
"github.com/docker/docker/reference"
"github.com/docker/docker/runconfig" "github.com/docker/docker/runconfig"
runconfigopts "github.com/docker/docker/runconfig/opts" runconfigopts "github.com/docker/docker/runconfig/opts"
"github.com/docker/engine-api/types" "github.com/docker/engine-api/types"
@ -1064,11 +1062,6 @@ func (daemon *Daemon) conditionalUnmountOnCleanup(container *container.Container
return daemon.Unmount(container) return daemon.Unmount(container)
} }
func restoreCustomImage(is image.Store, ls layer.Store, rs reference.Store) error {
// Unix has no custom images to register
return nil
}
func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) { func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
if !c.IsRunning() { if !c.IsRunning() {
return nil, errNotRunning{c.ID} return nil, errNotRunning{c.ID}

View file

@ -1,27 +1,18 @@
package daemon package daemon
import ( import (
"encoding/json"
"errors"
"fmt" "fmt"
"os" "os"
"path/filepath"
"runtime"
"strings" "strings"
"github.com/Microsoft/hcsshim" "github.com/Microsoft/hcsshim"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/container" "github.com/docker/docker/container"
"github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/daemon/graphdriver/windows" // register the windows graph driver
"github.com/docker/docker/dockerversion"
"github.com/docker/docker/image" "github.com/docker/docker/image"
"github.com/docker/docker/layer"
"github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/pkg/sysinfo" "github.com/docker/docker/pkg/sysinfo"
"github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/system"
"github.com/docker/docker/reference"
"github.com/docker/docker/runconfig" "github.com/docker/docker/runconfig"
"github.com/docker/engine-api/types" "github.com/docker/engine-api/types"
pblkiodev "github.com/docker/engine-api/types/blkiodev" pblkiodev "github.com/docker/engine-api/types/blkiodev"
@ -383,85 +374,6 @@ func (daemon *Daemon) conditionalUnmountOnCleanup(container *container.Container
return nil return nil
} }
func restoreCustomImage(is image.Store, ls layer.Store, rs reference.Store) error {
type graphDriverStore interface {
GraphDriver() graphdriver.Driver
}
gds, ok := ls.(graphDriverStore)
if !ok {
return nil
}
driver := gds.GraphDriver()
wd, ok := driver.(*windows.Driver)
if !ok {
return nil
}
imageInfos, err := wd.GetCustomImageInfos()
if err != nil {
return err
}
// Convert imageData to valid image configuration
for _, info := range imageInfos {
name := strings.ToLower(info.Name)
type registrar interface {
RegisterDiffID(graphID string, size int64) (layer.Layer, error)
}
r, ok := ls.(registrar)
if !ok {
return errors.New("Layerstore doesn't support RegisterDiffID")
}
if _, err := r.RegisterDiffID(info.ID, info.Size); err != nil {
return err
}
// layer is intentionally not released
rootFS := image.NewRootFSWithBaseLayer(filepath.Base(info.Path))
// Create history for base layer
config, err := json.Marshal(&image.Image{
V1Image: image.V1Image{
DockerVersion: dockerversion.Version,
Architecture: runtime.GOARCH,
OS: runtime.GOOS,
Created: info.CreatedTime,
},
RootFS: rootFS,
History: []image.History{},
OSVersion: info.OSVersion,
OSFeatures: info.OSFeatures,
})
named, err := reference.ParseNamed(name)
if err != nil {
return err
}
ref, err := reference.WithTag(named, info.Version)
if err != nil {
return err
}
id, err := is.Create(config)
if err != nil {
logrus.Warnf("Failed to restore custom image %s with error: %s.", name, err)
logrus.Warnf("Skipping image %s...", name)
continue
}
if err := rs.AddTag(ref, id, true); err != nil {
return err
}
logrus.Debugf("Registered base layer %s as %s", ref, id)
}
return nil
}
func driverOptions(config *Config) []nwconfig.Option { func driverOptions(config *Config) []nwconfig.Option {
return []nwconfig.Option{} return []nwconfig.Option{}
} }

View file

@ -5,7 +5,6 @@ package windows
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"crypto/sha512"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
@ -17,7 +16,6 @@ import (
"strings" "strings"
"sync" "sync"
"syscall" "syscall"
"time"
"unsafe" "unsafe"
"github.com/Microsoft/go-winio" "github.com/Microsoft/go-winio"
@ -448,78 +446,6 @@ func (d *Driver) DiffSize(id, parent string) (size int64, err error) {
return archive.ChangesSize(layerFs, changes), nil return archive.ChangesSize(layerFs, changes), nil
} }
// CustomImageInfo is the object returned by the driver describing the base
// image.
type CustomImageInfo struct {
ID string
Name string
Version string
Path string
Size int64
CreatedTime time.Time
OSVersion string `json:"-"`
OSFeatures []string `json:"-"`
}
// GetCustomImageInfos returns the image infos for window specific
// base images which should always be present.
func (d *Driver) GetCustomImageInfos() ([]CustomImageInfo, error) {
strData, err := hcsshim.GetSharedBaseImages()
if err != nil {
return nil, fmt.Errorf("Failed to restore base images: %s", err)
}
type customImageInfoList struct {
Images []CustomImageInfo
}
var infoData customImageInfoList
if err = json.Unmarshal([]byte(strData), &infoData); err != nil {
err = fmt.Errorf("JSON unmarshal returned error=%s", err)
logrus.Error(err)
return nil, err
}
var images []CustomImageInfo
for _, imageData := range infoData.Images {
folderName := filepath.Base(imageData.Path)
// Use crypto hash of the foldername to generate a docker style id.
h := sha512.Sum384([]byte(folderName))
id := fmt.Sprintf("%x", h[:32])
if err := d.Create(id, "", "", nil); err != nil {
return nil, err
}
// Create the alternate ID file.
if err := d.setID(id, folderName); err != nil {
return nil, err
}
imageData.ID = id
// For now, hard code that all base images except nanoserver depend on win32k support
if imageData.Name != "NanoServer" {
imageData.OSFeatures = append(imageData.OSFeatures, "win32k")
}
versionData := strings.Split(imageData.Version, ".")
if len(versionData) != 4 {
logrus.Warnf("Could not parse Windows version %s", imageData.Version)
} else {
// Include just major.minor.build, skip the fourth version field, which does not influence
// OS compatibility.
imageData.OSVersion = strings.Join(versionData[:3], ".")
}
images = append(images, imageData)
}
return images, nil
}
// GetMetadata returns custom driver information. // GetMetadata returns custom driver information.
func (d *Driver) GetMetadata(id string) (map[string]string, error) { func (d *Driver) GetMetadata(id string) (map[string]string, error) {
m := make(map[string]string) m := make(map[string]string)