Browse Source

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>
Stefan J. Wernli 9 years ago
parent
commit
3e109f349f
4 changed files with 0 additions and 173 deletions
  1. 0 4
      daemon/daemon.go
  2. 0 7
      daemon/daemon_unix.go
  3. 0 88
      daemon/daemon_windows.go
  4. 0 74
      daemon/graphdriver/windows/windows.go

+ 0 - 4
daemon/daemon.go

@@ -545,10 +545,6 @@ func NewDaemon(config *Config, registryService registry.Service, containerdRemot
 		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()
 	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)

+ 0 - 7
daemon/daemon_unix.go

@@ -19,12 +19,10 @@ import (
 	"github.com/Sirupsen/logrus"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/image"
-	"github.com/docker/docker/layer"
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/sysinfo"
-	"github.com/docker/docker/reference"
 	"github.com/docker/docker/runconfig"
 	runconfigopts "github.com/docker/docker/runconfig/opts"
 	"github.com/docker/engine-api/types"
@@ -1064,11 +1062,6 @@ func (daemon *Daemon) conditionalUnmountOnCleanup(container *container.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) {
 	if !c.IsRunning() {
 		return nil, errNotRunning{c.ID}

+ 0 - 88
daemon/daemon_windows.go

@@ -1,27 +1,18 @@
 package daemon
 
 import (
-	"encoding/json"
-	"errors"
 	"fmt"
 	"os"
-	"path/filepath"
-	"runtime"
 	"strings"
 
 	"github.com/Microsoft/hcsshim"
 	"github.com/Sirupsen/logrus"
 	"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/layer"
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/sysinfo"
 	"github.com/docker/docker/pkg/system"
-	"github.com/docker/docker/reference"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/engine-api/types"
 	pblkiodev "github.com/docker/engine-api/types/blkiodev"
@@ -383,85 +374,6 @@ func (daemon *Daemon) conditionalUnmountOnCleanup(container *container.Container
 	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 {
 	return []nwconfig.Option{}
 }

+ 0 - 74
daemon/graphdriver/windows/windows.go

@@ -5,7 +5,6 @@ package windows
 import (
 	"bufio"
 	"bytes"
-	"crypto/sha512"
 	"encoding/json"
 	"fmt"
 	"io"
@@ -17,7 +16,6 @@ import (
 	"strings"
 	"sync"
 	"syscall"
-	"time"
 	"unsafe"
 
 	"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
 }
 
-// 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.
 func (d *Driver) GetMetadata(id string) (map[string]string, error) {
 	m := make(map[string]string)